ConfigurazioneHelper.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.web.ctrlstat.servlet.config;

  21. import java.net.URL;
  22. import java.nio.file.InvalidPathException;
  23. import java.nio.file.Paths;
  24. import java.text.MessageFormat;
  25. import java.util.ArrayList;
  26. import java.util.Collections;
  27. import java.util.Date;
  28. import java.util.Enumeration;
  29. import java.util.HashMap;
  30. import java.util.Iterator;
  31. import java.util.List;
  32. import java.util.Map;
  33. import java.util.Properties;
  34. import java.util.Scanner;
  35. import java.util.Set;
  36. import java.util.stream.Collectors;

  37. import javax.servlet.http.HttpServletRequest;
  38. import javax.servlet.http.HttpSession;

  39. import org.apache.commons.lang.StringEscapeUtils;
  40. import org.apache.commons.lang.StringUtils;
  41. import org.openspcoop2.core.allarmi.Allarme;
  42. import org.openspcoop2.core.allarmi.AllarmeFiltro;
  43. import org.openspcoop2.core.allarmi.constants.RuoloPorta;
  44. import org.openspcoop2.core.allarmi.constants.StatoAllarme;
  45. import org.openspcoop2.core.allarmi.constants.TipoAllarme;
  46. import org.openspcoop2.core.allarmi.constants.TipoPeriodo;
  47. import org.openspcoop2.core.allarmi.utils.AllarmiConverterUtils;
  48. import org.openspcoop2.core.commons.ErrorsHandlerCostant;
  49. import org.openspcoop2.core.commons.Filtri;
  50. import org.openspcoop2.core.commons.ISearch;
  51. import org.openspcoop2.core.commons.Liste;
  52. import org.openspcoop2.core.commons.ModalitaIdentificazione;
  53. import org.openspcoop2.core.commons.SearchUtils;
  54. import org.openspcoop2.core.commons.dao.DAOFactoryException;
  55. import org.openspcoop2.core.config.AccessoRegistro;
  56. import org.openspcoop2.core.config.AccessoRegistroRegistro;
  57. import org.openspcoop2.core.config.CanaleConfigurazione;
  58. import org.openspcoop2.core.config.CanaleConfigurazioneNodo;
  59. import org.openspcoop2.core.config.CanaliConfigurazione;
  60. import org.openspcoop2.core.config.Configurazione;
  61. import org.openspcoop2.core.config.ConfigurazioneHandler;
  62. import org.openspcoop2.core.config.ConfigurazioneUrlInvocazioneRegola;
  63. import org.openspcoop2.core.config.Connettore;
  64. import org.openspcoop2.core.config.Dump;
  65. import org.openspcoop2.core.config.GenericProperties;
  66. import org.openspcoop2.core.config.GestioneToken;
  67. import org.openspcoop2.core.config.MessaggiDiagnostici;
  68. import org.openspcoop2.core.config.OpenspcoopAppender;
  69. import org.openspcoop2.core.config.OpenspcoopSorgenteDati;
  70. import org.openspcoop2.core.config.PortaApplicativa;
  71. import org.openspcoop2.core.config.PortaDelegata;
  72. import org.openspcoop2.core.config.Property;
  73. import org.openspcoop2.core.config.Proprieta;
  74. import org.openspcoop2.core.config.RegistroPlugin;
  75. import org.openspcoop2.core.config.RegistroPluginArchivio;
  76. import org.openspcoop2.core.config.ResponseCachingConfigurazioneRegola;
  77. import org.openspcoop2.core.config.Route;
  78. import org.openspcoop2.core.config.RoutingTable;
  79. import org.openspcoop2.core.config.RoutingTableDestinazione;
  80. import org.openspcoop2.core.config.SystemProperties;
  81. import org.openspcoop2.core.config.Tracciamento;
  82. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  83. import org.openspcoop2.core.config.constants.FaseMessageHandler;
  84. import org.openspcoop2.core.config.constants.FaseServiceHandler;
  85. import org.openspcoop2.core.config.constants.PluginCostanti;
  86. import org.openspcoop2.core.config.constants.PluginSorgenteArchivio;
  87. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  88. import org.openspcoop2.core.config.constants.StatoFunzionalitaCacheDigestQueryParameter;
  89. import org.openspcoop2.core.config.constants.StatoFunzionalitaConWarning;
  90. import org.openspcoop2.core.config.constants.TipoGestioneCORS;
  91. import org.openspcoop2.core.config.driver.DriverConfigurazioneNotFound;
  92. import org.openspcoop2.core.config.driver.db.DriverConfigurazioneDBLib;
  93. import org.openspcoop2.core.config.driver.db.IDServizioApplicativoDB;
  94. import org.openspcoop2.core.constants.CostantiLabel;
  95. import org.openspcoop2.core.constants.TipoPdD;
  96. import org.openspcoop2.core.controllo_traffico.AttivazionePolicy;
  97. import org.openspcoop2.core.controllo_traffico.AttivazionePolicyFiltro;
  98. import org.openspcoop2.core.controllo_traffico.AttivazionePolicyRaggruppamento;
  99. import org.openspcoop2.core.controllo_traffico.Cache;
  100. import org.openspcoop2.core.controllo_traffico.ConfigurazioneControlloTraffico;
  101. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  102. import org.openspcoop2.core.controllo_traffico.ConfigurazionePolicy;
  103. import org.openspcoop2.core.controllo_traffico.ConfigurazioneRateLimiting;
  104. import org.openspcoop2.core.controllo_traffico.ConfigurazioneRateLimitingProprieta;
  105. import org.openspcoop2.core.controllo_traffico.TempiRispostaErogazione;
  106. import org.openspcoop2.core.controllo_traffico.TempiRispostaFruizione;
  107. import org.openspcoop2.core.controllo_traffico.beans.InfoPolicy;
  108. import org.openspcoop2.core.controllo_traffico.beans.JMXConstants;
  109. import org.openspcoop2.core.controllo_traffico.beans.UniqueIdentifierUtilities;
  110. import org.openspcoop2.core.controllo_traffico.constants.CacheAlgorithm;
  111. import org.openspcoop2.core.controllo_traffico.constants.RuoloPolicy;
  112. import org.openspcoop2.core.controllo_traffico.constants.TipoApplicabilita;
  113. import org.openspcoop2.core.controllo_traffico.constants.TipoBanda;
  114. import org.openspcoop2.core.controllo_traffico.constants.TipoControlloPeriodo;
  115. import org.openspcoop2.core.controllo_traffico.constants.TipoErrore;
  116. import org.openspcoop2.core.controllo_traffico.constants.TipoFiltroApplicativo;
  117. import org.openspcoop2.core.controllo_traffico.constants.TipoFinestra;
  118. import org.openspcoop2.core.controllo_traffico.constants.TipoLatenza;
  119. import org.openspcoop2.core.controllo_traffico.constants.TipoPeriodoRealtime;
  120. import org.openspcoop2.core.controllo_traffico.constants.TipoPeriodoStatistico;
  121. import org.openspcoop2.core.controllo_traffico.constants.TipoRisorsa;
  122. import org.openspcoop2.core.controllo_traffico.constants.TipoRisorsaPolicyAttiva;
  123. import org.openspcoop2.core.controllo_traffico.driver.PolicyGroupByActiveThreadsType;
  124. import org.openspcoop2.core.controllo_traffico.utils.PolicyUtilities;
  125. import org.openspcoop2.core.id.IDPortaApplicativa;
  126. import org.openspcoop2.core.id.IDPortaDelegata;
  127. import org.openspcoop2.core.id.IDServizio;
  128. import org.openspcoop2.core.id.IDServizioApplicativo;
  129. import org.openspcoop2.core.id.IDSoggetto;
  130. import org.openspcoop2.core.mapping.MappingErogazionePortaApplicativa;
  131. import org.openspcoop2.core.mapping.MappingFruizionePortaDelegata;
  132. import org.openspcoop2.core.mvc.properties.utils.ConfigManager;
  133. import org.openspcoop2.core.mvc.properties.utils.PropertiesSourceConfiguration;
  134. import org.openspcoop2.core.plugins.Plugin;
  135. import org.openspcoop2.core.plugins.constants.TipoPlugin;
  136. import org.openspcoop2.core.plugins.utils.handlers.ConfigurazioneHandlerBean;
  137. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  138. import org.openspcoop2.core.registry.Soggetto;
  139. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  140. import org.openspcoop2.core.registry.constants.CostantiRegistroServizi;
  141. import org.openspcoop2.core.registry.constants.CredenzialeTipo;
  142. import org.openspcoop2.core.registry.constants.PddTipologia;
  143. import org.openspcoop2.core.registry.constants.RuoloTipologia;
  144. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  145. import org.openspcoop2.core.registry.driver.FiltroRicercaGruppi;
  146. import org.openspcoop2.core.registry.driver.FiltroRicercaRuoli;
  147. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  148. import org.openspcoop2.core.registry.driver.db.IDSoggettoDB;
  149. import org.openspcoop2.core.transazioni.utils.TipoCredenzialeMittente;
  150. import org.openspcoop2.generic_project.exception.NotFoundException;
  151. import org.openspcoop2.message.constants.ServiceBinding;
  152. import org.openspcoop2.monitor.engine.alarm.AlarmContext;
  153. import org.openspcoop2.monitor.engine.alarm.AlarmEngineConfig;
  154. import org.openspcoop2.monitor.engine.alarm.utils.AllarmiUtils;
  155. import org.openspcoop2.monitor.engine.alarm.wrapper.ConfigurazioneAllarmeBean;
  156. import org.openspcoop2.monitor.engine.alarm.wrapper.ConfigurazioneAllarmeHistoryBean;
  157. import org.openspcoop2.monitor.engine.dynamic.DynamicFactory;
  158. import org.openspcoop2.monitor.engine.dynamic.IDynamicValidator;
  159. import org.openspcoop2.monitor.sdk.condition.Context;
  160. import org.openspcoop2.monitor.sdk.constants.ParameterType;
  161. import org.openspcoop2.monitor.sdk.exceptions.ValidationException;
  162. import org.openspcoop2.monitor.sdk.plugins.FiltersConfiguration;
  163. import org.openspcoop2.monitor.sdk.plugins.GroupByConfiguration;
  164. import org.openspcoop2.pdd.config.ConfigurazionePdD;
  165. import org.openspcoop2.pdd.core.CostantiPdD;
  166. import org.openspcoop2.pdd.core.GestoreRichieste;
  167. import org.openspcoop2.pdd.core.connettori.ConnettoreCheck;
  168. import org.openspcoop2.pdd.core.controllo_traffico.policy.config.PolicyConfiguration;
  169. import org.openspcoop2.pdd.core.integrazione.GruppoIntegrazione;
  170. import org.openspcoop2.pdd.core.jmx.JMXUtils;
  171. import org.openspcoop2.pdd.core.token.PolicyGestioneToken;
  172. import org.openspcoop2.pdd.core.token.PolicyNegoziazioneToken;
  173. import org.openspcoop2.pdd.core.token.TokenUtilities;
  174. import org.openspcoop2.pdd.core.token.attribute_authority.TipologiaResponseAttributeAuthority;
  175. import org.openspcoop2.pdd.logger.LogLevels;
  176. import org.openspcoop2.pdd.logger.filetrace.FileTraceGovWayState;
  177. import org.openspcoop2.pdd.timers.TimerState;
  178. import org.openspcoop2.protocol.engine.ProtocolFactoryManager;
  179. import org.openspcoop2.protocol.engine.utils.NamingUtils;
  180. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  181. import org.openspcoop2.protocol.sdk.InformazioniProtocollo;
  182. import org.openspcoop2.protocol.sdk.archive.ExportMode;
  183. import org.openspcoop2.protocol.sdk.constants.ArchiveType;
  184. import org.openspcoop2.protocol.utils.ProtocolUtils;
  185. import org.openspcoop2.utils.Utilities;
  186. import org.openspcoop2.utils.UtilsException;
  187. import org.openspcoop2.utils.certificate.byok.BYOKManager;
  188. import org.openspcoop2.utils.date.DateManager;
  189. import org.openspcoop2.utils.date.DateUtils;
  190. import org.openspcoop2.utils.properties.PropertiesUtilities;
  191. import org.openspcoop2.utils.regexp.RegularExpressionEngine;
  192. import org.openspcoop2.utils.resources.MapReader;
  193. import org.openspcoop2.utils.transport.http.HttpResponse;
  194. import org.openspcoop2.utils.transport.http.HttpUtilities;
  195. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  196. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  197. import org.openspcoop2.web.ctrlstat.core.DAOConsoleFactory;
  198. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  199. import org.openspcoop2.web.ctrlstat.costanti.InUsoType;
  200. import org.openspcoop2.web.ctrlstat.costanti.MultitenantSoggettiErogazioni;
  201. import org.openspcoop2.web.ctrlstat.costanti.MultitenantSoggettiFruizioni;
  202. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationException;
  203. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationNotFound;
  204. import org.openspcoop2.web.ctrlstat.servlet.ApiKeyState;
  205. import org.openspcoop2.web.ctrlstat.servlet.ConsoleHelper;
  206. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCostanti;
  207. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCostanti;
  208. import org.openspcoop2.web.ctrlstat.servlet.archivi.ArchiviCostanti;
  209. import org.openspcoop2.web.ctrlstat.servlet.archivi.ExporterUtils;
  210. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCostanti;
  211. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeHelper;
  212. import org.openspcoop2.web.ctrlstat.servlet.pd.PorteDelegateCostanti;
  213. import org.openspcoop2.web.ctrlstat.servlet.pd.PorteDelegateHelper;
  214. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCostanti;
  215. import org.openspcoop2.web.lib.mvc.AreaBottoni;
  216. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  217. import org.openspcoop2.web.lib.mvc.CheckboxStatusType;
  218. import org.openspcoop2.web.lib.mvc.Costanti;
  219. import org.openspcoop2.web.lib.mvc.DataElement;
  220. import org.openspcoop2.web.lib.mvc.DataElementImage;
  221. import org.openspcoop2.web.lib.mvc.DataElementInfo;
  222. import org.openspcoop2.web.lib.mvc.DataElementType;
  223. import org.openspcoop2.web.lib.mvc.MessageType;
  224. import org.openspcoop2.web.lib.mvc.PageData;
  225. import org.openspcoop2.web.lib.mvc.Parameter;
  226. import org.openspcoop2.web.lib.mvc.ServletUtils;
  227. import org.openspcoop2.web.lib.mvc.TipoOperazione;
  228. import org.openspcoop2.web.lib.mvc.dynamic.components.BaseComponent;
  229. import org.openspcoop2.web.lib.mvc.dynamic.components.Hidden;
  230. import org.openspcoop2.web.lib.users.dao.User;

  231. /**
  232.  * ConfigurazioneHelper
  233.  *
  234.  * @author Poli Andrea (apoli@link.it)
  235.  * @author $Author$
  236.  * @version $Rev$, $Date$
  237.  */
  238. public class ConfigurazioneHelper extends ConsoleHelper{

  239.     public ConfigurazioneHelper(HttpServletRequest request, PageData pd,
  240.             HttpSession session) throws Exception {
  241.         super(request, pd,  session);
  242.     }
  243.     public ConfigurazioneHelper(ControlStationCore core, HttpServletRequest request, PageData pd,
  244.             HttpSession session) throws Exception {
  245.         super(core, request, pd,  session);
  246.     }

  247.     public List<DataElement>   addIdProprietaToDati(TipoOperazione tipoOp, String idprop, List<DataElement> dati) {
  248.         DataElement de = new DataElement();

  249.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ID_PROPRIETA);
  250.         de.setValue(idprop);
  251.         de.setType(DataElementType.HIDDEN);
  252.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID_PROPRIETA);
  253.         dati.add(de);

  254.         return dati;
  255.     }

  256.     public List<DataElement> addTipoTracciamentoAppenderToDati(TipoOperazione tipoOp, String tipo,
  257.             List<DataElement> dati,String idAppenderDati, int dimensioneAppenderDati) {
  258.        
  259.         DataElement de = new DataElement();
  260.         de.setType(DataElementType.TITLE);
  261.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_APPENDER);
  262.         dati.add(de);
  263.        
  264.         de = new DataElement();
  265.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO);
  266.         de.setValue(tipo);
  267.         de.setType(DataElementType.TEXT_EDIT);
  268.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);
  269.         de.setSize(getSize());
  270.         de.setRequired(true);
  271.         dati.add(de);

  272.         if(tipoOp.equals(TipoOperazione.CHANGE)){
  273.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  274.             de = new DataElement();
  275.             de.setType(DataElementType.LINK);
  276.             de.setUrl(
  277.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_APPENDER_PROPERTIES_LIST ,
  278.                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, idAppenderDati));
  279.             if (contaListe!=null && contaListe.booleanValue())
  280.                 ServletUtils.setDataElementVisualizzaLabel(de, (long) dimensioneAppenderDati);
  281.             else
  282.                 ServletUtils.setDataElementVisualizzaLabel(de);
  283.             dati.add(de);
  284.         }

  285.         return dati;
  286.     }

  287.     public String convertLifeCacheValue(String v) {
  288.         if(v==null) {
  289.             return "-1";
  290.         }
  291.         try {
  292.             int vInt = Integer.valueOf(v);
  293.             if(vInt>0) {
  294.                 return vInt+"";
  295.             }
  296.             else {
  297.                 return "-1";
  298.             }
  299.         }catch(Exception e) {
  300.             return "-1";
  301.         }
  302.     }
  303.    
  304.     public void setDataElementCRLCacheInfo(List<DataElement> dati,
  305.             String nomeParametroCrlLifeCache, String crllifecache,
  306.             boolean allHidden){
  307.    
  308.         boolean view = this.isModalitaAvanzata() && !allHidden;
  309.        
  310.         DataElement de = new DataElement();
  311.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CRL_LIFE_CACHE);
  312.         int value = -1;
  313.         try {
  314.             value = Integer.valueOf(crllifecache);
  315.         }catch(Exception e) {
  316.             // value
  317.         }
  318.         if(value>0){
  319.             de.setValue(value+"");
  320.         }
  321.         if(view){
  322.             de.setType(DataElementType.TEXT_EDIT);
  323.             de.setNote(ConfigurazioneCostanti.LABEL_CACHE_SECONDS_NOTE);
  324.         }
  325.         else{
  326.             de.setType(DataElementType.HIDDEN);
  327.         }
  328.         de.setName(nomeParametroCrlLifeCache);
  329.         de.setSize( getSize());
  330.         dati.add(de);
  331.        
  332.     }
  333.    
  334.     public void setDataElementCache(List<DataElement> dati, String intestazioneSezione,
  335.             String nomeParametroStatoCache, String statocache,
  336.             String nomeParametroDimensioneCache, String dimensionecache,
  337.             String nomeParametroAlgoritmoCache, String algoritmocache,
  338.             String nomeParametroIdleCache, String idlecache,
  339.             String nomeParametroLifeCache, String lifecache,
  340.             boolean allHidden){
  341.        
  342.         boolean view = this.isModalitaAvanzata() && !allHidden;
  343.        
  344.         if(view){
  345.             DataElement de = new DataElement();
  346.             de.setLabel(intestazioneSezione);
  347.             de.setType(DataElementType.TITLE);
  348.             dati.add(de);
  349.         }

  350.         String[] tipoStatoCache = {
  351.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  352.                 ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO
  353.         };
  354.         DataElement de = new DataElement();
  355.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO_CACHE);
  356.         de.setName(nomeParametroStatoCache);
  357.         if(view &&
  358.                 !ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CACHE_RISPOSTE.equals(intestazioneSezione) &&
  359.                 !ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CACHE_CONSEGNA_APPLICATIVI.equals(intestazioneSezione)){
  360.             de.setType(DataElementType.SELECT);
  361.             de.setValues(tipoStatoCache);
  362.             de.setSelected(statocache);
  363.             de.setPostBack(true);
  364.         }
  365.         else{
  366.             de.setType(DataElementType.HIDDEN);
  367.             de.setValue(statocache);
  368.         }
  369.         dati.add(de);

  370.         if (statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO)) {
  371.             de = new DataElement();
  372.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE);
  373.             de.setValue(dimensionecache);
  374.             if(view){
  375.                 de.setType(DataElementType.TEXT_EDIT);
  376.                 de.setRequired(true);
  377.             }
  378.             else{
  379.                 de.setType(DataElementType.HIDDEN);
  380.             }
  381.             de.setName(nomeParametroDimensioneCache);
  382.             de.setSize( getSize());
  383.             dati.add(de);

  384.             String[] tipoAlg = {
  385.                     ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_LRU,
  386.                     ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_MRU
  387.             };
  388.             String[] labelsAlg = {
  389.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_LRU,
  390.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_MRU
  391.             };
  392.             de = new DataElement();
  393.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE);
  394.             de.setName(nomeParametroAlgoritmoCache);
  395.             if(view){
  396.                 de.setType(DataElementType.SELECT);
  397.                 de.setLabels(labelsAlg);
  398.                 de.setValues(tipoAlg);
  399.                 de.setSelected(algoritmocache);
  400.             }
  401.             else{
  402.                 de.setType(DataElementType.HIDDEN);
  403.                 de.setValue(algoritmocache);
  404.             }
  405.             dati.add(de);

  406.             de = new DataElement();
  407.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIFE_CACHE);
  408.             int value = -1;
  409.             try {
  410.                 value = Integer.valueOf(lifecache);
  411.             }catch(Exception e) {
  412.                 // value
  413.             }
  414.             if(value>0){
  415.                 de.setValue(value+"");
  416.             }
  417.             if(view &&
  418.                     !ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CACHE_RISPOSTE.equals(intestazioneSezione) &&
  419.                     !ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CACHE_CONSEGNA_APPLICATIVI.equals(intestazioneSezione)){
  420.                 de.setType(DataElementType.TEXT_EDIT);
  421.                 //de.setRequired(true);
  422.             }
  423.             else{
  424.                 de.setType(DataElementType.HIDDEN);
  425.             }
  426.             de.setName(nomeParametroLifeCache);
  427.             de.setSize( getSize());
  428.             dati.add(de);

  429.             de = new DataElement();
  430.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_IDLE_CACHE);
  431.             de.setValue(idlecache);
  432.             if(view &&
  433.                     !ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CACHE_CONSEGNA_APPLICATIVI.equals(intestazioneSezione)){
  434.                 de.setType(DataElementType.TEXT_EDIT);
  435.                 if(!ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CACHE_KEYSTORE.equals(intestazioneSezione)){
  436.                     de.setNote(ConfigurazioneCostanti.LABEL_CACHE_SECONDS_NOTE);
  437.                 }
  438.             }
  439.             else{
  440.                 de.setType(DataElementType.HIDDEN);
  441.             }
  442.             de.setName(nomeParametroIdleCache);
  443.             de.setSize( getSize());
  444.             dati.add(de);
  445.         }
  446.        
  447.     }
  448.    
  449.     public List<DataElement> addConfigurazioneRegistroToDati(String statocache,
  450.             String dimensionecache, String algoritmocache, String idlecache,
  451.             String lifecache, List<DataElement> dati) {
  452.        
  453.         DataElement de = new DataElement();
  454.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_REGISTRO_ROTTA);
  455.         de.setType(DataElementType.TITLE);
  456.         dati.add(de);

  457.         de = new DataElement();
  458.         de.setType(DataElementType.LINK);
  459.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_REGISTRI_LIST);
  460.         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_REGISTRI);
  461.         dati.add(de);

  462.         this.setDataElementCache(dati,ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CACHE_REGISTRY,
  463.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_REGISTRY,statocache,
  464.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_REGISTRY,dimensionecache,
  465.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_REGISTRY,algoritmocache,
  466.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_REGISTRY,idlecache,
  467.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_REGISTRY,lifecache,
  468.                 false);

  469.         if(this.isModalitaStandard()){
  470.             this.pd.disableEditMode();
  471.         }
  472.        
  473.         dati = this.addParameterApplicaModifica(dati);
  474.        
  475.         return dati;
  476.     }


  477.     public List<DataElement> addTipoDiagnosticaAppenderToDati(TipoOperazione tipoOp, String tipo,
  478.             List<DataElement> dati,String idAppenderDati, int dimensioneAppenderDati) {
  479.        
  480.         DataElement de = new DataElement();
  481.         de.setType(DataElementType.TITLE);
  482.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_APPENDER);
  483.         dati.add(de);
  484.        
  485.         de = new DataElement();
  486.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO);
  487.         de.setValue(tipo);
  488.         de.setType(DataElementType.TEXT_EDIT);
  489.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);
  490.         de.setSize(getSize());
  491.         de.setRequired(true);
  492.         dati.add(de);

  493.         if(tipoOp.equals(TipoOperazione.CHANGE)){
  494.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  495.             de = new DataElement();
  496.             de.setType(DataElementType.LINK);
  497.             de.setUrl(
  498.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_APPENDER_PROPERTIES_LIST,
  499.                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, idAppenderDati));
  500.             if (contaListe!=null && contaListe.booleanValue())
  501.                 ServletUtils.setDataElementVisualizzaLabel(de, (long) dimensioneAppenderDati);
  502.             else
  503.                 ServletUtils.setDataElementVisualizzaLabel(de);
  504.             dati.add(de);
  505.         }

  506.         return dati;
  507.     }

  508.     public List<DataElement>   addDiagnosticaDatasourceToDati(TipoOperazione tipoOp, String nome, String nomeJndi,
  509.             String tipoDatabase, String[] tipoDbList, List<DataElement> dati, String idSorgenteDati, int dimensioneSorgenteDati) {
  510.        
  511.         DataElement de = new DataElement();
  512.         de.setType(DataElementType.TITLE);
  513.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SORGENTI_DATI);
  514.         dati.add(de);
  515.        
  516.         de = new DataElement();
  517.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME);
  518.         de.setValue(nome);
  519.         de.setType(DataElementType.TEXT_EDIT);
  520.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  521.         de.setSize(getSize());
  522.         de.setRequired(true);
  523.         dati.add(de);

  524.         de = new DataElement();
  525.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME_JNDI);
  526.         de.setValue(nomeJndi);
  527.         de.setType(DataElementType.TEXT_EDIT);
  528.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_JNDI);
  529.         de.setSize(getSize());
  530.         de.setRequired(true);
  531.         dati.add(de);

  532.         de = new DataElement();
  533.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_DATABASE);
  534.         de.setType(DataElementType.SELECT);
  535.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_DATABASE);
  536.         de.setValues(tipoDbList);
  537.         if(tipoDatabase != null){
  538.             de.setSelected(tipoDatabase);
  539.         }
  540.         de.setRequired(true);
  541.         dati.add(de);

  542.         if(tipoOp .equals(TipoOperazione.CHANGE)){
  543.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  544.             de = new DataElement();
  545.             de.setType(DataElementType.LINK);
  546.             de.setUrl(
  547.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_DATASOURCE_PROPERTIES_LIST,
  548.                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, idSorgenteDati));
  549.             if (contaListe!=null && contaListe.booleanValue())
  550.                 ServletUtils.setDataElementVisualizzaLabel(de, (long) dimensioneSorgenteDati);
  551.             else
  552.                 ServletUtils.setDataElementVisualizzaLabel(de);
  553.             dati.add(de);
  554.         }

  555.         return dati;
  556.     }

  557.     public List<DataElement>   addTracciamentoDatasourceToDati(TipoOperazione tipoOp, String nome, String nomeJndi,
  558.             String tipoDatabase, String[] tipoDbList, List<DataElement> dati, String idSorgenteDati, int dimensioneSorgenteDati) {

  559.         DataElement de = new DataElement();
  560.         de.setType(DataElementType.TITLE);
  561.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SORGENTI_DATI);
  562.         dati.add(de);
  563.        
  564.         de = new DataElement();
  565.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME);
  566.         de.setValue(nome);
  567.         de.setType(DataElementType.TEXT_EDIT);
  568.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  569.         de.setSize(getSize());
  570.         de.setRequired(true);
  571.         dati.add(de);

  572.         de = new DataElement();
  573.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME_JNDI);
  574.         de.setValue(nomeJndi);
  575.         de.setType(DataElementType.TEXT_EDIT);
  576.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_JNDI);
  577.         de.setSize(getSize());
  578.         de.setRequired(true);
  579.         dati.add(de);

  580.         de = new DataElement();
  581.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_DATABASE);
  582.         de.setType(DataElementType.SELECT);
  583.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_DATABASE);
  584.         de.setValues(tipoDbList);
  585.         if(tipoDatabase != null){
  586.             de.setSelected(tipoDatabase);
  587.         }
  588.         de.setRequired(true);
  589.         dati.add(de);

  590.         if(tipoOp .equals(TipoOperazione.CHANGE)){
  591.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  592.             de = new DataElement();
  593.             de.setType(DataElementType.LINK);
  594.             de.setUrl(
  595.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_DATASOURCE_PROPERTIES_LIST,
  596.                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, idSorgenteDati));
  597.             if (contaListe!=null && contaListe.booleanValue())
  598.                 ServletUtils.setDataElementVisualizzaLabel(de, (long) dimensioneSorgenteDati);
  599.             else
  600.                 ServletUtils.setDataElementVisualizzaLabel(de);
  601.             dati.add(de);
  602.         }

  603.         return dati;
  604.     }

  605.     // Prepara la lista di datasource del tracciamento
  606.     public void prepareTracciamentoDatasourceList(List<OpenspcoopSorgenteDati> lista)
  607.             throws Exception {
  608.         try {

  609.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_TRACCIAMENTO_DATASOURCE);

  610.             Boolean contaListe = ServletUtils.getConfigurazioniPersonalizzateFromSession(this.session);

  611.             //this.pd.setIndex(offset);
  612.             //this.pd.setPageSize(limit);
  613.             if (lista == null)
  614.                 this.pd.setNumEntries(0);
  615.             else
  616.                 this.pd.setNumEntries(lista.size());

  617.             this.pd.setSearchDescription("");
  618.             this.pd.setSearch("off");

  619.             // setto la barra del titolo
  620.             List<Parameter> lstParam = new ArrayList<>();

  621.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO,
  622.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI));
  623.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_SORGENTI_DATI_TRACCIAMENTO , null));

  624.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  625.             // setto le label delle colonne
  626.             String[] labels = {
  627.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME,
  628.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME_JNDI,
  629.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_DATABASE,
  630.                     ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA
  631.             };
  632.             this.pd.setLabels(labels);

  633.             // preparo i dati
  634.             List<List<DataElement>> dati = new ArrayList<>();

  635.             if (lista != null) {
  636.                 for (int i = 0; i < lista.size(); i++) {
  637.                     OpenspcoopSorgenteDati od = lista.get(i);

  638.                     List<DataElement> e = new ArrayList<>();

  639.                     Parameter pid = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, od.getId() + "");

  640.                     DataElement de = new DataElement();
  641.                     de.setUrl(
  642.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_DATASOURCE_CHANGE, pid);
  643.                     de.setValue(od.getNome());
  644.                     de.setIdToRemove(""+od.getId());
  645.                     e.add(de);

  646.                     de = new DataElement();
  647.                     de.setValue(od.getNomeJndi());
  648.                     e.add(de);

  649.                     de = new DataElement();
  650.                     de.setValue(od.getTipoDatabase());
  651.                     e.add(de);

  652.                     de = new DataElement();
  653.                     de.setUrl(
  654.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_DATASOURCE_PROPERTIES_LIST, pid);
  655.                     if (contaListe!=null && contaListe.booleanValue())
  656.                         ServletUtils.setDataElementVisualizzaLabel(de, (long) od.sizePropertyList());
  657.                     else
  658.                         ServletUtils.setDataElementVisualizzaLabel(de);

  659.                     e.add(de);

  660.                     dati.add(e);
  661.                 }
  662.             }

  663.             this.pd.setDati(dati);
  664.             this.pd.setAddButton(true);
  665.         } catch (Exception e) {
  666.             this.logError("Exception: " + e.getMessage(), e);
  667.             throw new DriverControlStationException(e);
  668.         }
  669.     }

  670.     // Controlla i dati del sorgente dati del tracciamento
  671.     public boolean tracciamentoDatasourceCheckData(TipoOperazione tipoOp)
  672.             throws Exception {
  673.         try {
  674.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  675.             String nomeJndi = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_JNDI);
  676.             String tipoDatabase = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_DATABASE);

  677.             if (nome == null || "".equals(nome)) {
  678.                 this.pd.setMessage("Il campo Nome deve essere specificato.");
  679.                 return false;
  680.             }
  681.             if (nomeJndi == null || "".equals(nomeJndi)) {
  682.                 this.pd.setMessage("Il campo Nome Jndi deve essere specificato.");
  683.                 return false;
  684.             }
  685.             if (tipoDatabase == null || "".equals(tipoDatabase)) {
  686.                 this.pd.setMessage("Il campo Tipo Database deve essere specificato.");
  687.                 return false;
  688.             }

  689.             // Se tipoOp = add, controllo che il sorgente dati non sia gia' stato registrato
  690.             if (tipoOp.equals(TipoOperazione.ADD)) {
  691.                 boolean trovatoDatasource = false;
  692.                 Configurazione newConfigurazione = this.core.getConfigurazioneGenerale();
  693.                 Tracciamento t = newConfigurazione.getTracciamento();
  694.                 if (t != null) {
  695.                     List<OpenspcoopSorgenteDati> lista = t.getOpenspcoopSorgenteDatiList();
  696.                     OpenspcoopSorgenteDati od = null;
  697.                     for (int j = 0; j < t.sizeOpenspcoopSorgenteDatiList(); j++) {
  698.                         od = lista.get(j);
  699.                         if (nome.equals(od.getNome())) {
  700.                             trovatoDatasource = true;
  701.                             break;
  702.                         }
  703.                     }
  704.                 }
  705.                 if (trovatoDatasource) {
  706.                     this.pd.setMessage("Esiste gi&agrave; un sorgente dati con nome " + nome);
  707.                     return false;
  708.                 }
  709.             }

  710.             return true;
  711.         } catch (Exception e) {
  712.             this.logError("Exception: " + e.getMessage(), e);
  713.             throw new DriverControlStationException(e);
  714.         }
  715.     }


  716.     // Prepara la lista di property di appender del tracciamento
  717.     public void prepareTracciamentoAppenderPropList(OpenspcoopAppender oa,
  718.             List<Property> lista)
  719.                     throws Exception {
  720.         try {
  721.             Parameter pOaId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, ""+oa.getId());
  722.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_TRACCIAMENTO_APPENDER_PROPERTIES,
  723.                     pOaId);        

  724.             //this.pd.setIndex(offset);
  725.             //this.pd.setPageSize(limit);
  726.             if (lista == null)
  727.                 this.pd.setNumEntries(0);
  728.             else
  729.                 this.pd.setNumEntries(lista.size());

  730.             this.pd.setSearchDescription("");
  731.             this.pd.setSearch("off");

  732.             // setto la barra del titolo
  733.             List<Parameter> lstParam = new ArrayList<>();

  734.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO,
  735.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI));
  736.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_APPENDER_TRACCIAMENTO ,
  737.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_APPENDER_LIST));
  738.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA+ " di " + oa.getTipo(), null));

  739.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  740.             // setto le label delle colonne
  741.             String[] labels = {
  742.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME,
  743.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_VALORE
  744.             };
  745.             this.pd.setLabels(labels);

  746.             // preparo i dati
  747.             List<List<DataElement>> dati = new ArrayList<>();

  748.             if (lista != null) {
  749.                 for (int i = 0; i < lista.size(); i++) {
  750.                     Property oap = lista.get(i);

  751.                     List<DataElement> e = new ArrayList<>();
  752.                     Parameter pOapId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID_PROPRIETA, oap.getId()  + "");
  753.                     DataElement de = new DataElement();
  754.                     de.setUrl(
  755.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_APPENDER_PROPERTIES_CHANGE, pOaId, pOapId
  756.                             );
  757.                     de.setValue(oap.getNome());
  758.                     de.setIdToRemove(""+oap.getId());
  759.                     e.add(de);

  760.                     de = new DataElement();
  761.                     de.setValue(oap.getValore());
  762.                     e.add(de);

  763.                     dati.add(e);
  764.                 }
  765.             }

  766.             this.pd.setDati(dati);
  767.             this.pd.setAddButton(true);
  768.         } catch (Exception e) {
  769.             this.logError("Exception: " + e.getMessage(), e);
  770.             throw new DriverControlStationException(e);
  771.         }
  772.     }

  773.     // Controlla i dati delle property dell'appender del tracciamento
  774.     public boolean tracciamentoAppenderPropCheckData(TipoOperazione tipoOp)
  775.             throws Exception {
  776.         try {
  777.             String id = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID);
  778.             int idInt = Integer.parseInt(id);
  779.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  780.             String valore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_VALORE);

  781.             if (nome == null || "".equals(nome)) {
  782.                 this.pd.setMessage("Il campo Nome deve essere specificato.");
  783.                 return false;
  784.             }
  785.             if (valore == null || "".equals(valore)) {
  786.                 this.pd.setMessage("Il campo Valore deve essere specificato.");
  787.                 return false;
  788.             }

  789.             // Se tipoOp = add, controllo che la property non sia gia' stata registrata
  790.             if (tipoOp.equals(TipoOperazione.ADD)) {
  791.                 boolean trovataProp = false;
  792.                 Configurazione newConfigurazione = this.core.getConfigurazioneGenerale();
  793.                 Tracciamento t = newConfigurazione.getTracciamento();
  794.                 OpenspcoopAppender oa = null;
  795.                 for (int j = 0; j < t.sizeOpenspcoopAppenderList(); j++) {
  796.                     oa = t.getOpenspcoopAppender(j);
  797.                     if (idInt == oa.getId().intValue()) {
  798.                         break;
  799.                     }
  800.                 }
  801.                
  802.                 if(oa==null) {
  803.                     throw new DriverControlStationException("Appender non trovato");
  804.                 }
  805.                
  806.                 Property oap = null;
  807.                 for (int i = 0; i < oa.sizePropertyList(); i++) {
  808.                     oap = oa.getProperty(i);
  809.                     if (nome.equals(oap.getNome())) {
  810.                         trovataProp = true;
  811.                         break;
  812.                     }
  813.                 }
  814.                 if (trovataProp) {
  815.                     this.pd.setMessage("Esiste gi&agrave; una Proprietà con nome " + nome);
  816.                     return false;
  817.                 }
  818.             }

  819.             return true;
  820.         } catch (Exception e) {
  821.             this.logError("Exception: " + e.getMessage(), e);
  822.             throw new DriverControlStationException(e);
  823.         }
  824.     }

  825.     // Prepara la lista di property di datasource del tracciamento
  826.     public void prepareTracciamentoDatasourcePropList(OpenspcoopSorgenteDati od,
  827.             List<Property> lista)
  828.                     throws Exception {
  829.         try {

  830.             Parameter pOdId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, ""+od.getId());
  831.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_TRACCIAMENTO_DATASOURCE_PROPERTIES,
  832.                     pOdId);

  833.             //this.pd.setIndex(offset);
  834.             //this.pd.setPageSize(limit);
  835.             if (lista == null)
  836.                 this.pd.setNumEntries(0);
  837.             else
  838.                 this.pd.setNumEntries(lista.size());

  839.             this.pd.setSearchDescription("");
  840.             this.pd.setSearch("off");

  841.             // setto la barra del titolo
  842.             List<Parameter> lstParam = new ArrayList<>();

  843.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO,
  844.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI));
  845.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_SORGENTI_DATI_TRACCIAMENTO ,
  846.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_DATASOURCE_LIST));
  847.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA+ " di " + od.getNome(), null));

  848.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  849.             // setto le label delle colonne
  850.             String[] labels = {
  851.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME,
  852.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_VALORE
  853.             };
  854.             this.pd.setLabels(labels);

  855.             // preparo i dati
  856.             List<List<DataElement>> dati = new ArrayList<>();

  857.             if (lista != null) {
  858.                 for (int i = 0; i < lista.size(); i++) {
  859.                     Property odp = lista.get(i);

  860.                     Parameter pOapId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID_PROPRIETA, odp.getId()  + "");

  861.                     List<DataElement> e = new ArrayList<>();

  862.                     DataElement de = new DataElement();
  863.                     de.setUrl(
  864.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_DATASOURCE_PROPERTIES_CHANGE, pOdId, pOapId
  865.                             );
  866.                     de.setValue(odp.getNome());
  867.                     de.setIdToRemove(""+odp.getId());
  868.                     e.add(de);

  869.                     de = new DataElement();
  870.                     de.setValue(odp.getValore());
  871.                     e.add(de);

  872.                     dati.add(e);
  873.                 }
  874.             }

  875.             this.pd.setDati(dati);
  876.             this.pd.setAddButton(true);
  877.         } catch (Exception e) {
  878.             this.logError("Exception: " + e.getMessage(), e);
  879.             throw new DriverControlStationException(e);
  880.         }
  881.     }

  882.     // Controlla i dati delle property del datasource del tracciamento
  883.     public boolean tracciamentoDatasourcePropCheckData(TipoOperazione tipoOp)
  884.             throws Exception {
  885.         try {
  886.             String id = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID);
  887.             int idInt = Integer.parseInt(id);
  888.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  889.             String valore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_VALORE);

  890.             if (nome == null || "".equals(nome)) {
  891.                 this.pd.setMessage("Il campo Nome deve essere specificato.");
  892.                 return false;
  893.             }
  894.             if (valore == null || "".equals(valore)) {
  895.                 this.pd.setMessage("Il campo Valore deve essere specificato.");
  896.                 return false;
  897.             }

  898.             // Se tipoOp = add, controllo che la property non sia gia' stata registrata
  899.             if (tipoOp.equals(TipoOperazione.ADD)) {
  900.                 boolean trovataProp = false;
  901.                 Configurazione newConfigurazione = this.core.getConfigurazioneGenerale();
  902.                 Tracciamento t = newConfigurazione.getTracciamento();
  903.                 List<OpenspcoopSorgenteDati> lista = t.getOpenspcoopSorgenteDatiList();
  904.                 OpenspcoopSorgenteDati od = null;
  905.                 for (int j = 0; j < t.sizeOpenspcoopSorgenteDatiList(); j++) {
  906.                     od = lista.get(j);
  907.                     if (idInt == od.getId().intValue()) {
  908.                         break;
  909.                     }
  910.                 }
  911.                
  912.                 if(od==null) {
  913.                     throw new DriverControlStationException("Datasource non trovato");
  914.                 }
  915.                
  916.                 List<Property> lista1 = od.getPropertyList();
  917.                 Property odp = null;
  918.                 for (int i = 0; i < od.sizePropertyList(); i++) {
  919.                     odp = lista1.get(i);
  920.                     if (nome.equals(odp.getNome())) {
  921.                         trovataProp = true;
  922.                         break;
  923.                     }
  924.                 }
  925.                 if (trovataProp) {
  926.                     this.pd.setMessage("Esiste gi&agrave; una Proprietà con nome " + nome);
  927.                     return false;
  928.                 }
  929.             }

  930.             return true;
  931.         } catch (Exception e) {
  932.             this.logError("Exception: " + e.getMessage(), e);
  933.             throw new DriverControlStationException(e);
  934.         }
  935.     }


  936.     // Prepara la lista di appender del tracciamento
  937.     public void prepareTracciamentoAppenderList(List<OpenspcoopAppender> lista)
  938.             throws Exception {
  939.         try {
  940.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_TRACCIAMENTO_APPENDER);
  941.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);

  942.             //this.pd.setIndex(offset);
  943.             //this.pd.setPageSize(limit);
  944.             if (lista == null)
  945.                 this.pd.setNumEntries(0);
  946.             else
  947.                 this.pd.setNumEntries(lista.size());

  948.             this.pd.setSearchDescription("");
  949.             this.pd.setSearch("off");

  950.             // setto la barra del titolo
  951.             List<Parameter> lstParam = new ArrayList<>();

  952.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO,
  953.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI));
  954.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_APPENDER_TRACCIAMENTO, null));

  955.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  956.             // setto le label delle colonne
  957.             String[] labels = {
  958.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO,
  959.                     ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA
  960.             };
  961.             this.pd.setLabels(labels);

  962.             // preparo i dati
  963.             List<List<DataElement>> dati = new ArrayList<>();

  964.             if (lista != null) {
  965.                 for (int i = 0; i < lista.size(); i++) {
  966.                     OpenspcoopAppender oa = lista.get(i);

  967.                     List<DataElement> e = new ArrayList<>();

  968.                     Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, oa.getId()  + "");
  969.                     DataElement de = new DataElement();
  970.                     de.setUrl(
  971.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_APPENDER_CHANGE, pId);
  972.                     de.setValue(oa.getTipo());
  973.                     de.setIdToRemove(""+oa.getId());
  974.                     e.add(de);

  975.                     de = new DataElement();
  976.                     de.setUrl(
  977.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_APPENDER_PROPERTIES_LIST ,pId);

  978.                     if (contaListe!=null && contaListe.booleanValue())
  979.                         ServletUtils.setDataElementVisualizzaLabel(de, (long)oa.sizePropertyList());
  980.                     else
  981.                         ServletUtils.setDataElementVisualizzaLabel(de);
  982.                     e.add(de);

  983.                     dati.add(e);
  984.                 }
  985.             }

  986.             this.pd.setDati(dati);
  987.             this.pd.setAddButton(true);
  988.         } catch (Exception e) {
  989.             this.logError("Exception: " + e.getMessage(), e);
  990.             throw new DriverControlStationException(e);
  991.         }
  992.     }

  993.     // Controlla i dati dell'appender del tracciamento
  994.     public boolean tracciamentoAppenderCheckData(TipoOperazione tipoOp)
  995.             throws Exception {
  996.         try {
  997.             String tipo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);

  998.             if (tipo == null || "".equals(tipo)) {
  999.                 this.pd.setMessage("Il campo Tipo deve essere specificato.");
  1000.                 return false;
  1001.             }

  1002.             // Se tipoOp = add, controllo che l'appender non sia gia' stato registrato
  1003.             if (tipoOp.equals(TipoOperazione.ADD)) {
  1004.                 boolean trovatoAppender = false;
  1005.                 Configurazione newConfigurazione = this.core.getConfigurazioneGenerale();
  1006.                 Tracciamento t = newConfigurazione.getTracciamento();
  1007.                 if (t != null) {
  1008.                     OpenspcoopAppender oa = null;
  1009.                     for (int j = 0; j < t.sizeOpenspcoopAppenderList(); j++) {
  1010.                         oa = t.getOpenspcoopAppender(j);
  1011.                         if (tipo.equals(oa.getTipo())) {
  1012.                             trovatoAppender = true;
  1013.                             break;
  1014.                         }
  1015.                     }
  1016.                 }
  1017.                 if (trovatoAppender) {
  1018.                     this.pd.setMessage("Esiste gi&agrave; un Appender con tipo " + tipo);
  1019.                     return false;
  1020.                 }
  1021.             }

  1022.             return true;
  1023.         } catch (Exception e) {
  1024.             this.logError("Exception: " + e.getMessage(), e);
  1025.             throw new DriverControlStationException(e);
  1026.         }
  1027.     }


  1028.     // Prepara la lista di appender del dump
  1029.     public void prepareDumpAppenderList(List<OpenspcoopAppender> lista)
  1030.             throws Exception {
  1031.         try {
  1032.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_DUMP_APPENDER);
  1033.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);

  1034.             //this.pd.setIndex(offset);
  1035.             //this.pd.setPageSize(limit);
  1036.             if (lista == null)
  1037.                 this.pd.setNumEntries(0);
  1038.             else
  1039.                 this.pd.setNumEntries(lista.size());

  1040.             this.pd.setSearchDescription("");
  1041.             this.pd.setSearch("off");

  1042.             // setto la barra del titolo
  1043.             List<Parameter> lstParam = new ArrayList<>();

  1044.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO,
  1045.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI));
  1046.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_APPENDER_DUMP, null));

  1047.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  1048.             // setto le label delle colonne
  1049.             String[] labels = {
  1050.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO,
  1051.                     ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA
  1052.             };
  1053.             this.pd.setLabels(labels);

  1054.             // preparo i dati
  1055.             List<List<DataElement>> dati = new ArrayList<>();

  1056.             if (lista != null) {
  1057.                 for (int i = 0; i < lista.size(); i++) {
  1058.                     OpenspcoopAppender oa = lista.get(i);

  1059.                     List<DataElement> e = new ArrayList<>();

  1060.                     Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, oa.getId()  + "");
  1061.                     DataElement de = new DataElement();
  1062.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DUMP_APPENDER_CHANGE, pId);
  1063.                     de.setValue(oa.getTipo());
  1064.                     de.setIdToRemove(""+oa.getId());
  1065.                     e.add(de);

  1066.                     de = new DataElement();
  1067.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DUMP_APPENDER_PROPERTIES_LIST ,pId);

  1068.                     if (contaListe!=null && contaListe.booleanValue())
  1069.                         ServletUtils.setDataElementVisualizzaLabel(de, (long)oa.sizePropertyList());
  1070.                     else
  1071.                         ServletUtils.setDataElementVisualizzaLabel(de);
  1072.                     e.add(de);

  1073.                     dati.add(e);
  1074.                 }
  1075.             }

  1076.             this.pd.setDati(dati);
  1077.             this.pd.setAddButton(true);
  1078.         } catch (Exception e) {
  1079.             this.logError("Exception: " + e.getMessage(), e);
  1080.             throw new DriverControlStationException(e);
  1081.         }
  1082.     }

  1083.     // Controlla i dati dell'appender del dump
  1084.     public boolean dumpAppenderCheckData(TipoOperazione tipoOp)
  1085.             throws Exception {
  1086.         try {
  1087.             String tipo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);

  1088.             if (tipo == null || "".equals(tipo)) {
  1089.                 this.pd.setMessage("Il campo Tipo deve essere specificato.");
  1090.                 return false;
  1091.             }

  1092.             // Se tipoOp = add, controllo che l'appender non sia gia' stato registrato
  1093.             if (tipoOp.equals(TipoOperazione.ADD)) {
  1094.                     boolean trovatoAppender = false;
  1095.                     Configurazione newConfigurazione = this.core.getConfigurazioneGenerale();
  1096.                     Dump dump = newConfigurazione.getDump();
  1097.                     if (dump != null) {
  1098.                         OpenspcoopAppender oa = null;
  1099.                         for (int j = 0; j < dump.sizeOpenspcoopAppenderList(); j++) {
  1100.                             oa = dump.getOpenspcoopAppender(j);
  1101.                             if (tipo.equals(oa.getTipo())) {
  1102.                                 trovatoAppender = true;
  1103.                                 break;
  1104.                             }
  1105.                         }
  1106.                     }
  1107.                     if (trovatoAppender) {
  1108.                         this.pd.setMessage("Esiste gi&agrave; un Appender con tipo " + tipo);
  1109.                         return false;
  1110.                     }
  1111.                 }

  1112.             return true;
  1113.         } catch (Exception e) {
  1114.             this.logError("Exception: " + e.getMessage(), e);
  1115.             throw new DriverControlStationException(e);
  1116.         }
  1117.     }

  1118.     public List<DataElement> addTipoDumpAppenderToDati(TipoOperazione tipoOp, String tipo, List<DataElement> dati,String idAppenderDati, int dimensioneAppenderDati) {
  1119.        
  1120.         DataElement de = new DataElement();
  1121.         de.setType(DataElementType.TITLE);
  1122.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_APPENDER);
  1123.         dati.add(de);
  1124.        
  1125.         de = new DataElement();
  1126.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO);
  1127.         de.setValue(tipo);
  1128.         de.setType(DataElementType.TEXT_EDIT);
  1129.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);
  1130.         de.setSize(getSize());
  1131.         de.setRequired(true);
  1132.         dati.add(de);

  1133.         if(tipoOp.equals(TipoOperazione.CHANGE)){
  1134.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  1135.             de = new DataElement();
  1136.             de.setType(DataElementType.LINK);
  1137.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DUMP_APPENDER_PROPERTIES_LIST, new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, idAppenderDati));
  1138.             if (contaListe!=null && contaListe.booleanValue())
  1139.                 ServletUtils.setDataElementVisualizzaLabel(de, (long) dimensioneAppenderDati);
  1140.             else
  1141.                 ServletUtils.setDataElementVisualizzaLabel(de);
  1142.             dati.add(de);
  1143.         }

  1144.         return dati;
  1145.     }
  1146.    
  1147.     // Prepara la lista di property di appender del dump
  1148.     public void prepareDumpAppenderPropList(OpenspcoopAppender oa,  List<Property> lista)
  1149.                     throws Exception {
  1150.         try {
  1151.             Parameter pOaId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, ""+oa.getId());
  1152.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_DUMP_APPENDER_PROPERTIES,
  1153.                     pOaId);        

  1154.             //this.pd.setIndex(offset);
  1155.             //this.pd.setPageSize(limit);
  1156.             if (lista == null)
  1157.                 this.pd.setNumEntries(0);
  1158.             else
  1159.                 this.pd.setNumEntries(lista.size());

  1160.             this.pd.setSearchDescription("");
  1161.             this.pd.setSearch("off");

  1162.             // setto la barra del titolo
  1163.             List<Parameter> lstParam = new ArrayList<>();

  1164.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO,
  1165.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI));
  1166.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_APPENDER_DUMP ,
  1167.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DUMP_APPENDER_LIST));
  1168.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA+ " di " + oa.getTipo(), null));

  1169.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  1170.             // setto le label delle colonne
  1171.             String[] labels = {
  1172.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME,
  1173.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_VALORE
  1174.             };
  1175.             this.pd.setLabels(labels);

  1176.             // preparo i dati
  1177.             List<List<DataElement>> dati = new ArrayList<>();

  1178.             if (lista != null) {
  1179.                 for (int i = 0; i < lista.size(); i++) {
  1180.                     Property oap = lista.get(i);

  1181.                     List<DataElement> e = new ArrayList<>();
  1182.                     Parameter pOapId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID_PROPRIETA, oap.getId()  + "");
  1183.                     DataElement de = new DataElement();
  1184.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DUMP_APPENDER_PROPERTIES_CHANGE, pOaId, pOapId );
  1185.                     de.setValue(oap.getNome());
  1186.                     de.setIdToRemove(""+oap.getId());
  1187.                     e.add(de);

  1188.                     de = new DataElement();
  1189.                     de.setValue(oap.getValore());
  1190.                     e.add(de);

  1191.                     dati.add(e);
  1192.                 }
  1193.             }

  1194.             this.pd.setDati(dati);
  1195.             this.pd.setAddButton(true);
  1196.         } catch (Exception e) {
  1197.             this.logError("Exception: " + e.getMessage(), e);
  1198.             throw new DriverControlStationException(e);
  1199.         }
  1200.     }

  1201.     // Controlla i dati delle property dell'appender del dump
  1202.     public boolean dumpAppenderPropCheckData(TipoOperazione tipoOp)
  1203.             throws Exception {
  1204.         try {
  1205.             String id = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID);
  1206.             int idInt = Integer.parseInt(id);
  1207.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  1208.             String valore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_VALORE);

  1209.             if (nome == null || "".equals(nome)) {
  1210.                 this.pd.setMessage("Il campo Nome deve essere specificato.");
  1211.                 return false;
  1212.             }
  1213.             if (valore == null || "".equals(valore)) {
  1214.                 this.pd.setMessage("Il campo Valore deve essere specificato.");
  1215.                 return false;
  1216.             }

  1217.             // Se tipoOp = add, controllo che la property non sia gia' stata registrata
  1218.             if (tipoOp.equals(TipoOperazione.ADD)) {
  1219.                 boolean trovataProp = false;
  1220.                 Configurazione newConfigurazione = this.core.getConfigurazioneGenerale();
  1221.                 Dump dump = newConfigurazione.getDump();
  1222.                 OpenspcoopAppender oa = null;
  1223.                 for (int j = 0; j < dump.sizeOpenspcoopAppenderList(); j++) {
  1224.                     oa = dump.getOpenspcoopAppender(j);
  1225.                     if (idInt == oa.getId().intValue()) {
  1226.                         break;
  1227.                     }
  1228.                 }
  1229.                
  1230.                 if(oa==null) {
  1231.                     throw new DriverControlStationException("Appender non trovato");
  1232.                 }
  1233.                
  1234.                 Property oap = null;
  1235.                 for (int i = 0; i < oa.sizePropertyList(); i++) {
  1236.                     oap = oa.getProperty(i);
  1237.                     if (nome.equals(oap.getNome())) {
  1238.                         trovataProp = true;
  1239.                         break;
  1240.                     }
  1241.                 }
  1242.                 if (trovataProp) {
  1243.                     this.pd.setMessage("Esiste gi&agrave; una Propriet&agrave; con nome " + nome);
  1244.                     return false;
  1245.                 }
  1246.             }

  1247.             return true;
  1248.         } catch (Exception e) {
  1249.             this.logError("Exception: " + e.getMessage(), e);
  1250.             throw new DriverControlStationException(e);
  1251.         }
  1252.     }

  1253.     // Controlla i dati del system properties
  1254.     public boolean systemPropertiesCheckData(TipoOperazione tipoOp) throws DriverControlStationException {
  1255.         try {
  1256.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  1257.             String valore = this.getLockedParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_VALORE, false);

  1258.             // Campi obbligatori
  1259.             if (nome.equals("") || valore.equals("")) {
  1260.                 String tmpElenco = "";
  1261.                 if (nome.equals("")) {
  1262.                     tmpElenco = "Nome";
  1263.                 }
  1264.                 if (valore.equals("")) {
  1265.                     if (tmpElenco.equals("")) {
  1266.                         tmpElenco = "Valore";
  1267.                     } else {
  1268.                         tmpElenco = tmpElenco + ", Valore";
  1269.                     }
  1270.                 }
  1271.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare: " + tmpElenco);
  1272.                 return false;
  1273.             }

  1274.             // Controllo che non ci siano spazi nei campi di testo
  1275.             if ((nome.indexOf(" ") != -1) ) {
  1276.                 this.pd.setMessage("Non inserire spazi nei nomi");
  1277.                 return false;
  1278.             }
  1279.             if(!this.checkLength255(nome, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME)) {
  1280.                 return false;
  1281.             }
  1282.            
  1283.             if( !this.core.getDriverBYOKUtilities().isEnabledBYOK() || !this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(valore) ){
  1284.                 if(valore.startsWith(" ") || valore.endsWith(" ")){
  1285.                     this.pd.setMessage("Non inserire spazi all'inizio o alla fine dei valori");
  1286.                     return false;
  1287.                 }
  1288.                 if(!this.checkLength255(valore, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_VALORE)) {
  1289.                     return false;
  1290.                 }
  1291.             }

  1292.             // Se tipoOp = add, controllo che non sia gia' stato
  1293.             // registrato per la porta delegata
  1294.             if (tipoOp.equals(TipoOperazione.ADD)) {
  1295.                 boolean giaRegistrato = false;
  1296.                 SystemProperties sps = this.confCore.getSystemPropertiesPdD();
  1297.                 if(sps!=null){
  1298.                     for (int i = 0; i < sps.sizeSystemPropertyList(); i++) {
  1299.                         Property tmpSP = sps.getSystemProperty(i);
  1300.                         if (nome.equals(tmpSP.getNome())) {
  1301.                             giaRegistrato = true;
  1302.                             break;
  1303.                         }
  1304.                     }
  1305.                 }

  1306.                 if (giaRegistrato) {
  1307.                     this.pd.setMessage("La proprietà di sistema " + nome + " &egrave; gi&agrave; stata registrata");
  1308.                     return false;
  1309.                 }
  1310.             }

  1311.             return true;

  1312.         } catch (Exception e) {
  1313.             this.logError("Exception: " + e.getMessage(), e);
  1314.             throw new DriverControlStationException(e);
  1315.         }
  1316.     }

  1317.     public void prepareSystemPropertiesList(ISearch ricerca, List<Property> lista)
  1318.             throws Exception {
  1319.         try {

  1320.             String id = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID);
  1321.             Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, id);
  1322.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_SYSTEM_PROPERTIES, pId);

  1323.             int idLista = Liste.SYSTEM_PROPERTIES;
  1324.             int limit = ricerca.getPageSize(idLista);
  1325.             int offset = ricerca.getIndexIniziale(idLista);
  1326.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  1327.             this.pd.setIndex(offset);
  1328.             this.pd.setPageSize(limit);
  1329.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  1330.             // setto la barra del titolo
  1331.             List<Parameter> lstParam = new ArrayList<>();

  1332.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  1333.             if (search.equals("")) {
  1334.                 this.pd.setSearchDescription("");
  1335.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA_SISTEMA,   null));

  1336.             } else{
  1337.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA_SISTEMA,
  1338.                         ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SYSTEM_PROPERTIES_LIST));
  1339.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  1340.             }
  1341.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  1342.             // controllo eventuali risultati ricerca
  1343.             if (!search.equals("")) {
  1344.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA_SISTEMA, search);
  1345.             }

  1346.             // setto le label delle colonne
  1347.             String[] labels = {
  1348.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME,
  1349.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_VALORE
  1350.             };
  1351.             this.pd.setLabels(labels);

  1352.             // preparo i dati
  1353.             List<List<DataElement>> dati = new ArrayList<>();

  1354.             if (lista != null) {
  1355.                 Iterator<Property> it = lista.iterator();
  1356.                 while (it.hasNext()) {
  1357.                     Property sp = it.next();

  1358.                     List<DataElement> e = new ArrayList<>();

  1359.                     Parameter pIdProp = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, ""+sp.getId());

  1360.                     DataElement de = new DataElement();
  1361.                     de.setUrl(
  1362.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SYSTEM_PROPERTIES_CHANGE, pIdProp);
  1363.                     de.setValue(sp.getNome());
  1364.                     de.setIdToRemove(sp.getNome());
  1365.                     de.setSize(CostantiControlStation.NOME_PROPRIETA_VISUALIZZATA);
  1366.                     e.add(de);

  1367.                     de = new DataElement();
  1368.                     if(sp.getValore()!=null && StringUtils.isNotEmpty(sp.getValore()) &&
  1369.                             BYOKManager.isEnabledBYOK() &&
  1370.                             this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(sp.getValore())) {
  1371.                         de.setValue(CostantiControlStation.VALORE_CIFRATO);
  1372.                     }
  1373.                     else {
  1374.                         de.setValue(sp.getValore());
  1375.                     }
  1376.                     e.add(de);

  1377.                     dati.add(e);
  1378.                 }
  1379.             }

  1380.             this.pd.setDati(dati);
  1381.             this.pd.setAddButton(true);

  1382.         } catch (Exception e) {
  1383.             this.logError("Exception: " + e.getMessage(), e);
  1384.             throw new DriverControlStationException(e);
  1385.         }
  1386.     }

  1387.     public void refreshSystemProperties() {
  1388.         // reimposto proprietà
  1389.         List<String> aliases = this.confCore.getJmxPdDAliases();
  1390.         boolean resetOk = false;
  1391.         if(aliases!=null && !aliases.isEmpty()){
  1392.             resetOk = true;
  1393.             for (String alias : aliases) {
  1394.                 String stato = null;
  1395.                 try{
  1396.                     stato = this.confCore.getInvoker().invokeJMXMethod(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  1397.                             this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaSystemPropertiesPdD(alias),
  1398.                             this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoRefreshPersistentConfiguration(alias));
  1399.                     if(this.isErroreHttp(stato, "refresh System Properties")){
  1400.                         // e' un errore
  1401.                         throw new DriverControlStationException(stato);
  1402.                     }
  1403.                 }catch(Exception e){
  1404.                     ControlStationCore.getLog().error("Errore durante il refresh via jmx delle system properties (alias: "+alias+"): "+e.getMessage(),e);
  1405.                     resetOk = false;
  1406.                 }
  1407.             }
  1408.         }
  1409.        
  1410.         if(!resetOk) {
  1411.             this.pd.setMessage(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA_SISTEMA_MODIFICATA_CON_SUCCESSO, Costanti.MESSAGE_TYPE_INFO);
  1412.         }
  1413.     }
  1414.    
  1415.     // Controlla i dati del pannello Configurazione -> Tabella di routing
  1416.     public boolean routingCheckData(String[] registriList) throws Exception {

  1417.         try{

  1418.             String rottaenabled = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ROTTA_ENABLED);
  1419.             String tiporotta = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA);
  1420.             if (tiporotta == null) {
  1421.                 tiporotta = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY;
  1422.             }
  1423.             String tiposoggrotta = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_SOGGETTO_ROTTA);
  1424.             if (tiposoggrotta == null) {
  1425.                 tiposoggrotta = "";
  1426.             }
  1427.             String nomesoggrotta = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_SOGGETTO_ROTTA);
  1428.             if (nomesoggrotta == null) {
  1429.                 nomesoggrotta = "";
  1430.             }
  1431.             String registrorotta = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRO_ROTTA);
  1432.             if (registrorotta == null) {
  1433.                 registrorotta = "";
  1434.             }

  1435.             // Controllo che i campi "select" abbiano uno dei valori ammessi
  1436.             if (!tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY) &&
  1437.                     !tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_REGISTRO)) {
  1438.                 this.pd.setMessage("Tipo Rotta dev'essere gateway o registro");
  1439.                 return false;
  1440.             }

  1441.             // Campi obbligatori
  1442.             if (rottaenabled.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  1443.                     tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY) && ( (tiposoggrotta.equals("") || tiposoggrotta.equals("-")) || nomesoggrotta.equals(""))) {
  1444.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare Tipo e Nome Soggetto");
  1445.                 return false;
  1446.             }

  1447.             // Controllo che non ci siano spazi nei campi di testo
  1448.             if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY) && ((tiposoggrotta.indexOf(" ") != -1) || (nomesoggrotta.indexOf(" ") != -1))) {
  1449.                 this.pd.setMessage("Non inserire spazi nei campi di testo");
  1450.                 return false;
  1451.             }

  1452.             // Controllo che il registrorotta appartenga alla lista di registri
  1453.             // disponibili
  1454.             if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_REGISTRO)) {
  1455.                 boolean trovatoReg = false;
  1456.                 for (int i = 0; i < registriList.length; i++) {
  1457.                     String tmpReg = registriList[i];
  1458.                     if (tmpReg.equals(registrorotta)) {
  1459.                         trovatoReg = true;
  1460.                     }
  1461.                 }
  1462.                 if (!trovatoReg) {
  1463.                     this.pd.setMessage("Il registro dev'essere 'all' oppure dev'essere scelto tra quelli definiti nel pannello Registri");
  1464.                     return false;
  1465.                 }
  1466.             }

  1467.             return true;

  1468.         } catch (Exception e) {
  1469.             this.logError("Exception: " + e.getMessage(), e);
  1470.             throw new DriverControlStationException(e);
  1471.         }
  1472.     }

  1473.     // Controlla i dati delle rotte statiche
  1474.     public boolean routingListCheckData(TipoOperazione tipoOp, String[] registriList)
  1475.             throws Exception {

  1476.         try{

  1477.             // String id = this.getParameter("id");
  1478.             // int idInt = 0;
  1479.             // if (tipoOp.equals("change"))
  1480.             // idInt = Integer.parseInt(id);
  1481.             String tipo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);
  1482.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  1483.             String tiporotta = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA);
  1484.             String tiposoggrotta = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_SOGGETTO_ROTTA);
  1485.             String nomesoggrotta = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_SOGGETTO_ROTTA);
  1486.             String registrorotta = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRO_ROTTA);

  1487.             // Controllo che i campi "select" abbiano uno dei valori ammessi
  1488.             if (!tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY) && !tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_REGISTRO)) {
  1489.                 this.pd.setMessage("Tipo Rotta dev'essere gateway o registro");
  1490.                 return false;
  1491.             }

  1492.             // Campi obbligatori
  1493.             if (tipo.equals("") || nome.equals("")) {
  1494.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare Tipo e Nome");
  1495.                 return false;
  1496.             }
  1497.             if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY) && (tiposoggrotta.equals("") || nomesoggrotta.equals(""))) {
  1498.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare Tipo e Nome Soggetto");
  1499.                 return false;
  1500.             }

  1501.             // Controllo che non ci siano spazi nei campi di testo
  1502.             if ((tipo.indexOf(" ") != -1) || (nome.indexOf(" ") != -1)) {
  1503.                 this.pd.setMessage("Non inserire spazi nei campi di testo");
  1504.                 return false;
  1505.             }
  1506.             if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY) && ((tiposoggrotta.indexOf(" ") != -1) || (nomesoggrotta.indexOf(" ") != -1))) {
  1507.                 this.pd.setMessage("Non inserire spazi nei campi di testo");
  1508.                 return false;
  1509.             }

  1510.             // Controllo che il registrorotta appartenga alla lista di registri
  1511.             // disponibili
  1512.             if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_REGISTRO)) {
  1513.                 boolean trovatoReg = false;
  1514.                 for (int i = 0; i < registriList.length; i++) {
  1515.                     String tmpReg = registriList[i];
  1516.                     if (tmpReg.equals(registrorotta)) {
  1517.                         trovatoReg = true;
  1518.                     }
  1519.                 }
  1520.                 if (!trovatoReg) {
  1521.                     this.pd.setMessage("Il registro dev'essere 'all' oppure dev'essere scelto tra quelli definiti nel pannello Registri");
  1522.                     return false;
  1523.                 }
  1524.             }

  1525.             // Se tipoOp = add, controllo che il routing non sia gia' stato
  1526.             // registrato
  1527.             if (tipoOp.equals(TipoOperazione.ADD)) {
  1528.                 boolean giaRegistrato = false;

  1529.                 RoutingTable rt = this.confCore.getRoutingTable();
  1530.                 for (int i = 0; i < rt.sizeDestinazioneList(); i++) {
  1531.                     RoutingTableDestinazione rtd = rt.getDestinazione(i);
  1532.                     if (nome.equals(rtd.getNome()) && tipo.equals(rtd.getTipo())) {
  1533.                         giaRegistrato = true;
  1534.                         break;
  1535.                     }
  1536.                 }

  1537.                 if (giaRegistrato) {
  1538.                     this.pd.setMessage("La destinazione " + tipo + "/" + nome + " &egrave; gi&agrave; stata registrata");
  1539.                     return false;
  1540.                 }
  1541.             }

  1542.             return true;

  1543.         } catch (Exception e) {
  1544.             this.logError("Exception: " + e.getMessage(), e);
  1545.             throw new DriverControlStationException(e);
  1546.         }
  1547.     }

  1548.     // Prepara la lista di rotte statiche
  1549.     public void prepareRoutingList(ISearch ricerca, List<RoutingTableDestinazione> lista)
  1550.             throws Exception {
  1551.         try {
  1552.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_ROTTE_ROUTING);

  1553.             int idLista = Liste.ROUTING;
  1554.             int limit = ricerca.getPageSize(idLista);
  1555.             int offset = ricerca.getIndexIniziale(idLista);
  1556.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  1557.             this.pd.setIndex(offset);
  1558.             this.pd.setPageSize(limit);
  1559.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  1560.             // setto la barra del titolo
  1561.             List<Parameter> lstParam = new ArrayList<>();

  1562.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  1563.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TABELLA_DI_ROUTING,
  1564.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ROUTING));
  1565.             if(search.equals("")){
  1566.                 this.pd.setSearchDescription("");
  1567.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DESTINAZIONI,
  1568.                         null));
  1569.             }else{
  1570.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DESTINAZIONI,
  1571.                         ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ROTTE_ROUTING_LIST));
  1572.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  1573.             }

  1574.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  1575.             // controllo eventuali risultati ricerca
  1576.             if (!search.equals("")) {
  1577.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DESTINAZIONI, search);
  1578.             }

  1579.             // setto le label delle colonne
  1580.             String[] labels = {
  1581.                     ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DESTINATARIO,
  1582.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA
  1583.             };
  1584.             this.pd.setLabels(labels);

  1585.             // preparo i dati
  1586.             List<List<DataElement>> dati = new ArrayList<>();

  1587.             if (lista != null) {
  1588.                 Iterator<RoutingTableDestinazione> it = lista.iterator();
  1589.                 while (it.hasNext()) {
  1590.                     RoutingTableDestinazione rtd = it.next();

  1591.                     List<DataElement> e = new ArrayList<>();

  1592.                     DataElement de = new DataElement();
  1593.                     Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, rtd.getId() + "");
  1594.                     de.setUrl(
  1595.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ROTTE_ROUTING_CHANGE, pId);
  1596.                     de.setValue(rtd.getTipo()+"/"+rtd.getNome());
  1597.                     e.add(de);

  1598.                     Route r = rtd.getRoute(0);
  1599.                     de = new DataElement();
  1600.                     if (r.getGateway() != null) {
  1601.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY);
  1602.                     } else {
  1603.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_REGISTRO);
  1604.                     }
  1605.                     e.add(de);

  1606.                     dati.add(e);
  1607.                 }
  1608.             }

  1609.             this.pd.setDati(dati);
  1610.             this.pd.setAddButton(true);
  1611.         } catch (Exception e) {
  1612.             this.logError("Exception: " + e.getMessage(), e);
  1613.             throw new DriverControlStationException(e);
  1614.         }
  1615.     }

  1616.    
  1617.     // Controlla i dati del pannello Configurazione -> Registro
  1618.     public boolean registroCheckData() throws Exception {

  1619.         try{

  1620.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_REGISTRY);
  1621.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_REGISTRY);
  1622.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_REGISTRY);
  1623.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_REGISTRY);
  1624.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_REGISTRY);

  1625.             return checkDatiCache(CostantiPdD.JMX_REGISTRO_SERVIZI, statocache, dimensionecache, algoritmocache, idlecache, lifecache);

  1626.         } catch (Exception e) {
  1627.             this.logError("Exception: " + e.getMessage(), e);
  1628.             throw new DriverControlStationException(e);
  1629.         }
  1630.     }
  1631.    
  1632.     public boolean checkDatiCache(String nomeCache, String statocache, String dimensionecache, String algoritmocache, String idlecache, String lifecache) throws Exception {

  1633.         try{

  1634.             // Campi obbligatori
  1635.             if (statocache.equals("")) {
  1636.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare lo Stato in "+nomeCache);
  1637.                 return false;
  1638.             }

  1639.             // Controllo che non ci siano spazi nei campi di testo
  1640.             if (statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) && ((dimensionecache.indexOf(" ") != -1) || (idlecache.indexOf(" ") != -1) || (lifecache.indexOf(" ") != -1))) {
  1641.                 this.pd.setMessage("Non inserire spazi nei campi di testo");
  1642.                 return false;
  1643.             }

  1644.             // Controllo che i campi "select" abbiano uno dei valori ammessi
  1645.             if (!statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) && !statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  1646.                 this.pd.setMessage("Stato Cache "+nomeCache+" dev'essere abilitato o disabilitato");
  1647.                 return false;
  1648.             }
  1649.             if (statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  1650.                     !algoritmocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_LRU) &&
  1651.                     !algoritmocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_MRU)) {
  1652.                 this.pd.setMessage("Algoritmo della Cache "+nomeCache+" dev'essere LRU o MRU");
  1653.                 return false;
  1654.             }

  1655.             // dimensionecache, idlecache e lifecache devono essere numerici
  1656.             if (statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) && (dimensionecache==null || dimensionecache.equals("")) ) {
  1657.                 this.pd.setMessage("Deve essere indicato un valore per la Dimensione della Cache "+nomeCache);
  1658.                 return false;
  1659.             }
  1660.             if (statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) && !dimensionecache.equals("") &&
  1661.                     !this.checkNumber(dimensionecache, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE+ "("+nomeCache+")", false)) {
  1662.                 return false;
  1663.             }
  1664.            
  1665.             if (statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) && !idlecache.equals("") &&
  1666.                     !this.checkNumber(idlecache, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_IDLE_CACHE+ "("+nomeCache+")", false)) {
  1667.                 return false;
  1668.             }
  1669.            
  1670. //          if (statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) && (lifecache==null || lifecache.equals("")) ) {
  1671. //              this.pd.setMessage("Deve essere indicato un valore per l'impostazione 'Life second' della Cache "+nomeCache);
  1672. //              return false;
  1673. //          }
  1674.             if (statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) && lifecache!=null && !lifecache.equals("") &&
  1675.                     !this.checkNumber(lifecache, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIFE_CACHE+ "("+nomeCache+")", false)) {
  1676.                 return false;
  1677.             }

  1678.             return true;

  1679.         } catch (Exception e) {
  1680.             this.logError("Exception: " + e.getMessage(), e);
  1681.             throw new DriverControlStationException(e);
  1682.         }
  1683.     }

  1684.     // Controlla i dati del registro
  1685.     public boolean registriCheckData(TipoOperazione tipoOp) throws Exception {

  1686.         try{

  1687.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  1688.             String location = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LOCATION);
  1689.             String tipo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);
  1690.             String utente = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_UTENTE);
  1691.             String password = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PW);
  1692.             String confpw = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONFERMA_PW);

  1693.             // Campi obbligatori
  1694.             if (nome.equals("") || location.equals("") || tipo.equals("")) {
  1695.                 String tmpElenco = "";
  1696.                 if (nome.equals("")) {
  1697.                     tmpElenco = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME;
  1698.                 }
  1699.                 if (location.equals("")) {
  1700.                     if (tmpElenco.equals("")) {
  1701.                         tmpElenco =  ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOCATION;
  1702.                     } else {
  1703.                         tmpElenco = tmpElenco + ", "+ ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOCATION;
  1704.                     }
  1705.                 }
  1706.                 if (tipo.equals("")) {
  1707.                     if (tmpElenco.equals("")) {
  1708.                         tmpElenco = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO;
  1709.                     } else {
  1710.                         tmpElenco = tmpElenco + ", "+ ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO;
  1711.                     }
  1712.                 }
  1713.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare: " + tmpElenco);
  1714.                 return false;
  1715.             }

  1716.             // Controllo che non ci siano spazi nei campi di testo
  1717.             if ((nome.indexOf(" ") != -1) || (location.indexOf(" ") != -1)) {
  1718.                 this.pd.setMessage("Non inserire spazi nei campi di testo");
  1719.                 return false;
  1720.             }
  1721.             if (tipo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_UDDI) &&
  1722.                     ((utente.indexOf(" ") != -1) || (password.indexOf(" ") != -1) || (confpw.indexOf(" ") != -1))) {
  1723.                 this.pd.setMessage("Non inserire spazi nei campi di testo");
  1724.                 return false;
  1725.             }

  1726.             // length
  1727.             if(this.checkLength255(nome, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME)==false) {
  1728.                 return false;
  1729.             }
  1730.             if(this.checkLength255(location, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOCATION)==false) {
  1731.                 return false;
  1732.             }
  1733.             if(utente!=null && !"".equals(utente)) {
  1734.                 if(this.checkLength255(utente, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_UTENTE)==false) {
  1735.                     return false;
  1736.                 }
  1737.             }
  1738.             if(password!=null && !"".equals(password)) {
  1739.                 if(this.checkLength255(password, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PW)==false) {
  1740.                     return false;
  1741.                 }
  1742.             }
  1743.            
  1744.             // Controllo che i campi "select" abbiano uno dei valori ammessi
  1745.             if (!tipo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_XML) &&
  1746.                     !tipo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_DB) &&
  1747.                     !tipo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_UDDI) &&
  1748.                     !tipo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_WEB) &&
  1749.                     !tipo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_WS)) {
  1750.                 this.pd.setMessage("Tipo dev'essere xml, db, uddi, web o ws");
  1751.                 return false;
  1752.             }

  1753.             // Controllo che le password corrispondano
  1754.             if (tipo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_UDDI) && !password.equals(confpw)) {
  1755.                 this.pd.setMessage("Le password non corrispondono");
  1756.                 return false;
  1757.             }

  1758.             // Se tipoOp = add, controllo che il registro non sia gia' stato
  1759.             // registrata
  1760.             if (tipoOp.equals(TipoOperazione.ADD)) {
  1761.                 boolean giaRegistrato = false;

  1762.                 AccessoRegistro ar = this.confCore.getAccessoRegistro();
  1763.                 for (int i = 0; i < ar.sizeRegistroList(); i++) {
  1764.                     AccessoRegistroRegistro arr = ar.getRegistro(i);
  1765.                     if (nome.equals(arr.getNome())) {
  1766.                         giaRegistrato = true;
  1767.                         break;
  1768.                     }
  1769.                 }

  1770.                 if (giaRegistrato) {
  1771.                     this.pd.setMessage("Il registro " + nome + " &egrave; gi&agrave; stato registrato");
  1772.                     return false;
  1773.                 }
  1774.             }

  1775.             return true;

  1776.         } catch (Exception e) {
  1777.             this.logError("Exception: " + e.getMessage(), e);
  1778.             throw new DriverControlStationException(e);
  1779.         }
  1780.     }
  1781.    

  1782.     // Prepara la lista di registri
  1783.     public void prepareRegistriList(ISearch ricerca, List<AccessoRegistroRegistro> lista)
  1784.             throws Exception {
  1785.         try {
  1786.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_REGISTRI);

  1787.             int idLista = Liste.REGISTRI;
  1788.             int limit = ricerca.getPageSize(idLista);
  1789.             int offset = ricerca.getIndexIniziale(idLista);
  1790.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  1791.             this.pd.setIndex(offset);
  1792.             this.pd.setPageSize(limit);
  1793.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  1794.             // setto la barra del titolo
  1795.             List<Parameter> lstParam = new ArrayList<>();

  1796.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  1797.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO,
  1798.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ACCESSO_REGISTRO_SERVIZI));
  1799.             if(search.equals("")){
  1800.                 this.pd.setSearchDescription("");
  1801.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_REGISTRI,
  1802.                         null));
  1803.             }else{
  1804.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_REGISTRI,
  1805.                         ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_REGISTRI_LIST));
  1806.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  1807.             }

  1808.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  1809.             // controllo eventuali risultati ricerca
  1810.             if (!search.equals("")) {
  1811.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRI, search);
  1812.             }

  1813.             // setto le label delle colonne
  1814.             String[] labels = {
  1815.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME,
  1816.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO
  1817.             };
  1818.             this.pd.setLabels(labels);

  1819.             // preparo i dati
  1820.             List<List<DataElement>> dati = new ArrayList<>();

  1821.             if (lista != null) {
  1822.                 Iterator<AccessoRegistroRegistro> it = lista.iterator();
  1823.                 while (it.hasNext()) {
  1824.                     AccessoRegistroRegistro arr = it.next();

  1825.                     List<DataElement> e = new ArrayList<>();

  1826.                     DataElement de = new DataElement();
  1827.                     Parameter pNome = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME, arr.getNome());
  1828.                     de.setUrl(
  1829.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_REGISTRI_CHANGE , pNome);
  1830.                     de.setValue(arr.getNome());
  1831.                     de.setIdToRemove(arr.getNome());
  1832.                     e.add(de);

  1833.                     de = new DataElement();
  1834.                     de.setValue(arr.getTipo().toString());
  1835.                     e.add(de);

  1836.                     dati.add(e);
  1837.                 }
  1838.             }

  1839.             this.pd.setDati(dati);
  1840.             this.pd.setAddButton(true);
  1841.         } catch (Exception e) {
  1842.             this.logError("Exception: " + e.getMessage(), e);
  1843.             throw new DriverControlStationException(e);
  1844.         }
  1845.     }
  1846.    
  1847.     // Prepara la lista delle regole di configurazione del caching risposta
  1848.     public void prepareResponseCachingConfigurazioneRegolaList(ISearch ricerca, List<ResponseCachingConfigurazioneRegola> lista, Integer defaultCacheSeconds) throws Exception {
  1849.         try {
  1850.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA);

  1851.             int idLista = Liste.CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA;
  1852.             int limit = ricerca.getPageSize(idLista);
  1853.             int offset = ricerca.getIndexIniziale(idLista);

  1854.             this.pd.setIndex(offset);
  1855.             this.pd.setPageSize(limit);
  1856.             this.pd.setSearch("");
  1857.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  1858.             this.pd.setSearchDescription("");
  1859.            
  1860.             ServletUtils.disabledPageDataSearch(this.pd);

  1861.             // setto la barra del titolo
  1862.             List<Parameter> lstParam = new ArrayList<>();

  1863.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  1864.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLE, null));

  1865.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  1866.             // setto le label delle colonne
  1867.             String[] labels = {
  1868.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE,
  1869.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_FAULT,
  1870.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_CACHE_TIMEOUT_SECONDS
  1871.             };
  1872.             this.pd.setLabels(labels);

  1873.             // preparo i dati
  1874.             List<List<DataElement>> dati = new ArrayList<>();

  1875.             if (lista != null) {
  1876.                 Iterator<ResponseCachingConfigurazioneRegola> it = lista.iterator();
  1877.                 while (it.hasNext()) {
  1878.                     ResponseCachingConfigurazioneRegola regola = it.next();

  1879.                     List<DataElement> e = new ArrayList<>();

  1880.                     DataElement de = new DataElement();
  1881.                     de.setIdToRemove(regola.getId() + "");
  1882.                    
  1883.                     Integer statusMin = regola.getReturnCodeMin();
  1884.                     Integer statusMax = regola.getReturnCodeMax();
  1885.                    
  1886.                     // se e' stato salvato il valore 0 lo tratto come null
  1887.                     if(statusMin != null && statusMin.intValue() <= 0) {
  1888.                         statusMin = null;
  1889.                     }
  1890.                    
  1891.                     if(statusMax != null && statusMax.intValue() <= 0) {
  1892.                         statusMax = null;
  1893.                     }
  1894.                    
  1895.                     String statusValue = null;
  1896.                     // Intervallo
  1897.                     if(statusMin != null && statusMax != null) {
  1898.                         if(statusMax.longValue() == statusMin.longValue()) // esatto
  1899.                             statusValue = statusMin + "";
  1900.                         else
  1901.                             statusValue = "[" + statusMin + " - " + statusMax + "]";
  1902.                     } else if(statusMin != null && statusMax == null) { // definito solo l'estremo inferiore
  1903.                         statusValue = "&gt;" + statusMin;
  1904.                     } else if(statusMin == null && statusMax != null) { // definito solo l'estremo superiore
  1905.                         statusValue = "&lt;" + statusMax;
  1906.                     } else { //entrambi null
  1907.                         statusValue = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_QUALSIASI;
  1908.                     }
  1909.                    
  1910.                     de.setValue(statusValue);
  1911.                     e.add(de);
  1912.                    
  1913.                     de = new DataElement();
  1914.                     de.setValue(regola.getFault() ? CostantiControlStation.LABEL_SI : CostantiControlStation.LABEL_NO);
  1915.                     e.add(de);
  1916.                    
  1917.                     de = new DataElement();
  1918.                     de.setValue(regola.getCacheTimeoutSeconds() != null ? regola.getCacheTimeoutSeconds() + "" : "default ("+defaultCacheSeconds+")");
  1919.                     e.add(de);

  1920.                     dati.add(e);
  1921.                 }
  1922.             }

  1923.             this.pd.setDati(dati);
  1924.             this.pd.setAddButton(true);
  1925.         } catch (Exception e) {
  1926.             this.logError("Exception: " + e.getMessage(), e);
  1927.             throw new DriverControlStationException(e);
  1928.         }
  1929.     }
  1930.    
  1931.     // Controlla i dati del registro
  1932.     public boolean responseCachingConfigurazioneRegolaCheckData(TipoOperazione tipoOp) throws Exception {

  1933.         try{
  1934.            
  1935.             if(this.checkRegolaResponseCaching() == false) {
  1936.                 return false;
  1937.             }
  1938.            
  1939.             String returnCode = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE);
  1940.             String statusMinS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MIN);
  1941.             String statusMaxS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MAX);
  1942.             String faultS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_FAULT);
  1943.            
  1944.             Integer statusMin = null;
  1945.             Integer statusMax = null;
  1946.             boolean fault = ServletUtils.isCheckBoxEnabled(faultS);
  1947.            
  1948.             if(!returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_QUALSIASI)) {

  1949.                 if(StringUtils.isNotEmpty(statusMinS)) {
  1950.                     statusMin = Integer.parseInt(statusMinS);
  1951.                 }
  1952.                
  1953.                 if(returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_INTERVALLO)) {
  1954.                     if(StringUtils.isNotEmpty(statusMaxS)) {
  1955.                         statusMax = Integer.parseInt(statusMaxS);
  1956.                     }
  1957.                 }
  1958.                
  1959.                 // return code esatto, ho salvato lo stesso valore nel campo return code;
  1960.                 if(returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_ESATTO))
  1961.                     statusMax = statusMin;
  1962.             }
  1963.            
  1964.             // Se tipoOp = add, controllo che il registro non sia gia' stato
  1965.             // registrata
  1966.             if (tipoOp.equals(TipoOperazione.ADD)) {
  1967.                 boolean giaRegistrato = this.confCore.existsResponseCachingConfigurazioneRegola(statusMin, statusMax, fault);

  1968.                 if (giaRegistrato) {
  1969.                     this.pd.setMessage("&Egrave; gi&agrave; presente una Regola di Response Caching con in parametri indicati.");
  1970.                     return false;
  1971.                 }
  1972.             }

  1973.             return true;

  1974.         } catch (Exception e) {
  1975.             this.logError("Exception: " + e.getMessage(), e);
  1976.             throw new DriverControlStationException(e);
  1977.         }
  1978.     }

  1979.     // Controlla i dati del pannello Configurazione -> Generale
  1980.     public boolean configurazioneCheckData() throws Exception {

  1981.         try{

  1982.             String inoltromin = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_INOLTRO_MIN);
  1983.             String stato = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO);
  1984.             String controllo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO);
  1985.             //String severita = this.getParameter("severita");
  1986.             //String severita_log4j = this.getParameter("severita_log4j");
  1987.             String integman = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_INTEGMAN);
  1988.             String nomeintegman = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_INTEGMAN);
  1989.             String profcoll = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROFILO_COLLABORAZIONE);
  1990.             String connessione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONNESSIONE);
  1991.             String utilizzo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_UTILIZZO);
  1992.             String validman = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_VALIDMAN);
  1993.             String gestman = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTMAN);
  1994.             String registrazioneTracce = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_TRACCE);
  1995. //          String dumpApplicativo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_APPLICATIVO);
  1996. //          String dumpPD = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PD);
  1997. //          String dumpPA = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PA);

  1998.             // Campi obbligatori
  1999.             if (inoltromin.equals("")) {
  2000.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare una cadenza");
  2001.                 return false;
  2002.             }

  2003.             // Controllo che non ci siano spazi nei campi di testo
  2004.             if (inoltromin.indexOf(" ") != -1) {
  2005.                 this.pd.setMessage("Non inserire spazi nei campi di testo");
  2006.                 return false;
  2007.             }

  2008.             // Controllo che i campi "select" abbiano uno dei valori ammessi
  2009.             if (stato != null && !stato.equals("") && !stato.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  2010.                     !stato.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO) && !stato.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_STATO_WARNING_ONLY)) {
  2011.                 this.pd.setMessage("Stato dev'essere abilitato, disabilitato o warningOnly");
  2012.                 return false;
  2013.             }
  2014.             if (controllo != null && !controllo.equals("") &&
  2015.                     !controllo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_RIGIDO) &&
  2016.                     !controllo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_NORMALE)) {
  2017.                 this.pd.setMessage("Controllo dev'essere rigido o normale");
  2018.                 return false;
  2019.             }
  2020.             /*if (!spcoop.equals("off") && !spcoop.equals("fatalOpenspcoop") && !spcoop.equals("errorSpcoop") && !spcoop.equals("errorOpenspcoop") && !spcoop.equals("infoSpcoop") && !spcoop.equals("infoOpenspcoop") && !spcoop.equals("debugLow") && !spcoop.equals("debugMedium") && !spcoop.equals("debugHigh") && !spcoop.equals("all")) {
  2021.                     this.pd.setMessage("Livello SPCoop dev'essere off, fatalOpenspcoop, errorSpcoop, errorOpenspcoop, infoSpcoop, infoOpenspcoop, debugLow, debugMedium, debugHigh o all");
  2022.                     return false;
  2023.                 }
  2024.                 if (!openspcoop.equals("off") && !openspcoop.equals("fatalOpenspcoop") && !openspcoop.equals("errorSpcoop") && !openspcoop.equals("errorOpenspcoop") && !openspcoop.equals("infoSpcoop") && !openspcoop.equals("infoOpenspcoop") && !openspcoop.equals("debugLow") && !openspcoop.equals("debugMedium") && !openspcoop.equals("debugHigh") && !openspcoop.equals("all")) {
  2025.                     this.pd.setMessage("Livello OpenSPCoop dev'essere off, fatalOpenspcoop, errorSpcoop, errorOpenspcoop, infoSpcoop, infoOpenspcoop, debugLow, debugMedium, debugHigh o all");
  2026.                     return false;
  2027.                 }*/
  2028.             boolean foundIM = false;
  2029.             for (int i = 0; i < ConfigurazioneCostanti.PARAMETRI_CONFIGURAZIONE_IM.length; i++) {
  2030.                 if(ConfigurazioneCostanti.PARAMETRI_CONFIGURAZIONE_IM[i].equals(integman)){
  2031.                     foundIM = true;
  2032.                     break;
  2033.                 }
  2034.             }
  2035.             if (!foundIM &&
  2036.                     !integman.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_IM_CUSTOM)) {
  2037.                 this.pd.setMessage("Tipo autenticazione per integrationManager sconosciuto");
  2038.                 return false;
  2039.             }
  2040.             if (profcoll != null && !profcoll.equals("") &&
  2041.                     !profcoll.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  2042.                     !profcoll.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  2043.                 this.pd.setMessage("Profilo di collaborazione dev'essere abilitato o disabilitato");
  2044.                 return false;
  2045.             }
  2046.             if (connessione != null && !connessione.equals("") &&
  2047.                     !connessione.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONNESSIONE_NEW) &&
  2048.                     !connessione.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONNESSIONE_REPLY)) {
  2049.                 this.pd.setMessage("Connessione dev'essere abilitato o disabilitato");
  2050.                 return false;
  2051.             }
  2052.             if (utilizzo != null && !utilizzo.equals("") && !utilizzo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  2053.                     !utilizzo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  2054.                 this.pd.setMessage("Utilizzo dev'essere abilitato o disabilitato");
  2055.                 return false;
  2056.             }
  2057.             if (validman != null && !validman.equals("") && !validman.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  2058.                     !validman.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  2059.                 this.pd.setMessage("Manifest attachments dev'essere abilitato o disabilitato");
  2060.                 return false;
  2061.             }
  2062.             if (!gestman.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  2063.                     !gestman.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  2064.                 this.pd.setMessage("Gestione dev'essere abilitato o disabilitato");
  2065.                 return false;
  2066.             }
  2067.             if (!registrazioneTracce.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  2068.                     !registrazioneTracce.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  2069.                 this.pd.setMessage("Buste dev'essere abilitato o disabilitato");
  2070.                 return false;
  2071.             }
  2072. //          if (!dumpApplicativo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  2073. //                  !dumpApplicativo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  2074. //              this.pd.setMessage("Dump Applicativo dev'essere abilitato o disabilitato");
  2075. //              return false;
  2076. //          }
  2077. //          if (!dumpPD.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  2078. //                  !dumpPD.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  2079. //              this.pd.setMessage("Dump Binario Porta Delegata dev'essere abilitato o disabilitato");
  2080. //              return false;
  2081. //          }
  2082. //          if (!dumpPA.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  2083. //                  !dumpPA.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  2084. //              this.pd.setMessage("Dump Binario Porta Applicativa dev'essere abilitato o disabilitato");
  2085. //              return false;
  2086. //          }

  2087.             // inoltromin dev'essere numerico
  2088.             if (!this.checkNumber(inoltromin, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_INOLTRO_BUSTE_NON_RISCONTRATE, false) ) {
  2089.                 return false;
  2090.             }

  2091.             // Se integman = custom, nomeintegman dev'essere specificato
  2092.             if (integman.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_IM_CUSTOM) &&
  2093.                     (nomeintegman == null || nomeintegman.equals(""))) {
  2094.                 this.pd.setMessage("Indicare un nome per il tipo autenticazione");
  2095.                 return false;
  2096.             }

  2097.             String configurazioneCachesTmp = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CACHES);
  2098.             boolean isAllHiddenConfigurazione = ServletUtils.isCheckBoxEnabled(configurazioneCachesTmp);
  2099.             boolean isAllHiddenCache = !isAllHiddenConfigurazione;
  2100.            
  2101.             if(!this.registryCheckDataCache()){
  2102.                 return false;
  2103.             }
  2104.            
  2105.             if(!this.configurazioneCheckDataCache()){
  2106.                 return false;
  2107.             }
  2108.            
  2109.             if(!this.datiAutorizzazioneCheckDataCache()){
  2110.                 return false;
  2111.             }
  2112.            
  2113.             if(!this.datiAutenticazioneCheckDataCache()){
  2114.                 return false;
  2115.             }
  2116.            
  2117.             if(!this.datiGestioneTokenCheckDataCache()){
  2118.                 return false;
  2119.             }
  2120.            
  2121.             if(!this.datiAttributeAuthorityCheckDataCache()){
  2122.                 return false;
  2123.             }
  2124.            
  2125.             if(!this.datiKeystoreCheckDataCache()){
  2126.                 return false;
  2127.             }
  2128.            
  2129.             if(!isAllHiddenCache &&
  2130.                 (!this.controlloTrafficoCheckDataCache())
  2131.                 ){
  2132.                 return false;
  2133.             }
  2134.            
  2135.             if(!this.datiResponseCachingCheckDataCache()){
  2136.                 return false;
  2137.             }
  2138.            
  2139.             if(!this.datiGestoreConsegnaApplicativiCheckDataCache()){
  2140.                 return false;
  2141.             }
  2142.            
  2143.             // validazione URL Invocazione
  2144.             if(!this.checkDataURLInvocazione()) {
  2145.                 return false;
  2146.             }
  2147.            
  2148.             // validazione Cors
  2149.             if(!this.checkDataCors()) {
  2150.                 return false;
  2151.             }
  2152.            
  2153.             // validazione caching risposta
  2154.             if(!this.checkDataResponseCaching()) {
  2155.                 return false;
  2156.             }
  2157.            
  2158.             // validazione canali
  2159.             if(!this.canaliCheckData()) {
  2160.                 return false;
  2161.             }
  2162.            
  2163.             return true;

  2164.         } catch (Exception e) {
  2165.             this.logError("Exception: " + e.getMessage(), e);
  2166.             throw new DriverControlStationException(e);
  2167.         }
  2168.     }


  2169.     private boolean canaliCheckData() throws Exception {
  2170.         try{
  2171.             String canaliEnabledTmp = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_STATO);
  2172.             boolean canaliEnabled = ServletUtils.isCheckBoxEnabled(canaliEnabledTmp);
  2173.            
  2174.             Configurazione configurazione = this.confCore.getConfigurazioneGenerale();
  2175.             CanaliConfigurazione gestioneCanali = configurazione.getGestioneCanali();
  2176.             List<CanaleConfigurazione> canaleList = gestioneCanali != null ? gestioneCanali.getCanaleList() : null;
  2177.            
  2178.             if(canaliEnabled) {
  2179.                 String canaliNome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NOME);
  2180.                 String canaliDescrizione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_DESCRIZIONE);
  2181.                 String canaliDefault = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_DEFAULT);
  2182.            
  2183.                 if(canaleList == null || canaleList.size() == 0) { // in questa situazione mi dovrei trovare solo quando attivo la funzionalita'
  2184.                     if(canaleDatiCheckData(canaliNome, canaliDescrizione) == false) {
  2185.                         return false;
  2186.                     }
  2187.                 } else {
  2188.                     if(StringUtils.isEmpty(canaliDefault)){
  2189.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_DEFAULT));
  2190.                         return false;
  2191.                     }
  2192.                    
  2193.                     boolean found = false;
  2194.                     for (CanaleConfigurazione canaleConfigurazione : canaleList) {
  2195.                         if(canaleConfigurazione.getNome().equals(canaliDefault)) {
  2196.                             found = true;
  2197.                             break;
  2198.                         }
  2199.                     }
  2200.                    
  2201.                     if(found ==false) {
  2202.                         this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_CANALE_DEFAULT_SELEZIONATO_NON_ESISTE);
  2203.                         return false;
  2204.                     }
  2205.                 }
  2206.             } else {
  2207.                 boolean oldEnabled = (gestioneCanali != null && StatoFunzionalita.ABILITATO.equals(gestioneCanali.getStato()) ) ? true: false;
  2208.                
  2209.                 StringBuilder inUsoMessage = new StringBuilder();
  2210.                
  2211.                 if(oldEnabled) {
  2212.                     // se era abilitato e ora sto disabilitando devo controllare che non ci sia nessun canale in uso in API, Erogazioni o Fruizioni
  2213.                    
  2214.                     if(canaleList != null) {
  2215.                         for (CanaleConfigurazione canale : canaleList) {
  2216.                             if(ConfigurazioneCanaliUtilities.isCanaleInUsoRegistro(canale, this.confCore, this, inUsoMessage, org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE)) {
  2217.                                 this.pd.setMessage(MessageFormat.format(ConfigurazioneCostanti.MESSAGGIO_FUNZIONALITA_CANALI_NON_DISATTIVABILE, inUsoMessage.toString()));
  2218.                                 return false;
  2219.                             }
  2220.                         }
  2221.                     }
  2222.                 }
  2223.             }
  2224.            
  2225.             return true;
  2226.         } catch (Exception e) {
  2227.             this.logError("Exception: " + e.getMessage(), e);
  2228.             throw new DriverControlStationException(e);
  2229.         }
  2230.     }
  2231.     private boolean canaleDatiCheckData(String canaliNome, String canaliDescrizione) throws Exception {
  2232.         // nome obbligatorio
  2233.         if(StringUtils.isEmpty(canaliNome)){
  2234.             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NOME));
  2235.             return false;
  2236.         }
  2237.        
  2238.         if(this.checkSpazi(canaliNome, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NOME)==false) {
  2239.             return false;
  2240.         }
  2241.        
  2242.         if(this.checkLength255(canaliNome, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NOME)==false) {
  2243.             return false;
  2244.         }
  2245.        
  2246.         if(this.checkLength255(canaliDescrizione, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_DESCRIZIONE)==false) {
  2247.             return false;
  2248.         }
  2249.        
  2250.         return true;
  2251.     }
  2252.    
  2253.     public boolean registryCheckDataCache() throws Exception {

  2254.         try{

  2255.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_REGISTRY);
  2256.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_REGISTRY);
  2257.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_REGISTRY);
  2258.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_REGISTRY);
  2259.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_REGISTRY);

  2260.             return checkDatiCache(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CACHE_REGISTRY, statocache, dimensionecache, algoritmocache, idlecache, lifecache);

  2261.         } catch (Exception e) {
  2262.             this.logError("Exception: " + e.getMessage(), e);
  2263.             throw new DriverControlStationException(e);
  2264.         }
  2265.     }
  2266.    
  2267.     public boolean configurazioneCheckDataCache() throws Exception {

  2268.         try{

  2269.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_CONFIG);
  2270.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_CONFIG);
  2271.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_CONFIG);
  2272.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_CONFIG);
  2273.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_CONFIG);

  2274.             return checkDatiCache(CostantiPdD.JMX_CONFIGURAZIONE_PDD, statocache, dimensionecache, algoritmocache, idlecache, lifecache);

  2275.         } catch (Exception e) {
  2276.             this.logError("Exception: " + e.getMessage(), e);
  2277.             throw new DriverControlStationException(e);
  2278.         }
  2279.     }
  2280.    
  2281.     public boolean datiAutorizzazioneCheckDataCache() throws Exception {

  2282.         try{

  2283.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_AUTHZ);
  2284.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_AUTHZ);
  2285.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_AUTHZ);
  2286.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_AUTHZ);
  2287.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_AUTHZ);

  2288.             return checkDatiCache(CostantiPdD.JMX_AUTORIZZAZIONE, statocache, dimensionecache, algoritmocache, idlecache, lifecache);

  2289.         } catch (Exception e) {
  2290.             this.logError("Exception: " + e.getMessage(), e);
  2291.             throw new DriverControlStationException(e);
  2292.         }
  2293.     }
  2294.    
  2295.     public boolean datiAutenticazioneCheckDataCache() throws Exception {

  2296.         try{

  2297.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_AUTHN);
  2298.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_AUTHN);
  2299.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_AUTHN);
  2300.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_AUTHN);
  2301.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_AUTHN);

  2302.             return checkDatiCache(CostantiPdD.JMX_AUTENTICAZIONE, statocache, dimensionecache, algoritmocache, idlecache, lifecache);

  2303.         } catch (Exception e) {
  2304.             this.logError("Exception: " + e.getMessage(), e);
  2305.             throw new DriverControlStationException(e);
  2306.         }
  2307.     }
  2308.    
  2309.     public boolean datiGestioneTokenCheckDataCache() throws Exception {

  2310.         try{

  2311.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_TOKEN);
  2312.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_TOKEN);
  2313.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_TOKEN);
  2314.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_TOKEN);
  2315.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_TOKEN);

  2316.             return checkDatiCache(CostantiPdD.JMX_TOKEN, statocache, dimensionecache, algoritmocache, idlecache, lifecache);

  2317.         } catch (Exception e) {
  2318.             this.logError("Exception: " + e.getMessage(), e);
  2319.             throw new DriverControlStationException(e);
  2320.         }
  2321.     }
  2322.    
  2323.     public boolean datiAttributeAuthorityCheckDataCache() throws Exception {

  2324.         try{

  2325.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_ATTRIBUTE_AUTHORITY);
  2326.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_ATTRIBUTE_AUTHORITY);
  2327.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_ATTRIBUTE_AUTHORITY);
  2328.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_ATTRIBUTE_AUTHORITY);
  2329.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_ATTRIBUTE_AUTHORITY);

  2330.             return checkDatiCache(CostantiPdD.JMX_ATTRIBUTE_AUTHORITY, statocache, dimensionecache, algoritmocache, idlecache, lifecache);

  2331.         } catch (Exception e) {
  2332.             this.logError("Exception: " + e.getMessage(), e);
  2333.             throw new DriverControlStationException(e);
  2334.         }
  2335.     }
  2336.    
  2337.     public boolean datiKeystoreCheckDataCache() throws Exception {

  2338.         try{

  2339.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_KEYSTORE);
  2340.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_KEYSTORE);
  2341.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_KEYSTORE);
  2342.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_KEYSTORE);
  2343.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_KEYSTORE);

  2344.             boolean esito = checkDatiCache(CostantiPdD.JMX_KEYSTORE_CACHING, statocache, dimensionecache, algoritmocache, idlecache, lifecache);
  2345.             if(esito==false) {
  2346.                 return false;
  2347.             }
  2348.            
  2349.             String crllifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CRL_LIFE_CACHE_KEYSTORE);
  2350.             if (statocache.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) && crllifecache!=null && !crllifecache.equals("") &&
  2351.                     !this.checkNumber(crllifecache, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CRL_LIFE_CACHE+ "("+crllifecache+")", false)) {
  2352.                 return false;
  2353.             }
  2354.            
  2355.             return true;

  2356.         } catch (Exception e) {
  2357.             this.logError("Exception: " + e.getMessage(), e);
  2358.             throw new DriverControlStationException(e);
  2359.         }
  2360.     }
  2361.    
  2362.     public boolean controlloTrafficoCheckDataCache() throws Exception {

  2363.         try{

  2364.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_CONTROLLO_TRAFFICO);
  2365.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_CONTROLLO_TRAFFICO);
  2366.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_CONTROLLO_TRAFFICO);
  2367.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_CONTROLLO_TRAFFICO);
  2368.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_CONTROLLO_TRAFFICO);

  2369.             return checkDatiCache(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CACHE_CONTROLLO_TRAFFICO, statocache, dimensionecache, algoritmocache, idlecache, lifecache);

  2370.         } catch (Exception e) {
  2371.             this.logError("Exception: " + e.getMessage(), e);
  2372.             throw new DriverControlStationException(e);
  2373.         }
  2374.     }
  2375.    
  2376.     public boolean datiGestoreConsegnaApplicativiCheckDataCache() throws Exception {

  2377.         try{

  2378.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_KEYSTORE);
  2379.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_KEYSTORE);
  2380.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_KEYSTORE);
  2381.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_KEYSTORE);
  2382.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_KEYSTORE);

  2383.             return checkDatiCache(CostantiPdD.JMX_LOAD_BALANCER, statocache, dimensionecache, algoritmocache, idlecache, lifecache);

  2384.         } catch (Exception e) {
  2385.             this.logError("Exception: " + e.getMessage(), e);
  2386.             throw new DriverControlStationException(e);
  2387.         }
  2388.     }
  2389.    
  2390.     public boolean datiResponseCachingCheckDataCache() throws Exception {

  2391.         try{

  2392.             String statocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_CACHE_RISPOSTE);
  2393.             String dimensionecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DIMENSIONE_CACHE_RISPOSTE);
  2394.             String algoritmocache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALGORITMO_CACHE_RISPOSTE);
  2395.             String idlecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_IDLE_CACHE_RISPOSTE);
  2396.             String lifecache = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIFE_CACHE_RISPOSTE);

  2397.             return checkDatiCache(CostantiPdD.JMX_RESPONSE_CACHING, statocache, dimensionecache, algoritmocache, idlecache, lifecache);

  2398.         } catch (Exception e) {
  2399.             this.logError("Exception: " + e.getMessage(), e);
  2400.             throw new DriverControlStationException(e);
  2401.         }
  2402.     }





  2403.     // Prepara la lista di appender dei messaggi diagnostici
  2404.     public void prepareDiagnosticaAppenderList(List<OpenspcoopAppender> lista)
  2405.             throws Exception {
  2406.         try {
  2407.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_DIAGNOSTICA_APPENDER);
  2408.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);

  2409.             //this.pd.setIndex(offset);
  2410.             //this.pd.setPageSize(limit);
  2411.             if (lista == null)
  2412.                 this.pd.setNumEntries(0);
  2413.             else
  2414.                 this.pd.setNumEntries(lista.size());

  2415.             this.pd.setSearchDescription("");
  2416.             this.pd.setSearch("off");

  2417.             // setto la barra del titolo
  2418.             List<Parameter> lstParam = new ArrayList<>();

  2419.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO,
  2420.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI));
  2421.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_APPENDER_MESSAGGI_DIAGNOSTICI ,   null));

  2422.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  2423.             // setto le label delle colonne
  2424.             String[] labels = {
  2425.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO,
  2426.                     ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA
  2427.             };
  2428.             this.pd.setLabels(labels);

  2429.             // preparo i dati
  2430.             List<List<DataElement>> dati = new ArrayList<>();

  2431.             if (lista != null) {
  2432.                 for (int i = 0; i < lista.size(); i++) {
  2433.                     OpenspcoopAppender oa = lista.get(i);

  2434.                     List<DataElement> e = new ArrayList<>();

  2435.                     Parameter pOaId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, oa.getId() + "");

  2436.                     DataElement de = new DataElement();
  2437.                     de.setUrl(
  2438.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_APPENDER_CHANGE, pOaId);
  2439.                     de.setValue(oa.getTipo());
  2440.                     de.setIdToRemove(""+oa.getId());
  2441.                     e.add(de);

  2442.                     de = new DataElement();
  2443.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_APPENDER_PROPERTIES_LIST, pOaId);
  2444.                     if (contaListe!=null && contaListe.booleanValue())
  2445.                         ServletUtils.setDataElementVisualizzaLabel(de, (long)oa.sizePropertyList());
  2446.                     else
  2447.                         ServletUtils.setDataElementVisualizzaLabel(de);
  2448.                     e.add(de);

  2449.                     dati.add(e);
  2450.                 }
  2451.             }

  2452.             this.pd.setDati(dati);
  2453.             this.pd.setAddButton(true);
  2454.         } catch (Exception e) {
  2455.             this.logError("Exception: " + e.getMessage(), e);
  2456.             throw new DriverControlStationException(e);
  2457.         }
  2458.     }

  2459.     // Controlla i dati dell'appender dei messaggi diagnostici
  2460.     public boolean diagnosticaAppenderCheckData(TipoOperazione tipoOp)
  2461.             throws Exception {
  2462.         try {
  2463.             String tipo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);

  2464.             if (tipo == null || "".equals(tipo)) {
  2465.                 this.pd.setMessage("Il campo Tipo deve essere specificato.");
  2466.                 return false;
  2467.             }

  2468.             // Se tipoOp = add, controllo che l'appender non sia gia' stato registrato
  2469.             if (tipoOp.equals(TipoOperazione.ADD)) {
  2470.                     boolean trovatoAppender = false;
  2471.                     Configurazione newConfigurazione = this.core.getConfigurazioneGenerale();
  2472.                     MessaggiDiagnostici md = newConfigurazione.getMessaggiDiagnostici();
  2473.                     if (md != null) {
  2474.                         OpenspcoopAppender oa = null;
  2475.                         for (int j = 0; j < md.sizeOpenspcoopAppenderList(); j++) {
  2476.                             oa =  md.getOpenspcoopAppender(j);
  2477.                             if (tipo.equals(oa.getTipo())) {
  2478.                                 trovatoAppender = true;
  2479.                                 break;
  2480.                             }
  2481.                         }
  2482.                     }
  2483.                     if (trovatoAppender) {
  2484.                         this.pd.setMessage("Esiste gi&agrave; un Appender con tipo " + tipo);
  2485.                         return false;
  2486.                     }
  2487.                 }

  2488.             return true;
  2489.         } catch (Exception e) {
  2490.             this.logError("Exception: " + e.getMessage(), e);
  2491.             throw new DriverControlStationException(e);
  2492.         }
  2493.     }

  2494.     // Prepara la lista di property di appender dei messaggi diagnostici
  2495.     public void prepareDiagnosticaAppenderPropList(OpenspcoopAppender oa,
  2496.             List<Property> lista)
  2497.                     throws Exception {
  2498.         try {
  2499.             Parameter pOaId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, ""+oa.getId());
  2500.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_DIAGNOSTICA_APPENDER_PROPERTIES, pOaId);


  2501.             //this.pd.setIndex(offset);
  2502.             //this.pd.setPageSize(limit);
  2503.             if (lista == null)
  2504.                 this.pd.setNumEntries(0);
  2505.             else
  2506.                 this.pd.setNumEntries(lista.size());

  2507.             this.pd.setSearchDescription("");
  2508.             this.pd.setSearch("off");

  2509.             // setto la barra del titolo
  2510.             List<Parameter> lstParam = new ArrayList<>();

  2511.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO,
  2512.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI));
  2513.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_APPENDER_MESSAGGI_DIAGNOSTICI,
  2514.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_APPENDER_LIST));
  2515.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA + " di " + oa.getTipo(),
  2516.                     null));

  2517.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  2518.             // setto le label delle colonne
  2519.             String[] labels = {
  2520.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME,
  2521.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_VALORE
  2522.             };
  2523.             this.pd.setLabels(labels);

  2524.             // preparo i dati
  2525.             List<List<DataElement>> dati = new ArrayList<>();

  2526.             if (lista != null) {
  2527.                 for (int i = 0; i < lista.size(); i++) {
  2528.                     Property oap = lista.get(i);

  2529.                     List<DataElement> e = new ArrayList<>();

  2530.                     Parameter pIdProp = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID_PROPRIETA, oap.getId()  + "");
  2531.                     DataElement de = new DataElement();
  2532.                     de.setUrl(
  2533.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_APPENDER_PROPERTIES_CHANGE, pOaId, pIdProp);
  2534.                     de.setValue(oap.getNome());
  2535.                     de.setIdToRemove(""+oap.getId());
  2536.                     e.add(de);

  2537.                     de = new DataElement();
  2538.                     de.setValue(oap.getValore());
  2539.                     e.add(de);

  2540.                     dati.add(e);
  2541.                 }
  2542.             }

  2543.             this.pd.setDati(dati);
  2544.             this.pd.setAddButton(true);
  2545.         } catch (Exception e) {
  2546.             this.logError("Exception: " + e.getMessage(), e);
  2547.             throw new DriverControlStationException(e);
  2548.         }
  2549.     }

  2550.     // Controlla i dati delle property dell'appender dei messaggi diagnostici
  2551.     public boolean diagnosticaAppenderPropCheckData(TipoOperazione tipoOp)
  2552.             throws Exception {
  2553.         try {
  2554.             String id = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID);
  2555.             int idInt = Integer.parseInt(id);
  2556.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  2557.             String valore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_VALORE);

  2558.             if (nome == null || "".equals(nome)) {
  2559.                 this.pd.setMessage("Il campo Nome deve essere specificato.");
  2560.                 return false;
  2561.             }
  2562.             if (valore == null || "".equals(valore)) {
  2563.                 this.pd.setMessage("Il campo Valore deve essere specificato.");
  2564.                 return false;
  2565.             }

  2566.             // Se tipoOp = add, controllo che la property non sia gia' stata registrata
  2567.             if (tipoOp.equals(TipoOperazione.ADD)) {
  2568.                 boolean trovataProp = false;
  2569.                 Configurazione newConfigurazione = this.core.getConfigurazioneGenerale();
  2570.                 MessaggiDiagnostici md = newConfigurazione.getMessaggiDiagnostici();
  2571.                 OpenspcoopAppender oa = null;
  2572.                 for (int j = 0; j < md.sizeOpenspcoopAppenderList(); j++) {
  2573.                     oa = md.getOpenspcoopAppender(j);
  2574.                     if (idInt == oa.getId().intValue()) {
  2575.                         break;
  2576.                     }
  2577.                 }
  2578.                
  2579.                 if(oa==null) {
  2580.                     throw new DriverControlStationException("Appender non trovato");
  2581.                 }
  2582.                
  2583.                 Property oap = null;
  2584.                 for (int i = 0; i < oa.sizePropertyList(); i++) {
  2585.                     oap = oa.getProperty(i);
  2586.                     if (nome.equals(oap.getNome())) {
  2587.                         trovataProp = true;
  2588.                         break;
  2589.                     }
  2590.                 }
  2591.                 if (trovataProp) {
  2592.                     this.pd.setMessage("Esiste gi&agrave; una Proprietà con nome " + nome);
  2593.                     return false;
  2594.                 }
  2595.             }

  2596.             return true;
  2597.         } catch (Exception e) {
  2598.             this.logError("Exception: " + e.getMessage(), e);
  2599.             throw new DriverControlStationException(e);
  2600.         }
  2601.     }

  2602.     // Prepara la lista di datasource dei messaggi diagnostici
  2603.     public void prepareDiagnosticaDatasourceList(List<OpenspcoopSorgenteDati> lista)
  2604.             throws Exception {
  2605.         try {
  2606.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_DIAGNOSTICA_DATASOURCE);
  2607.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);

  2608.             //this.pd.setIndex(offset);
  2609.             //this.pd.setPageSize(limit);
  2610.             if (lista == null)
  2611.                 this.pd.setNumEntries(0);
  2612.             else
  2613.                 this.pd.setNumEntries(lista.size());

  2614.             this.pd.setSearchDescription("");
  2615.             this.pd.setSearch("off");

  2616.             // setto la barra del titolo
  2617.             List<Parameter> lstParam = new ArrayList<>();

  2618.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO,
  2619.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI));
  2620.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_SORGENTI_DATI_MESSAGGI_DIAGNOSTICI , null));

  2621.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  2622.             // setto le label delle colonne
  2623.             String[] labels = {
  2624.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME,
  2625.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME_JNDI,
  2626.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_DATABASE,
  2627.                     ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA
  2628.             };
  2629.             this.pd.setLabels(labels);

  2630.             // preparo i dati
  2631.             List<List<DataElement>> dati = new ArrayList<>();

  2632.             if (lista != null) {
  2633.                 for (int i = 0; i < lista.size(); i++) {
  2634.                     OpenspcoopSorgenteDati od = lista.get(i);

  2635.                     List<DataElement> e = new ArrayList<>();

  2636.                     Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, od.getId() + "");
  2637.                     DataElement de = new DataElement();
  2638.                     de.setUrl(
  2639.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_DATASOURCE_CHANGE, pId);
  2640.                     de.setValue(od.getNome());
  2641.                     de.setIdToRemove(""+od.getId());
  2642.                     e.add(de);

  2643.                     de = new DataElement();
  2644.                     de.setValue(od.getNomeJndi());
  2645.                     e.add(de);

  2646.                     de = new DataElement();
  2647.                     de.setValue(od.getTipoDatabase());
  2648.                     e.add(de);

  2649.                     de = new DataElement();
  2650.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_DATASOURCE_PROPERTIES_LIST, pId);
  2651.                     if (contaListe!=null && contaListe.booleanValue())
  2652.                         ServletUtils.setDataElementVisualizzaLabel(de, (long)  od.sizePropertyList());
  2653.                     else
  2654.                         ServletUtils.setDataElementVisualizzaLabel(de);
  2655.                     e.add(de);

  2656.                     dati.add(e);
  2657.                 }
  2658.             }

  2659.             this.pd.setDati(dati);
  2660.             this.pd.setAddButton(true);
  2661.         } catch (Exception e) {
  2662.             this.logError("Exception: " + e.getMessage(), e);
  2663.             throw new DriverControlStationException(e);
  2664.         }
  2665.     }

  2666.     // Controlla i dati del sorgente dati dei messaggi diagnostici
  2667.     public boolean diagnosticaDatasourceCheckData(TipoOperazione tipoOp)
  2668.             throws Exception {
  2669.         try {
  2670.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  2671.             String nomeJndi = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_JNDI);
  2672.             String tipoDatabase = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_DATABASE);

  2673.             if (nome == null || "".equals(nome)) {
  2674.                 this.pd.setMessage("Il campo Nome deve essere specificato.");
  2675.                 return false;
  2676.             }
  2677.             if (nomeJndi == null || "".equals(nomeJndi)) {
  2678.                 this.pd.setMessage("Il campo Nome Jndi deve essere specificato.");
  2679.                 return false;
  2680.             }
  2681.             if (tipoDatabase == null || "".equals(tipoDatabase)) {
  2682.                 this.pd.setMessage("Il campo Tipo Database deve essere specificato.");
  2683.                 return false;
  2684.             }

  2685.             // Se tipoOp = add, controllo che il sorgente dati non sia gia' stato registrato
  2686.             if (tipoOp.equals(TipoOperazione.ADD)) {
  2687.                 boolean trovatoDatasource = false;
  2688.                 Configurazione newConfigurazione = this.core.getConfigurazioneGenerale();
  2689.                 MessaggiDiagnostici md = newConfigurazione.getMessaggiDiagnostici();
  2690.                 if (md != null) {
  2691.                     List<OpenspcoopSorgenteDati> lista = md.getOpenspcoopSorgenteDatiList();
  2692.                     OpenspcoopSorgenteDati od = null;
  2693.                     for (int j = 0; j < md.sizeOpenspcoopSorgenteDatiList(); j++) {
  2694.                         od = lista.get(j);
  2695.                         if (nome.equals(od.getNome())) {
  2696.                             trovatoDatasource = true;
  2697.                             break;
  2698.                         }
  2699.                     }
  2700.                 }
  2701.                 if (trovatoDatasource) {
  2702.                     this.pd.setMessage("Esiste gi&agrave; un sorgente dati con nome " + nome);
  2703.                     return false;
  2704.                 }
  2705.             }

  2706.             return true;
  2707.         } catch (Exception e) {
  2708.             this.logError("Exception: " + e.getMessage(), e);
  2709.             throw new DriverControlStationException(e);
  2710.         }
  2711.     }

  2712.     // Prepara la lista di property di datasource dei messaggi diagnostici
  2713.     public void prepareDiagnosticaDatasourcePropList(OpenspcoopSorgenteDati od,
  2714.             List<Property> lista)
  2715.                     throws Exception {
  2716.         try {
  2717.             Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID, od.getId() + "");
  2718.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_DIAGNOSTICA_DATASOURCE_PROPERTIES, pId);

  2719.             //this.pd.setIndex(offset);
  2720.             //this.pd.setPageSize(limit);
  2721.             if (lista == null)
  2722.                 this.pd.setNumEntries(0);
  2723.             else
  2724.                 this.pd.setNumEntries(lista.size());

  2725.             this.pd.setSearchDescription("");
  2726.             this.pd.setSearch("off");

  2727.             // setto la barra del titolo
  2728.             List<Parameter> lstParam = new ArrayList<>();

  2729.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO,
  2730.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI));
  2731.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ELENCO_SORGENTI_DATI_MESSAGGI_DIAGNOSTICI,
  2732.                     ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_DATASOURCE_LIST));
  2733.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA + " di " + od.getNome(),  null));

  2734.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  2735.             // setto le label delle colonne
  2736.             String[] labels = {
  2737.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME,
  2738.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_VALORE
  2739.             };
  2740.             this.pd.setLabels(labels);

  2741.             // preparo i dati
  2742.             List<List<DataElement>> dati = new ArrayList<>();

  2743.             if (lista != null) {
  2744.                 for (int i = 0; i < lista.size(); i++) {
  2745.                     Property odp = lista.get(i);

  2746.                     List<DataElement> e = new ArrayList<>();
  2747.                     Parameter pOdpId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID_PROPRIETA, odp.getId() + "");
  2748.                     DataElement de = new DataElement();
  2749.                     de.setUrl(
  2750.                             ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_DATASOURCE_PROPERTIES_CHANGE, pId, pOdpId);
  2751.                     de.setValue(odp.getNome());
  2752.                     de.setIdToRemove(""+odp.getId());
  2753.                     e.add(de);

  2754.                     de = new DataElement();
  2755.                     de.setValue(odp.getValore());
  2756.                     e.add(de);

  2757.                     dati.add(e);
  2758.                 }
  2759.             }

  2760.             this.pd.setDati(dati);
  2761.             this.pd.setAddButton(true);
  2762.         } catch (Exception e) {
  2763.             this.logError("Exception: " + e.getMessage(), e);
  2764.             throw new DriverControlStationException(e);
  2765.         }
  2766.     }

  2767.     // Controlla i dati delle property del datasource dei messaggi diagnostici
  2768.     public boolean diagnosticaDatasourcePropCheckData(TipoOperazione tipoOp)
  2769.             throws Exception {
  2770.         try {
  2771.             String id = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ID);
  2772.             int idInt = Integer.parseInt(id);
  2773.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  2774.             String valore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_VALORE);

  2775.             if (nome == null || "".equals(nome)) {
  2776.                 this.pd.setMessage("Il campo Nome deve essere specificato.");
  2777.                 return false;
  2778.             }
  2779.             if (valore == null || "".equals(valore)) {
  2780.                 this.pd.setMessage("Il campo Valore deve essere specificato.");
  2781.                 return false;
  2782.             }

  2783.             // Se tipoOp = add, controllo che la property non sia gia' stata registrata
  2784.             if (tipoOp.equals(TipoOperazione.ADD)) {
  2785.                 boolean trovataProp = false;
  2786.                 Configurazione newConfigurazione = this.core.getConfigurazioneGenerale();
  2787.                 MessaggiDiagnostici md = newConfigurazione.getMessaggiDiagnostici();
  2788.                 List<OpenspcoopSorgenteDati> lista = md.getOpenspcoopSorgenteDatiList();
  2789.                 OpenspcoopSorgenteDati od = null;
  2790.                 for (int j = 0; j < md.sizeOpenspcoopSorgenteDatiList(); j++) {
  2791.                     od = lista.get(j);
  2792.                     if (idInt == od.getId().intValue()) {
  2793.                         break;
  2794.                     }
  2795.                 }
  2796.                
  2797.                 if(od==null) {
  2798.                     throw new DriverControlStationException("Datasource non trovato");
  2799.                 }
  2800.                
  2801.                 List<Property> lista1 = od.getPropertyList();
  2802.                 Property odp = null;
  2803.                 for (int i = 0; i < od.sizePropertyList(); i++) {
  2804.                     odp = lista1.get(i);
  2805.                     if (nome.equals(odp.getNome())) {
  2806.                         trovataProp = true;
  2807.                         break;
  2808.                     }
  2809.                 }
  2810.                 if (trovataProp) {
  2811.                     this.pd.setMessage("Esiste gi&agrave; una Proprietà con nome " + nome);
  2812.                     return false;
  2813.                 }
  2814.             }

  2815.             return true;
  2816.         } catch (Exception e) {
  2817.             this.logError("Exception: " + e.getMessage(), e);
  2818.             throw new DriverControlStationException(e);
  2819.         }
  2820.     }



  2821.     public List<DataElement>  addValoriRottaToDati(TipoOperazione tipoOp, String nome,
  2822.             String tipo, String tiporotta, String registrorotta,
  2823.             String[] registriList,
  2824.             String[] registriListLabel, List<DataElement> dati, String tiposoggrotta, String nomesoggrotta,
  2825.             String[] tipiSoggettiLabel, String[] tipiSoggettiLabelPerProtocollo )
  2826.                     throws DriverRegistroServiziException {
  2827.         DataElement de = new DataElement();
  2828.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DESTINATARIO);
  2829.         de.setType(DataElementType.TITLE);
  2830.         dati.add(de);

  2831. //      if (InterfaceType.STANDARD.equals(ServletUtils.getUserFromSession(this.session).getInterfaceType())) {
  2832. //          de = new DataElement();
  2833. //          de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO);
  2834. //          de.setValue(this.soggettiCore.getTipoSoggettoDefault());
  2835. //          de.setType(DataElementType.HIDDEN);
  2836. //          de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);
  2837. //          de.setSize(getSize());
  2838. //          dati.add(de);
  2839. //      } else {
  2840.         de = new DataElement();
  2841.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO);
  2842. //      if (tipo == null) {
  2843. //          de.setValue("");
  2844. //      } else {
  2845. //          de.setValue(tipo);
  2846. //      }
  2847.         de.setSelected(tipo);
  2848.         de.setValues(tipiSoggettiLabel);
  2849.         //de.setType(DataElementType.TEXT_EDIT);
  2850.         de.setType(DataElementType.SELECT);
  2851.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);
  2852.         de.setPostBack(true);
  2853.         de.setSize(getSize());
  2854.         de.setRequired(true);
  2855.         dati.add(de);
  2856. //      }

  2857.         de = new DataElement();
  2858.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME);
  2859.         de.setValue(nome);
  2860.         de.setType(DataElementType.TEXT_EDIT);
  2861.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  2862.         de.setSize(getSize());
  2863.         de.setRequired(true);
  2864.         dati.add(de);

  2865.         de = new DataElement();
  2866.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ROTTA);
  2867.         de.setType(DataElementType.TITLE);
  2868.         dati.add(de);

  2869.         String[] tipoR = { ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY,
  2870.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_REGISTRO
  2871.         };
  2872.         de = new DataElement();
  2873.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO);
  2874.         de.setType(DataElementType.SELECT);
  2875.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA);
  2876.         de.setValues(tipoR);
  2877.         de.setSelected(tiporotta);
  2878.         //              de.setOnChange("CambiaRotta('add')");
  2879.         de.setPostBack(true);
  2880.         dati.add(de);

  2881. //      if (InterfaceType.STANDARD.equals(ServletUtils.getUserFromSession(this.session).getInterfaceType())) {
  2882. //          if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY)) {
  2883. //              de = new DataElement();
  2884. //              de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_SOGGETTO_ROTTA);
  2885. //              de.setValue(this.soggettiCore.getTipoSoggettoDefault());
  2886. //              de.setType(DataElementType.HIDDEN);
  2887. //              de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_SOGGETTO_ROTTA);
  2888. //              de.setSize(getSize());
  2889. //              dati.add(de);
  2890. //
  2891. //              de = new DataElement();
  2892. //              de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME_SOGGETTO_ROTTA);
  2893. //              de.setValue(nomesoggrotta);
  2894. //              de.setType(DataElementType.TEXT_EDIT);
  2895. //              de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_SOGGETTO_ROTTA);
  2896. //              de.setSize(getSize());
  2897. //              de.setRequired(true);
  2898. //              dati.add(de);
  2899. //          }
  2900. //      } else {
  2901.         if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY)) {
  2902.             de = new DataElement();
  2903.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_SOGGETTO_ROTTA);
  2904.             //de.setValue(tiposoggrotta);
  2905.             de.setSelected(tiposoggrotta);
  2906.             de.setValues(tipiSoggettiLabelPerProtocollo);
  2907.             //de.setType(DataElementType.TEXT_EDIT);
  2908.             de.setType(DataElementType.SELECT);
  2909.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_SOGGETTO_ROTTA);
  2910.             de.setSize(getSize());
  2911.             de.setRequired(true);
  2912.             dati.add(de);

  2913.             de = new DataElement();
  2914.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME_SOGGETTO_ROTTA);
  2915.             de.setValue(nomesoggrotta);
  2916.             de.setType(DataElementType.TEXT_EDIT);
  2917.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_SOGGETTO_ROTTA);
  2918.             de.setSize(getSize());
  2919.             de.setRequired(true);
  2920.             dati.add(de);
  2921.         }
  2922. //      }

  2923.         if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_REGISTRO)) {
  2924.             de = new DataElement();
  2925.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_REGISTRO_ROTTA);
  2926.             de.setType(DataElementType.SELECT);
  2927.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRO_ROTTA);
  2928.             de.setValues(registriList);
  2929.             de.setLabels(registriListLabel);
  2930.             de.setSelected(registrorotta);
  2931.             dati.add(de);
  2932.         }

  2933.         return dati;
  2934.     }




  2935.     public List<DataElement> addRoutingToDati(TipoOperazione tipoOp, String tiporotta,
  2936.             String tiposoggrotta, String nomesoggrotta, String registrorotta,
  2937.             String rottaenabled,  
  2938.             String[] registriList, String[] registriListLabel, String[] tipiSoggettiLabel,
  2939.             List<DataElement> dati) throws DriverRegistroServiziException {
  2940.        
  2941.         if(dati==null) {
  2942.             throw new DriverRegistroServiziException("Dati is null");
  2943.         }
  2944.        
  2945.         DataElement dataElement = new DataElement();
  2946.         dataElement.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ROUTING_DELLE_BUSTE);
  2947.         dataElement.setType(DataElementType.TITLE);
  2948.         dati.add(dataElement);
  2949.        
  2950.         DataElement de = new DataElement();
  2951.         String[] tipoRouting = {
  2952.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  2953.                 ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO
  2954.         };
  2955.         de = new DataElement();
  2956.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ROUTING_DELLE_BUSTE_STATO);
  2957.         de.setType(DataElementType.SELECT);
  2958.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ROTTA_ENABLED);
  2959.         de.setValues(tipoRouting);
  2960.         de.setSelected(rottaenabled);
  2961.         //                  de.setOnChange("CambiaRouting()");
  2962.         de.setPostBack(true);
  2963.         dati.add(de);

  2964.         if (rottaenabled.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO)) {
  2965.             de = new DataElement();
  2966.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ROTTA_DI_DEFAULT);
  2967.             de.setType(DataElementType.TITLE);
  2968.             dati.add(de);

  2969.             String[] tipoR = {
  2970.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY,
  2971.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_REGISTRO
  2972.             };
  2973.             de = new DataElement();
  2974.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO);
  2975.             de.setType(DataElementType.SELECT);
  2976.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA);
  2977.             de.setValues(tipoR);
  2978.             de.setSelected(tiporotta);
  2979.             //                      de.setOnChange("CambiaRotta('routing')");
  2980.             de.setPostBack(true);
  2981.             dati.add(de);

  2982. //          if (InterfaceType.STANDARD.equals(ServletUtils.getUserFromSession(this.session).getInterfaceType())) {
  2983. //              if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY)) {
  2984. //                  de = new DataElement();
  2985. //                  de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_SOGGETTO_ROTTA);
  2986. //                  de.setValue(this.soggettiCore.getTipoSoggettoDefault());
  2987. //                  de.setType(DataElementType.HIDDEN);
  2988. //                  de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_SOGGETTO_ROTTA);
  2989. //                  de.setSize(getSize());
  2990. //                  dati.add(de);
  2991. //
  2992. //                  de = new DataElement();
  2993. //                  de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME_SOGGETTO_ROTTA);
  2994. //                  de.setValue(nomesoggrotta);
  2995. //                  de.setType(DataElementType.TEXT_EDIT);
  2996. //                  de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_SOGGETTO_ROTTA);
  2997. //                  de.setRequired(true);
  2998. //                  de.setSize(getSize());
  2999. //                  dati.add(de);
  3000. //              }
  3001. //          } else {
  3002.             if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_GATEWAY)) {
  3003.                 de = new DataElement();
  3004.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_SOGGETTO_ROTTA);
  3005.                 //de.setValue(tiposoggrotta);
  3006.                 //de.setType(DataElementType.TEXT_EDIT);
  3007.                 de.setType(DataElementType.SELECT);
  3008.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_SOGGETTO_ROTTA);
  3009.                 de.setValues(tipiSoggettiLabel);
  3010.                 de.setSelected(tiposoggrotta);
  3011.                 de.setSize(getSize());
  3012.                 de.setRequired(true);
  3013.                 dati.add(de);

  3014.                 de = new DataElement();
  3015.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME_SOGGETTO_ROTTA);
  3016.                 de.setValue(nomesoggrotta);
  3017.                 de.setType(DataElementType.TEXT_EDIT);
  3018.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_SOGGETTO_ROTTA);
  3019.                 de.setSize(getSize());
  3020.                 de.setRequired(true);
  3021.                 dati.add(de);
  3022.             }
  3023. //          }

  3024.             if (tiporotta.equals(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_ROTTA_REGISTRO)) {
  3025.                 de = new DataElement();
  3026.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_REGISTRO_ROTTA);
  3027.                 de.setType(DataElementType.SELECT);
  3028.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRO_ROTTA);
  3029.                 de.setValues(registriList);
  3030.                 de.setLabels(registriListLabel);
  3031.                 de.setSelected(registrorotta);
  3032.                 dati.add(de);
  3033.             }

  3034.             de = new DataElement();
  3035.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ROTTE_STATICHE);
  3036.             de.setType(DataElementType.TITLE);
  3037.             dati.add(de);

  3038.             de = new DataElement();
  3039.             de.setType(DataElementType.LINK);
  3040.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ROTTE_ROUTING_LIST);
  3041.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DESTINAZIONI);
  3042.             dati.add(de);
  3043.         }
  3044.        
  3045.         dati = this.addParameterApplicaModifica(dati);

  3046.         return dati;
  3047.     }

  3048.     public List<DataElement> addRegistroToDati(TipoOperazione tipoOP, String nome, String location, String tipo,
  3049.             String utente, String password, String confpw,
  3050.             List<DataElement> dati) {
  3051.        
  3052.         DataElement dataElement = new DataElement();
  3053.         dataElement.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO);
  3054.         dataElement.setType(DataElementType.TITLE);
  3055.         dati.add(dataElement);
  3056.        
  3057.         DataElement de = new DataElement();
  3058.         de = new DataElement();
  3059.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME);
  3060.         de.setValue(nome);
  3061.         if(TipoOperazione.ADD.equals(tipoOP)){
  3062.             de.setType(DataElementType.TEXT_EDIT);
  3063.         }
  3064.         else{
  3065.             de.setType(DataElementType.TEXT);
  3066.         }
  3067.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME);
  3068.         de.setSize( getSize());
  3069.         de.setRequired(true);
  3070.         dati.add(de);

  3071.         de = new DataElement();
  3072.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOCATION);
  3073.         de.setValue(location);
  3074.         de.setType(DataElementType.TEXT_EDIT);
  3075.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LOCATION);
  3076.         de.setSize( getSize());
  3077.         de.setRequired(true);
  3078.         dati.add(de);

  3079.         //String[] tipoReg = { "xml", "db", "uddi", "web", "ws" };
  3080.         String[] tipoReg = {
  3081.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_XML,
  3082.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_DB,
  3083.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_WEB,
  3084.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_WS
  3085.         };
  3086.         de = new DataElement();
  3087.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO);
  3088.         de.setType(DataElementType.SELECT);
  3089.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO);
  3090.         de.setValues(tipoReg);
  3091.         de.setSelected(tipo);
  3092.         de.setPostBack(true);
  3093.         dati.add(de);

  3094.         if (tipo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_UDDI)) {
  3095.             de = new DataElement();
  3096.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_UTENTE);
  3097.             de.setValue(utente);
  3098.             de.setType(DataElementType.TEXT_EDIT);
  3099.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_UTENTE);
  3100.             de.setSize( getSize());
  3101.             dati.add(de);

  3102.             de = new DataElement();
  3103.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PW);
  3104.             de.setValue(password);
  3105.             de.setType(DataElementType.CRYPT);
  3106.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PW);
  3107.             de.setSize( getSize());
  3108.             dati.add(de);

  3109.             de = new DataElement();
  3110.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONFERMA_PW);
  3111.             de.setValue(confpw);
  3112.             de.setType(DataElementType.CRYPT);
  3113.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONFERMA_PW);
  3114.             de.setSize( getSize());
  3115.             dati.add(de);
  3116.         }


  3117.         return dati;
  3118.     }
  3119.    
  3120.    


  3121.     public List<DataElement> addConfigurazioneToDati(  
  3122.             boolean allHidden,
  3123.             String inoltromin, String stato,
  3124.             String controllo, String severita, String severita_log4j,
  3125.             String integman, String nomeintegman, String profcoll,
  3126.             String connessione, String utilizzo, String validman,
  3127.             String gestman, String registrazioneTracce, String dumpPD, String dumpPA,
  3128.             String xsd, String tipoValidazione, String confPers, Configurazione configurazione,
  3129.             List<DataElement> dati, String applicaMTOM,
  3130.             String urlInvocazionePA, String urlInvocazionePD,
  3131.             boolean multitenantEnabled, String multitenantSoggettiFruizioni, String multitenantSoggettiErogazioni,
  3132.             boolean editModeEnabled,
  3133.             boolean corsStato, TipoGestioneCORS corsTipo, boolean corsAllAllowOrigins, boolean corsAllAllowHeaders, boolean corsAllAllowMethods,    
  3134.             String corsAllowHeaders, String corsAllowOrigins, String corsAllowMethods,
  3135.             boolean corsAllowCredential, String corsExposeHeaders, boolean corsMaxAge, int corsMaxAgeSeconds,
  3136.             boolean responseCachingEnabled, int responseCachingSeconds, boolean responseCachingMaxResponseSize, long responseCachingMaxResponseSizeBytes,
  3137.             boolean responseCachingDigestUrlInvocazione, boolean responseCachingDigestHeaders, boolean responseCachingDigestPayload, String responseCachingDigestHeadersNomiHeaders, StatoFunzionalitaCacheDigestQueryParameter responseCachingDigestQueryParameter, String responseCachingDigestNomiParametriQuery,
  3138.             boolean responseCachingCacheControlNoCache, boolean responseCachingCacheControlMaxAge, boolean responseCachingCacheControlNoStore, boolean visualizzaLinkConfigurazioneRegola,
  3139.             String servletResponseCachingConfigurazioneRegolaList, List<Parameter> paramsResponseCachingConfigurazioneRegolaList, int numeroResponseCachingConfigurazioneRegola, int numeroRegoleProxyPass,
  3140.             boolean canaliEnabled, int numeroCanali, int numeroNodi, String canaliNome, String canaliDescrizione, List<CanaleConfigurazione> canaleList, String canaliDefault,      
  3141.             int numeroArchiviPlugins, int numeroClassiPlugins) throws Exception {
  3142.         DataElement de = new DataElement();

  3143.         // Configurazione Inoltro Buste non Riscontrate e Validazione Buste
  3144.        
  3145.         if (!this.isModalitaCompleta() || allHidden) {
  3146.             de = new DataElement();
  3147.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_INOLTRO_MIN);
  3148.             de.setValue(inoltromin);
  3149.             de.setType(DataElementType.HIDDEN);
  3150.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_INOLTRO_MIN);
  3151.             de.setSize( getSize());
  3152.             dati.add(de);

  3153.             de = new DataElement();
  3154.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO);
  3155.             de.setType(DataElementType.HIDDEN);
  3156.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO);
  3157.             de.setValue(stato);

  3158.             dati.add(de);
  3159.             de = new DataElement();
  3160.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO);
  3161.             de.setType(DataElementType.HIDDEN);
  3162.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO);
  3163.             de.setValue(controllo);

  3164.             dati.add(de);

  3165.             de = new DataElement();
  3166.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROFILO_COLLABORAZIONE);
  3167.             de.setType(DataElementType.HIDDEN);
  3168.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROFILO_COLLABORAZIONE);
  3169.             de.setValue(profcoll);
  3170.             dati.add(de);

  3171.             de = new DataElement();
  3172.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_VALIDMAN);
  3173.             de.setType(DataElementType.HIDDEN);
  3174.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_VALIDMAN);
  3175.             de.setValue(validman);
  3176.             dati.add(de);
  3177.         } else {

  3178.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_INOLTRO_BUSTE_NON_RISCONTRATE);
  3179.             de.setType(DataElementType.TITLE);
  3180.             dati.add(de);
  3181.  
  3182.             de = new DataElement();
  3183.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_INOLTRO_MIN);
  3184.             de.setValue(inoltromin);
  3185.             de.setType(DataElementType.TEXT_EDIT);
  3186.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_INOLTRO_MIN);
  3187.             de.setRequired(true);
  3188.             de.setSize(getSize());
  3189.             dati.add(de);

  3190.             de = new DataElement();
  3191.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_VALIDAZIONE_BUSTE);
  3192.             de.setType(DataElementType.TITLE);
  3193.             dati.add(de);

  3194.             String[] tipoStato = {
  3195.                     ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  3196.                     ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO,
  3197.                     ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_STATO_WARNING_ONLY
  3198.             };
  3199.             de = new DataElement();
  3200.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO);
  3201.             de.setType(DataElementType.SELECT);
  3202.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO);
  3203.             de.setValues(tipoStato);
  3204.             de.setSelected(stato);
  3205.             dati.add(de);

  3206.             String[] tipoControllo = {
  3207.                     ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_RIGIDO,
  3208.                     ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_NORMALE
  3209.             };
  3210.             de = new DataElement();
  3211.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO);
  3212.             de.setType(DataElementType.SELECT);
  3213.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO);
  3214.             de.setValues(tipoControllo);
  3215.             de.setSelected(controllo);
  3216.             dati.add(de);

  3217.             String[] tipoPF = {
  3218.                     ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  3219.                     ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO
  3220.             };
  3221.             de = new DataElement();
  3222.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROFILO_COLLABORAZIONE);
  3223.             de.setType(DataElementType.SELECT);
  3224.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROFILO_COLLABORAZIONE);
  3225.             de.setValues(tipoPF);
  3226.             de.setSelected(profcoll);
  3227.             dati.add(de);

  3228.             String[] tipoVM = {
  3229.                     ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  3230.                     ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO
  3231.             };
  3232.             de = new DataElement();
  3233.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_VALIDMAN);
  3234.             de.setType(DataElementType.SELECT);
  3235.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_VALIDMAN);
  3236.             de.setValues(tipoVM);
  3237.             de.setSelected(validman);
  3238.             dati.add(de);
  3239.         }

  3240.         // Mesaggi Diagnostici
  3241.        
  3242.         addMessaggiDiagnosticiToDatiAsHidden(severita, severita_log4j, dati);

  3243.         // Tracciamento
  3244.        
  3245.         addTracciamentoToDatiAsHidden(registrazioneTracce, configurazione, dati);
  3246.        
  3247.         // RegistrazioneMessaggi
  3248.        
  3249.         addRegistrazioneMessaggiToDatiAsHidden(dumpPD, dumpPA, configurazione, dati);
  3250.        
  3251.        
  3252.         // Configurazione Validazione Contenuti Applicativi,  Risposte (Connessione) e Indirizzo Telematico
  3253.        
  3254.         if (!this.isModalitaCompleta() || allHidden) {
  3255.             de = new DataElement();
  3256.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONNESSIONE);
  3257.             de.setType(DataElementType.HIDDEN);
  3258.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONNESSIONE);
  3259.             de.setValue(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONNESSIONE_REPLY);
  3260.             dati.add(de);

  3261.             de = new DataElement();
  3262.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_UTILIZZO);
  3263.             de.setType(DataElementType.HIDDEN);
  3264.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_UTILIZZO);
  3265.             de.setValue(CostantiConfigurazione.DISABILITATO.toString());
  3266.             de.setSelected(utilizzo);
  3267.             dati.add(de);
  3268.         } else {
  3269.             de = new DataElement();
  3270.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_VALIDAZIONE_CONTENUTI_APPLICATIVI);
  3271.             de.setType(DataElementType.TITLE);
  3272.             dati.add(de);

  3273.             String[] tipoXsd = {
  3274.                     ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  3275.                     ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO,
  3276.                     ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_STATO_WARNING_ONLY
  3277.             };
  3278.             de = new DataElement();
  3279.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_XSD);
  3280.             de.setType(DataElementType.SELECT);
  3281.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_XSD);
  3282.             de.setValues(tipoXsd);
  3283.             //                      de.setOnChange("CambiaValidazione('" +
  3284.             //                          InterfaceType.STANDARD.equals(user.getInterfaceType()) +
  3285.             //                          "')");
  3286.             de.setPostBack(true);
  3287.             if (xsd == null) {
  3288.                 de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO);
  3289.             } else {
  3290.                 de.setSelected(xsd);
  3291.             }
  3292.             dati.add(de);

  3293.             if (ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(xsd) ||
  3294.                     ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_STATO_WARNING_ONLY .equals(xsd)) {
  3295.                 //String[] tipi_validazione = { "xsd", "wsdl", "openspcoop" };
  3296.                 String[] tipi_validazione = {
  3297.                         ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_VALIDAZIONE_XSD,
  3298.                         ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_VALIDAZIONE_WSDL
  3299.                 };
  3300.                 de = new DataElement();
  3301.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_VALIDAZIONE);
  3302.                 de.setType(DataElementType.SELECT);
  3303.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_VALIDAZIONE);
  3304.                 de.setValues(tipi_validazione);
  3305.                 if (tipoValidazione == null) {
  3306.                     de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_VALIDAZIONE_XSD);
  3307.                 } else {
  3308.                     de.setSelected(tipoValidazione);
  3309.                 }
  3310.                 dati.add(de);
  3311.                
  3312.                
  3313.                 // Applica MTOM
  3314.                 de = new DataElement();
  3315.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ACCETTA_MTOM);

  3316.                
  3317.                 if(this.isModalitaAvanzata()){
  3318.                     de.setType(DataElementType.CHECKBOX);
  3319.                     if( ServletUtils.isCheckBoxEnabled(applicaMTOM) || CostantiRegistroServizi.ABILITATO.equals(applicaMTOM) ){
  3320.                         de.setSelected(true);
  3321.                     }
  3322.                 }
  3323.                 else{
  3324.                     de.setType(DataElementType.HIDDEN);
  3325.                     de.setValue(applicaMTOM);
  3326.                 }
  3327.              
  3328.                 de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_APPLICA_MTOM);
  3329.                 dati.add(de);
  3330.             }

  3331.             de = new DataElement();
  3332.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RISPOSTE);
  3333.             de.setType(DataElementType.TITLE);
  3334.             dati.add(de);

  3335.             String[] tipoConn = {
  3336.                     ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONNESSIONE_NEW,
  3337.                     ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONNESSIONE_REPLY
  3338.             };
  3339.             de = new DataElement();
  3340.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONNESSIONE);
  3341.             de.setType(DataElementType.SELECT);
  3342.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONNESSIONE);
  3343.             de.setValues(tipoConn);
  3344.             de.setSelected(connessione);
  3345.             dati.add(de);

  3346.             de = new DataElement();
  3347.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_INDIRIZZO_TELEMATICO);
  3348.             de.setType(DataElementType.TITLE);
  3349.             dati.add(de);

  3350.             String[] tipoU = {
  3351.                     ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  3352.                     ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO
  3353.             };
  3354.             de = new DataElement();
  3355.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_UTILIZZO);
  3356.             de.setType(DataElementType.SELECT);
  3357.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_UTILIZZO);
  3358.             de.setValues(tipoU);
  3359.             de.setSelected(utilizzo);
  3360.             dati.add(de);
  3361.         }

  3362.        
  3363.         // Configurazione Gestione Manifest
  3364.        
  3365.         if (this.isModalitaCompleta() && !allHidden) {
  3366.             de = new DataElement();
  3367.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MANIFEST_ATTACHMENTS);
  3368.             de.setType(DataElementType.TITLE);
  3369.             dati.add(de);
  3370.         }

  3371.         String[] tipoGM = {
  3372.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  3373.                 ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO
  3374.         };
  3375.         de = new DataElement();
  3376.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTMAN);
  3377.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTMAN);
  3378.         if (!this.isModalitaCompleta() || allHidden) {
  3379.             de.setType(DataElementType.HIDDEN);
  3380.         }
  3381.         else {
  3382.             de.setType(DataElementType.SELECT);
  3383.             de.setValues(tipoGM);
  3384.             de.setSelected(gestman);
  3385.         }
  3386.         de.setValue(gestman);
  3387.         dati.add(de);
  3388.        
  3389.        
  3390.        
  3391.         // Configurazione Multitenant
  3392.        
  3393.         if(!allHidden) {
  3394.             de = new DataElement();
  3395.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MULTITENANT);
  3396.             de.setType(DataElementType.TITLE);
  3397.             dati.add(de);
  3398.         }
  3399.        
  3400.         boolean existsMoreThanOneSoggettoOperativoPerProtocollo = false;
  3401.         List<org.openspcoop2.core.registry.Soggetto> l = this.soggettiCore.getSoggettiOperativi();
  3402.         Map<String, Integer> countSoggettoOperativiByProtocol = new HashMap<>();
  3403.         if(l!=null && !l.isEmpty()) {
  3404.             for (org.openspcoop2.core.registry.Soggetto soggetto : l) {
  3405.                 String protocol = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(soggetto.getTipo());
  3406.                 int count = 0;
  3407.                 if(countSoggettoOperativiByProtocol.containsKey(protocol)) {
  3408.                     count = countSoggettoOperativiByProtocol.remove(protocol);
  3409.                 }
  3410.                 count ++;
  3411.                 if(count>1) {
  3412.                     existsMoreThanOneSoggettoOperativoPerProtocollo = true;
  3413.                     break;
  3414.                 }
  3415.                 countSoggettoOperativiByProtocol.put(protocol, count);
  3416.             }
  3417.         }
  3418.        
  3419.         de = new DataElement();
  3420.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_MULTITENANT_STATO);
  3421.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_MULTITENANT_STATO);
  3422.         if(allHidden) {
  3423.             de.setType(DataElementType.HIDDEN);
  3424.         }
  3425.         else {
  3426.             if(!existsMoreThanOneSoggettoOperativoPerProtocollo) {
  3427.                 de.setType(DataElementType.SELECT);
  3428.                 de.setPostBack(true);
  3429.                 de.setValues(ConfigurazioneCostanti.STATI);
  3430.                 de.setSelected(multitenantEnabled ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue());
  3431.             }
  3432.             else {
  3433.                 de.setType(DataElementType.TEXT);
  3434.             }
  3435.         }
  3436.         de.setValue(multitenantEnabled ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue());
  3437.         dati.add(de);
  3438.        
  3439.         if(multitenantEnabled) {
  3440.            
  3441.             boolean linkSoggettiFiltroDominioImpostato = false; // confonde
  3442.             if(!allHidden && linkSoggettiFiltroDominioImpostato) {
  3443.                 de = new DataElement();
  3444.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_MULTITENANT_SOGGETTI);
  3445.                 de.setType(DataElementType.LINK);
  3446.                 de.setUrl(SoggettiCostanti.SERVLET_NAME_SOGGETTI_LIST,
  3447.                         new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_FILTER_DOMINIO_INTERNO,"true"));
  3448.                 dati.add(de);
  3449.             }
  3450.            
  3451.             if(!allHidden) {
  3452.                 de = new DataElement();
  3453.                 de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MULTITENANT_FRUIZIONI);
  3454.                 de.setType(DataElementType.SUBTITLE);
  3455.                 dati.add(de);
  3456.             }
  3457.            
  3458.             de = new DataElement();
  3459.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_MULTITENANT_FRUIZIONI_SOGGETTO_EROGATORE);
  3460.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_MULTITENANT_FRUIZIONI_SOGGETTO_EROGATORE);
  3461.             if(!allHidden && editModeEnabled) {
  3462.                 de.setType(DataElementType.SELECT);
  3463.                 String [] values = MultitenantSoggettiFruizioni.toEnumNameArray();
  3464.                 String [] labels = MultitenantSoggettiFruizioni.toArray();
  3465.                 de.setValues(values);
  3466.                 de.setLabels(labels);
  3467.                 de.setSelected(multitenantSoggettiFruizioni);
  3468.             }
  3469.             else {
  3470.                 de.setType(DataElementType.HIDDEN);
  3471.             }
  3472.             de.setValue(multitenantSoggettiFruizioni);
  3473.             dati.add(de);
  3474.            
  3475.             if(!editModeEnabled) {
  3476.                 de = new DataElement();
  3477.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_MULTITENANT_FRUIZIONI_SOGGETTO_EROGATORE);
  3478.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_MULTITENANT_FRUIZIONI_SOGGETTO_EROGATORE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  3479.                 String multi = MultitenantSoggettiFruizioni.SOLO_SOGGETTI_ESTERNI.getValue();
  3480.                 try {
  3481.                     multi = MultitenantSoggettiFruizioni.valueOf(multitenantSoggettiFruizioni).getValue();
  3482.                 }catch(Exception e) {
  3483.                     // null
  3484.                 }
  3485.                 de.setValue(multi);
  3486.                 if(allHidden) {
  3487.                     de.setType(DataElementType.HIDDEN);
  3488.                 }
  3489.                 dati.add(de);
  3490.             }
  3491.            
  3492.             if(!allHidden) {
  3493.                 de = new DataElement();
  3494.                 de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MULTITENANT_EROGAZIONI);
  3495.                 de.setType(DataElementType.SUBTITLE);
  3496.                 dati.add(de);
  3497.             }
  3498.            
  3499.             de = new DataElement();
  3500.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_MULTITENANT_EROGAZIONI_SOGGETTI_FRUITORI);
  3501.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_MULTITENANT_EROGAZIONI_SOGGETTI_FRUITORI);
  3502.             if(!allHidden && editModeEnabled) {
  3503.                 de.setType(DataElementType.SELECT);
  3504.                 String [] values = MultitenantSoggettiErogazioni.toEnumNameArray();
  3505.                 String [] labels = MultitenantSoggettiErogazioni.toArray();
  3506.                 de.setValues(values);
  3507.                 de.setLabels(labels);
  3508.                 de.setSelected(multitenantSoggettiErogazioni);
  3509.             }
  3510.             else {
  3511.                 de.setType(DataElementType.HIDDEN);
  3512.             }
  3513.             de.setValue(multitenantSoggettiErogazioni);
  3514.             dati.add(de);
  3515.            
  3516.             if(!editModeEnabled) {
  3517.                 de = new DataElement();
  3518.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_MULTITENANT_EROGAZIONI_SOGGETTI_FRUITORI);
  3519.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_MULTITENANT_EROGAZIONI_SOGGETTI_FRUITORI+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  3520.                 String multi = MultitenantSoggettiErogazioni.SOLO_SOGGETTI_ESTERNI.getValue();
  3521.                 try {
  3522.                     multi = MultitenantSoggettiErogazioni.valueOf(multitenantSoggettiErogazioni).getValue();
  3523.                 }catch(Exception e) {
  3524.                     // null
  3525.                 }
  3526.                 de.setValue(multi);
  3527.                 if(allHidden) {
  3528.                     de.setType(DataElementType.HIDDEN);
  3529.                 }
  3530.                 dati.add(de);
  3531.             }
  3532.         }
  3533.        
  3534.        
  3535.        
  3536.         // Configurazione URL di Invocazione
  3537.        
  3538.         if(!allHidden) {
  3539.             de = new DataElement();
  3540.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PREFIX_URL_INVOCAZIONE);
  3541.             de.setType(DataElementType.TITLE);
  3542.             dati.add(de);
  3543.         }
  3544.        
  3545.         de = new DataElement();
  3546.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PA);
  3547.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PA);
  3548.         if(allHidden) {
  3549.             de.setType(DataElementType.HIDDEN);
  3550.         }
  3551.         else {
  3552.             de.setType(DataElementType.TEXT_EDIT);
  3553.             de.setRequired(true);
  3554.         }
  3555.         de.setValue(urlInvocazionePA);
  3556.         dati.add(de);
  3557.        
  3558.         de = new DataElement();
  3559.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PD);
  3560.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PD);
  3561.         if(allHidden) {
  3562.             de.setType(DataElementType.HIDDEN);
  3563.         }
  3564.         else {
  3565.             de.setType(DataElementType.TEXT_EDIT);
  3566.             de.setRequired(false);
  3567.         }
  3568.         de.setValue(urlInvocazionePD);
  3569.         dati.add(de);
  3570.        
  3571.         if(!allHidden) {
  3572.             de = new DataElement();
  3573.             de.setType(DataElementType.LINK);
  3574.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PROXY_PASS_REGOLA_LIST);
  3575.             boolean contaListeFromSession = ServletUtils.getContaListeFromSession(this.session) != null ? ServletUtils.getContaListeFromSession(this.session) : false;
  3576.             if (contaListeFromSession)
  3577.                 de.setValue(ConfigurazioneCostanti.LABEL_REGOLE_PROXY_PASS+" (" + numeroRegoleProxyPass + ")");
  3578.             else
  3579.                 de.setValue(ConfigurazioneCostanti.LABEL_REGOLE_PROXY_PASS);
  3580.             dati.add(de);
  3581.            

  3582.             String send = ArchiviCostanti.SERVLET_NAME_PACKAGE_EXPORT+"?"+
  3583.                     ArchiviCostanti.PARAMETRO_ARCHIVI_EXPORT_TIPO+"="+ArchiveType.CONFIGURAZIONE_URL_INVOCAZIONE.name();
  3584.             List<String> protocolli = this.confCore.getProtocolli(this.request, this.session, true);
  3585.             String protocollo = protocolli.get(0);
  3586.             if(protocollo!=null && !"".equals(protocollo)){
  3587.                 send = send + "&" + ArchiviCostanti.PARAMETRO_ARCHIVI_PROTOCOLLO+"="+ protocollo;
  3588.             }
  3589.             ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);
  3590.             List<ExportMode> exportModes = exporterUtils.getExportModesCompatibleWithAllProtocol(protocolli, ArchiveType.CONFIGURAZIONE_URL_INVOCAZIONE);
  3591.             String exportMode = null;
  3592.             if(exportModes!=null) {
  3593.                 if(exportModes.contains(org.openspcoop2.protocol.basic.Costanti.OPENSPCOOP_EXPORT_ARCHIVE_MODE)){
  3594.                     exportMode = org.openspcoop2.protocol.basic.Costanti.OPENSPCOOP_EXPORT_ARCHIVE_MODE.toString();
  3595.                 }else{
  3596.                     exportMode = exportModes.get(0).toString();
  3597.                 }
  3598.             }
  3599.             if(exportMode!=null && !"".equals(exportMode)){
  3600.                 send = send + "&" + ArchiviCostanti.PARAMETRO_ARCHIVI_TIPOLOGIA_ARCHIVIO+"="+ exportMode;
  3601.             }
  3602.             de = new DataElement();
  3603.             de.setType(DataElementType.LINK);
  3604.             de.setUrl(send);
  3605.             de.setValue(ConfigurazioneCostanti.LABEL_ESPORTA_URL_INVOCAZIONE);
  3606.             dati.add(de);
  3607.            
  3608.         }
  3609.        
  3610.        
  3611.         // Configuriazione CORS
  3612.         this.addConfigurazioneCorsToDati(dati, corsStato, corsTipo,
  3613.                 corsAllAllowOrigins, corsAllAllowHeaders, corsAllAllowMethods,
  3614.                 corsAllowHeaders, corsAllowOrigins, corsAllowMethods,
  3615.                 corsAllowCredential, corsExposeHeaders, corsMaxAge, corsMaxAgeSeconds,
  3616.                 true,
  3617.                 allHidden);
  3618.        
  3619.         // Configurazione Response Caching
  3620.         this.addResponseCachingToDati(dati, responseCachingEnabled, responseCachingSeconds, responseCachingMaxResponseSize,     responseCachingMaxResponseSizeBytes, responseCachingDigestUrlInvocazione, responseCachingDigestHeaders,
  3621.                 responseCachingDigestPayload, true, responseCachingDigestHeadersNomiHeaders, responseCachingDigestQueryParameter, responseCachingDigestNomiParametriQuery,  
  3622.                 responseCachingCacheControlNoCache, responseCachingCacheControlMaxAge, responseCachingCacheControlNoStore,
  3623.                 visualizzaLinkConfigurazioneRegola, servletResponseCachingConfigurazioneRegolaList, paramsResponseCachingConfigurazioneRegolaList, numeroResponseCachingConfigurazioneRegola,
  3624.                 allHidden);
  3625.        
  3626.         // Configurazione Canali
  3627.         this.addConfigurazioneCanaliToDati(dati, canaliEnabled, numeroCanali, numeroNodi, canaliNome, canaliDescrizione, true, allHidden, canaleList, canaliDefault);

  3628.        
  3629.        
  3630.         // Configurazione I.M.

  3631.         boolean integrationManagerSupported = this.confCore.isIntegrationManagerEnabled();
  3632.        
  3633.         if (integrationManagerSupported && !this.isModalitaStandard() && !allHidden) {
  3634.             de = new DataElement();
  3635.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_INTEGRATION_MANAGER);
  3636.             de.setType(DataElementType.TITLE);
  3637.             dati.add(de);
  3638.         }

  3639.         int totEl = ConfigurazioneCostanti.PARAMETRI_CONFIGURAZIONE_IM.length;
  3640.         if (confPers.equals(Costanti.CHECK_BOX_ENABLED_TRUE))
  3641.             totEl++;
  3642.         String[] tipoIM = new String[totEl];
  3643.         for (int i = 0; i < ConfigurazioneCostanti.PARAMETRI_CONFIGURAZIONE_IM.length; i++) {
  3644.             tipoIM[i] = ConfigurazioneCostanti.PARAMETRI_CONFIGURAZIONE_IM[i];
  3645.         }
  3646.         if (confPers.equals(Costanti.CHECK_BOX_ENABLED_TRUE))
  3647.             tipoIM[(totEl-1)] = ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_IM_CUSTOM;
  3648.         de = new DataElement();
  3649.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_INTEGMAN);
  3650.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_INTEGMAN);
  3651.         if (!integrationManagerSupported || this.isModalitaStandard() || allHidden) {
  3652.             de.setType(DataElementType.HIDDEN);
  3653.         }
  3654.         else {
  3655.             de.setType(DataElementType.SELECT);
  3656.             de.setValues(tipoIM);
  3657.             de.setSelected(integman);
  3658.             de.setPostBack(true);
  3659.         }
  3660.         de.setValue(integman);
  3661.         dati.add(de);

  3662.         de = new DataElement();
  3663.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_NOME_INTEGMAN);
  3664.         if (!integrationManagerSupported || this.isModalitaStandard() || allHidden) {
  3665.             de.setType(DataElementType.HIDDEN);
  3666.         }
  3667.         else {
  3668.             if (integman == null || !integman.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_IM_CUSTOM))
  3669.                 de.setType(DataElementType.HIDDEN);
  3670.             else
  3671.                 de.setType(DataElementType.TEXT_EDIT);
  3672.         }
  3673.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_NOME_INTEGMAN);
  3674.         de.setValue(nomeintegman);
  3675.         dati.add(de);
  3676.        
  3677.        
  3678.        
  3679.         // Configurazione Plugins
  3680.        
  3681.         boolean pluginsAbilitati = this.core.isConfigurazionePluginsEnabled();
  3682.        
  3683.         if(!allHidden && pluginsAbilitati && !this.isModalitaStandard()) {
  3684.            
  3685.             boolean contaListeFromSession = ServletUtils.getContaListeFromSession(this.session) != null ? ServletUtils.getContaListeFromSession(this.session) : false;
  3686.            
  3687.             de = new DataElement();
  3688.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PLUGINS);
  3689.             de.setType(DataElementType.TITLE);
  3690.             dati.add(de);
  3691.            
  3692.             // link Registro Archivi
  3693.             de = new DataElement();
  3694.             de.setType(DataElementType.LINK);
  3695.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_LIST);
  3696.             if (contaListeFromSession)
  3697.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PLUGINS_REGISTRO_ARCHIVI +" (" + numeroArchiviPlugins + ")");
  3698.             else
  3699.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PLUGINS_REGISTRO_ARCHIVI);
  3700.             dati.add(de);
  3701.            
  3702.             // Registro Classi
  3703.             de = new DataElement();
  3704.             de.setType(DataElementType.LINK);
  3705.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_CLASSI_LIST);
  3706.             if (contaListeFromSession)
  3707.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO_CLASSI+" (" + numeroClassiPlugins + ")");
  3708.             else
  3709.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO_CLASSI);
  3710.             dati.add(de);
  3711.         }
  3712.        
  3713.        
  3714.         // configurazione handler
  3715.         boolean handlerAbilitati = this.core.isConfigurazioneHandlersEnabled();
  3716.         if(!allHidden && handlerAbilitati && !this.isModalitaStandard()) {
  3717.             this.visualizzaLinkHandlers(dati, true, null, null, null);
  3718.         }
  3719.        
  3720.         // Configurazione del Profilo se il multitenant non è abilitato
  3721.        
  3722.         if(!allHidden && !multitenantEnabled) {
  3723.             de = new DataElement();
  3724.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROFILO);
  3725.             de.setType(DataElementType.TITLE);
  3726.             dati.add(de);
  3727.         }
  3728.        
  3729.         ProtocolFactoryManager pManager = ProtocolFactoryManager.getInstance();
  3730.         MapReader<String, IProtocolFactory<?>> mapPFactory = pManager.getProtocolFactories();
  3731.         Enumeration<String> protocolName = mapPFactory.keys();
  3732.         List<String> protocolliDispondibili = new ArrayList<>();
  3733.         while (protocolName.hasMoreElements()) {
  3734.             String protocollo = (String) protocolName.nextElement();
  3735.             protocolliDispondibili.add(protocollo);
  3736.         }
  3737.         for (String protocollo : ProtocolUtils.orderProtocolli(protocolliDispondibili)) {
  3738.             IProtocolFactory<?> pFactory = mapPFactory.get(protocollo);
  3739.            
  3740.             InformazioniProtocollo infoProt = pFactory.getInformazioniProtocol();
  3741.                    
  3742.             User user = ServletUtils.getUserFromSession(this.request, this.session);
  3743.             String userLogin = user.getLogin();
  3744.            
  3745.             if(mapPFactory.size()>1) {
  3746.                 if(!allHidden && !multitenantEnabled) {
  3747.                     de = new DataElement();
  3748.                     de.setLabel(infoProt.getLabel());
  3749.                     de.setType(DataElementType.SUBTITLE);
  3750.                     dati.add(de);
  3751.                 }
  3752.             }
  3753.            
  3754.             de = new DataElement();
  3755.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_NAME);
  3756.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_NAME+protocollo);
  3757.             de.setType(DataElementType.HIDDEN);
  3758.             de.setValue(protocollo);
  3759.             dati.add(de);
  3760.                                                        
  3761.             if(!multitenantEnabled) {
  3762.                 IDSoggetto idSoggetto = this.soggettiCore.getSoggettoOperativoDefault(userLogin, protocollo);
  3763.                 long idSoggettoLong = this.soggettiCore.getIdSoggetto(idSoggetto.getNome(), idSoggetto.getTipo());
  3764.                        
  3765.                 de = new DataElement();
  3766.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_SOGGETTO);
  3767.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_SOGGETTO+protocollo);
  3768.                 de.setValue(this.getLabelNomeSoggetto(protocollo, idSoggetto.getTipo(), idSoggetto.getNome()));
  3769.                 if(allHidden) {
  3770.                     de.setType(DataElementType.HIDDEN);
  3771.                 }
  3772.                 else {
  3773.                     de.setType(DataElementType.TEXT);
  3774.                 }
  3775.                 dati.add(de);
  3776.                
  3777.                 if(!allHidden) {
  3778.                     de = new DataElement();
  3779.                     de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_SOGGETTO_VISUALIZZA_DATI);
  3780.                     de.setType(DataElementType.LINK);
  3781.                     de.setUrl(SoggettiCostanti.SERVLET_NAME_SOGGETTI_CHANGE,
  3782.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_ID,idSoggettoLong+""),
  3783.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_NOME,idSoggetto.getNome()),
  3784.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_TIPO,idSoggetto.getTipo()),
  3785.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_MODIFICA_OPERATIVO,"true"));
  3786.                     dati.add(de);
  3787.                 }
  3788.             }
  3789.         }
  3790.        
  3791.        
  3792.         // Registro dei Servizi e Tabella di Routing
  3793.        
  3794.         if (!allHidden && this.isModalitaCompleta()) {
  3795.             de = new DataElement();
  3796.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO_SERVIZI);
  3797.             de.setType(DataElementType.TITLE);
  3798.             dati.add(de);
  3799.    
  3800.             de = new DataElement();
  3801.             de.setType(DataElementType.LINK);
  3802.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ACCESSO_REGISTRO_SERVIZI);
  3803.             ServletUtils.setDataElementVisualizzaLabel(de);
  3804.             dati.add(de);
  3805.    
  3806.             de = new DataElement();
  3807.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TABELLA_DI_ROUTING);
  3808.             de.setType(DataElementType.TITLE);
  3809.             dati.add(de);
  3810.    
  3811.             de = new DataElement();
  3812.             de.setType(DataElementType.LINK);
  3813.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ROUTING);
  3814.             ServletUtils.setDataElementVisualizzaLabel(de);
  3815.             dati.add(de);
  3816.        
  3817.         }
  3818.        
  3819.         // Proprietà di sistema
  3820.        
  3821.         if (!allHidden) {
  3822.    
  3823.             de = new DataElement();
  3824.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROPRIETA_SISTEMA);
  3825.             de.setType(DataElementType.TITLE);
  3826.             dati.add(de);
  3827.            
  3828.             de = new DataElement();
  3829.             de.setType(DataElementType.LINK);
  3830.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SYSTEM_PROPERTIES_LIST);
  3831.             ServletUtils.setDataElementVisualizzaLabel(de);
  3832.             dati.add(de);
  3833.            
  3834.         }
  3835.        
  3836.         // Lascio solo in menu
  3837. //      if(this.confCore.getJmxPdD_aliases()!=null && this.confCore.getJmxPdD_aliases().size()>0){
  3838. //      
  3839. //          de = new DataElement();
  3840. //          de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA);
  3841. //          de.setType(DataElementType.TITLE);
  3842. //          dati.add(de);
  3843. //  
  3844. //          de = new DataElement();
  3845. //          de.setType(DataElementType.LINK);
  3846. //          de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD);
  3847. //          ServletUtils.setDataElementVisualizzaLabel(de);
  3848. //          dati.add(de);
  3849. //          
  3850. //      }

  3851.         return dati;
  3852.     }
  3853.    
  3854.     private void addConfigurazioneCanaliToDati(List<DataElement> dati, boolean canaliEnabled, int numeroCanali,
  3855.             int numeroNodi, String canaliNome, String canaliDescrizione, boolean addTitle, boolean allHidden, List<CanaleConfigurazione> canaleList, String canaliDefault) throws Exception {
  3856.        
  3857.         boolean contaListeFromSession = ServletUtils.getContaListeFromSession(this.session) != null ? ServletUtils.getContaListeFromSession(this.session) : false;
  3858.         DataElement de;
  3859.        
  3860.         if(!allHidden && addTitle) {
  3861.             de = new DataElement();
  3862.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CANALI);
  3863.             de.setType(DataElementType.TITLE);
  3864.             dati.add(de);
  3865.         }
  3866.        
  3867.         boolean funzionalitaDisabilitabile = true;
  3868.         if(canaliEnabled) {
  3869.             if(canaleList != null) {
  3870.                 for (CanaleConfigurazione canale : canaleList) {
  3871.                     if(ConfigurazioneCanaliUtilities.isCanaleInUsoRegistro(canale, this.confCore, this, new StringBuilder(), org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE)) {
  3872.                         funzionalitaDisabilitabile = false;
  3873.                         break;
  3874.                     }
  3875.                 }
  3876.             }
  3877.         }
  3878.        
  3879.         de = new DataElement();
  3880.         de.setLabel(addTitle ?  ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_STATO : "");
  3881.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_STATO);
  3882.         if(allHidden) {
  3883.             de.setType(DataElementType.HIDDEN);
  3884.         }
  3885.         else if(!funzionalitaDisabilitabile) {
  3886.             de.setType(DataElementType.TEXT);
  3887.         }
  3888.         else {
  3889.             de.setType(DataElementType.SELECT);
  3890.             de.setPostBack(true);
  3891.             de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA);
  3892.             de.setSelected(canaliEnabled ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue());
  3893.         }
  3894.         de.setValue(canaliEnabled ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue());
  3895.         dati.add(de);
  3896.        
  3897.         if(!allHidden) {
  3898.             // se si passa da disabilitato ad abilitato, il numero dei canali e' 0, devo visualizzare la form di inserimento del canale di default
  3899.             if(canaliEnabled) {
  3900.                 if(numeroCanali == 0) {
  3901.                     // subtitle
  3902.                     de = new DataElement();
  3903.                     de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CANALE_DEFAULT);
  3904.                     de.setType(DataElementType.SUBTITLE);
  3905.                     dati.add(de);
  3906.                    
  3907.                     // nome canale
  3908.                     de = new DataElement();
  3909.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NOME);
  3910.                     de.setType(DataElementType.TEXT_EDIT);
  3911.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NOME);
  3912.                     de.setValue(canaliNome);
  3913.                     de.setRequired(true);
  3914.                     dati.add(de);
  3915.                    
  3916.                    
  3917.                     // descrizione canale
  3918.                     de = new DataElement();
  3919.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_DESCRIZIONE);
  3920.                     de.setType(DataElementType.TEXT_EDIT);
  3921.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_DESCRIZIONE);
  3922.                     de.setValue(canaliDescrizione);
  3923.                     dati.add(de);
  3924.                 } else {
  3925.                     // scelta canale default
  3926.                     de = new DataElement();
  3927.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_DEFAULT);
  3928.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_DEFAULT);
  3929.                     de.setType(DataElementType.SELECT);
  3930.                    
  3931.                     List<String> canaliListValues = canaleList!=null ? canaleList.stream().map(CanaleConfigurazione::getNome).collect(Collectors.toList()) : new ArrayList<>();
  3932.                     de.setValues(canaliListValues);
  3933.                     de.setLabels(canaliListValues);
  3934.                     de.setSelected(canaliDefault);
  3935.                     dati.add(de);
  3936.                    
  3937.                     // link canali
  3938.                     de = new DataElement();
  3939.                     de.setType(DataElementType.LINK);
  3940.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CANALI_LIST);
  3941.                    
  3942.                     if (contaListeFromSession)
  3943.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_CANALI +" (" + numeroCanali + ")");
  3944.                     else
  3945.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_CANALI);
  3946.                     dati.add(de);
  3947.                    
  3948.                     // link nodi
  3949.                     de = new DataElement();
  3950.                     de.setType(DataElementType.LINK);
  3951.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CANALI_NODI_LIST);
  3952.                     if (contaListeFromSession)
  3953.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_CANALI_NODI +" (" + numeroNodi + ")");
  3954.                     else
  3955.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_CANALI_NODI);
  3956.                     dati.add(de);
  3957.                 }
  3958.             }
  3959.         }
  3960.     }
  3961.     public void addRegistrazioneMessaggiToDatiAsHidden(String dumpPD, String dumpPA, Configurazione configurazione, List<DataElement> dati) {
  3962.         DataElement de = new DataElement();
  3963.        
  3964.         de = new DataElement();
  3965.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PD);
  3966.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PD);
  3967.         de.setType(DataElementType.HIDDEN);
  3968.         de.setValue(dumpPD);
  3969.         dati.add(de);
  3970.        
  3971.         de = new DataElement();
  3972.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PA);
  3973.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PA);
  3974.         de.setType(DataElementType.HIDDEN);
  3975.         de.setValue(dumpPA);
  3976.         dati.add(de);
  3977.        
  3978.     }
  3979.    
  3980.     public void addRegistrazioneMessaggiToDati(String dumpApplicativo, String dumpPD, String dumpPA, Configurazione configurazione, List<DataElement> dati, Boolean contaListe) {
  3981.         DataElement de;
  3982.         // DUMP
  3983.        
  3984.         de = new DataElement();
  3985.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_MESSAGGI);
  3986.         de.setType(DataElementType.TITLE);
  3987.         dati.add(de);
  3988.        
  3989.         String[] tipoDump = {
  3990.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  3991.                 ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO
  3992.         };
  3993.         de = new DataElement();
  3994.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_APPLICATIVO);
  3995.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO);
  3996.         de.setType(DataElementType.SELECT);
  3997.         de.setValues(tipoDump);
  3998.         de.setSelected(dumpApplicativo);
  3999.         de.setPostBack_viaPOST(true);
  4000.         dati.add(de);
  4001.        
  4002.         if(dumpApplicativo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO)) {
  4003.             String oldDumpApplicativo =null;
  4004.             if(configurazione.getDump().getStato()!=null)
  4005.                 oldDumpApplicativo = configurazione.getDump().getStato().toString();
  4006.            
  4007.             if(dumpApplicativo.equals(oldDumpApplicativo)) {
  4008.                 de = new DataElement();
  4009.                 de.setType(DataElementType.LINK);
  4010.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DUMP_CONFIGURAZIONE,
  4011.                         new Parameter(CostantiControlStation.PARAMETRO_DUMP_TIPO_CONFIGURAZIONE, TipoPdD.APPLICATIVA.getTipo()));
  4012.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DUMP_CONFIGURAZIONE_EROGAZIONI);
  4013.                 dati.add(de);
  4014.                
  4015.                 de = new DataElement();
  4016.                 de.setType(DataElementType.LINK);
  4017.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DUMP_CONFIGURAZIONE,
  4018.                         new Parameter(CostantiControlStation.PARAMETRO_DUMP_TIPO_CONFIGURAZIONE, TipoPdD.DELEGATA.getTipo()));
  4019.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DUMP_CONFIGURAZIONE_FRUIZIONI);
  4020.                 dati.add(de);
  4021.             }
  4022.         }
  4023.        
  4024.         if (this.isModalitaAvanzata()) {
  4025.             if (this.confCore.isDumpShowConfigurazioneCustomAppender()) {
  4026.                 de = new DataElement();
  4027.                 de.setType(DataElementType.LINK);
  4028.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DUMP_APPENDER_LIST);
  4029.                 if (contaListe!=null && contaListe.booleanValue()) {
  4030.                     int totAppender = 0;
  4031.                     if (configurazione.getDump() != null)
  4032.                         totAppender =
  4033.                         configurazione.getDump().sizeOpenspcoopAppenderList();
  4034.                     ServletUtils.setDataElementCustomLabel(de, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_APPENDER, (long)totAppender);
  4035.                 } else
  4036.                     ServletUtils.setDataElementCustomLabel(de, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_APPENDER);
  4037.                 dati.add(de);
  4038.             }
  4039.         }
  4040.        
  4041.         if(this.isModalitaAvanzata()){
  4042.             de = new DataElement();
  4043.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE);
  4044.             de.setType(DataElementType.SUBTITLE);
  4045.             dati.add(de);
  4046.         }
  4047.        
  4048.         String[] tipoDumpConnettorePA = {
  4049.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  4050.                 ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO
  4051.         };
  4052.         de = new DataElement();
  4053.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PA);
  4054.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PA);
  4055.         if(this.isModalitaAvanzata()){
  4056.             de.setType(DataElementType.SELECT);
  4057.             de.setValues(tipoDumpConnettorePA);
  4058.             de.setSelected(dumpPA);
  4059.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_CONNETTORE_PA_NOTE);
  4060.         }
  4061.         else{
  4062.             de.setType(DataElementType.HIDDEN);
  4063.             de.setValue(dumpPA);
  4064.         }
  4065.         dati.add(de);
  4066.        
  4067.         String[] tipoDumpConnettorePD = {
  4068.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  4069.                 ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO
  4070.         };
  4071.         de = new DataElement();
  4072.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PD);
  4073.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PD);
  4074.         if(this.isModalitaAvanzata()){
  4075.             de.setType(DataElementType.SELECT);
  4076.             de.setValues(tipoDumpConnettorePD);
  4077.             de.setSelected(dumpPD);
  4078.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_CONNETTORE_PD_NOTE);
  4079.         }
  4080.         else{
  4081.             de.setType(DataElementType.HIDDEN);
  4082.             de.setValue(dumpPD);
  4083.         }
  4084.         dati.add(de);
  4085.                
  4086.     }
  4087.    
  4088.     public void addTracciamentoToDatiAsHidden(String registrazioneTracce, Configurazione configurazione, List<DataElement> dati) {
  4089.         DataElement de = new DataElement();
  4090.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_TRACCE);
  4091.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO);
  4092.         de.setType(DataElementType.HIDDEN);
  4093.         de.setValue(registrazioneTracce);
  4094.         dati.add(de);
  4095.     }

  4096.     public void addTracciamentoToDati(String registrazioneTracce, Configurazione configurazione, List<DataElement> dati,    Boolean contaListe) {
  4097.         DataElement de;
  4098.        
  4099.         boolean showTitleSection =
  4100.                 (this.isModalitaCompleta())
  4101.                 ||
  4102.                 (this.isModalitaAvanzata() && (this.confCore.isTracceShowConfigurazioneCustomAppender() || this.confCore.isTracceShowSorgentiDatiDatabase()));
  4103.                
  4104.         if(showTitleSection) {
  4105.             if(this.isModalitaAvanzata()){
  4106.                 de = new DataElement();
  4107.                 de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCE);
  4108.                 de.setType(DataElementType.TITLE);
  4109.                 dati.add(de);
  4110.             }
  4111.         }
  4112.    
  4113.         String[] tipoBuste = {
  4114.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO,
  4115.                 ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO
  4116.         };
  4117.         de = new DataElement();
  4118.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_TRACCE);
  4119.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO);
  4120.         if(this.isModalitaCompleta()){
  4121.             de.setType(DataElementType.SELECT);
  4122.             de.setValues(tipoBuste);
  4123.             de.setSelected(registrazioneTracce);
  4124.             de.setPostBack_viaPOST(true);
  4125.         }
  4126.         else{
  4127.             de.setType(DataElementType.HIDDEN);
  4128.             de.setValue(registrazioneTracce);
  4129.         }
  4130.         dati.add(de);
  4131.    
  4132.         if (this.isModalitaAvanzata()) {
  4133.             if (this.confCore.isTracceShowConfigurazioneCustomAppender()) {
  4134.                 de = new DataElement();
  4135.                 de.setType(DataElementType.LINK);
  4136.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_APPENDER_LIST);
  4137.                 if (contaListe!=null && contaListe.booleanValue()) {
  4138.                     int totAppender = 0;
  4139.                     if (configurazione.getTracciamento() != null)
  4140.                         totAppender =
  4141.                         configurazione.getTracciamento().sizeOpenspcoopAppenderList();
  4142.                     ServletUtils.setDataElementCustomLabel(de, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_APPENDER, (long)totAppender);
  4143.                 } else
  4144.                     ServletUtils.setDataElementCustomLabel(de, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_APPENDER);
  4145.                 dati.add(de);
  4146.             }
  4147.             if (this.confCore.isTracceShowSorgentiDatiDatabase()) {
  4148.                 de = new DataElement();
  4149.                 de.setType(DataElementType.LINK);
  4150.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_DATASOURCE_LIST);
  4151.                 if (contaListe!=null && contaListe.booleanValue()) {
  4152.                     int totDs = 0;
  4153.                     if (configurazione.getTracciamento() != null)
  4154.                         totDs =
  4155.                         configurazione.getTracciamento().sizeOpenspcoopSorgenteDatiList();
  4156.                     ServletUtils.setDataElementCustomLabel(de, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SORGENTI_DATI, (long)totDs);
  4157.                 } else
  4158.                     ServletUtils.setDataElementCustomLabel(de, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SORGENTI_DATI);
  4159.                 dati.add(de);
  4160.             }
  4161.         }
  4162.        
  4163.     }

  4164.     public void addMessaggiDiagnosticiToDatiAsHidden(String severita, String severita_log4j, List<DataElement> dati) {
  4165.         DataElement de = new DataElement();
  4166.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA);
  4167.         de.setType(DataElementType.HIDDEN);
  4168.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA);
  4169.         de.setValue(severita);
  4170.         dati.add(de);

  4171.         de = new DataElement();
  4172.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA_LOG4J);
  4173.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA_LOG4J);
  4174.         de.setType(DataElementType.HIDDEN);
  4175.         de.setValue(severita_log4j);
  4176.         dati.add(de);
  4177.     }
  4178.        
  4179.     public void addConfigurazioneTracciamentoToDati(List<DataElement> dati) {
  4180.        
  4181.         DataElement de = new DataElement();
  4182.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_TRANSAZIONI);
  4183.         de.setType(DataElementType.TITLE);
  4184.         dati.add(de);
  4185.        
  4186.         de = new DataElement();
  4187.         de.setType(DataElementType.LINK);
  4188.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI,
  4189.                 new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE, ConfigurazioneCostanti.VALORE_PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE_TRACCIAMENTO_PA));
  4190.         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO_CONFIGURAZIONE_EROGAZIONI);
  4191.         dati.add(de);
  4192.        
  4193.         de = new DataElement();
  4194.         de.setType(DataElementType.LINK);
  4195.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI,
  4196.                 new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE, ConfigurazioneCostanti.VALORE_PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE_TRACCIAMENTO_PD));
  4197.         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO_CONFIGURAZIONE_FRUIZIONI);
  4198.         dati.add(de);
  4199.        
  4200.     }
  4201.    
  4202.     public void addMessaggiDiagnosticiToDati(String severita, String severita_log4j, Configurazione configurazione,
  4203.             List<DataElement> dati, Boolean contaListe) {
  4204.        
  4205.         this.addSeveritaMessaggiDiagnosticiToDati(severita, severita_log4j, dati);

  4206.         if (this.isModalitaAvanzata()) {
  4207.             if (this.confCore.isMsgDiagnosticiShowConfigurazioneCustomAppender()) {
  4208.                 DataElement de = new DataElement();
  4209.                 de.setType(DataElementType.LINK);
  4210.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_APPENDER_LIST);
  4211.                 if (contaListe!=null && contaListe.booleanValue()) {
  4212.                     int totAppender = 0;
  4213.                     if (configurazione.getMessaggiDiagnostici() != null)
  4214.                         totAppender =
  4215.                         configurazione.getMessaggiDiagnostici().sizeOpenspcoopAppenderList();
  4216.                     ServletUtils.setDataElementCustomLabel(de, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_APPENDER, (long)totAppender);
  4217.                 } else
  4218.                     ServletUtils.setDataElementCustomLabel(de, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_APPENDER);
  4219.                 dati.add(de);
  4220.             }
  4221.             if (this.confCore.isMsgDiagnosticiShowSorgentiDatiDatabase()) {
  4222.                 DataElement de = new DataElement();
  4223.                 de.setType(DataElementType.LINK);
  4224.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_DIAGNOSTICA_DATASOURCE_LIST);
  4225.                 if (contaListe!=null && contaListe.booleanValue()) {
  4226.                     int totDs = 0;
  4227.                     if (configurazione.getMessaggiDiagnostici() != null)
  4228.                         totDs =
  4229.                         configurazione.getMessaggiDiagnostici().sizeOpenspcoopSorgenteDatiList();
  4230.                     ServletUtils.setDataElementCustomLabel(de, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SORGENTI_DATI, (long)totDs);
  4231.                 } else
  4232.                     ServletUtils.setDataElementCustomLabel(de, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SORGENTI_DATI);
  4233.                 dati.add(de);
  4234.             }
  4235.         }
  4236.     }
  4237.    
  4238.     public List<DataElement> addConfigurazioneSistemaSelectListNodiCluster(List<DataElement> dati, String [] nodiSelezionati) throws Exception {
  4239.        
  4240.         DataElement de = new DataElement();
  4241.         de.setType(DataElementType.MULTI_SELECT);
  4242.         de.setValues(this.confCore.getJmxPdDAliases());
  4243.         List<String> labels = new ArrayList<>();
  4244.         for (String alias : this.confCore.getJmxPdDAliases()) {
  4245.             labels.add(this.confCore.getJmxPdDDescrizione(alias));
  4246.         }
  4247.         de.setLabels(labels);
  4248.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODI_CLUSTER);
  4249.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER);
  4250.         de.setSize(this.getSize());
  4251.         de.setPostBack(true);
  4252.         if(labels.size()>10) {
  4253.             de.setRows(10);
  4254.         }
  4255.         else {
  4256.             de.setRows(labels.size());
  4257.         }
  4258.         de.setSelezionati(nodiSelezionati);
  4259.         dati.add(de);
  4260.        
  4261.                
  4262.         boolean resetAllCaches = false;
  4263.         if(this.confCore.isVisualizzaLinkClearAllCachesRemoteCheckCacheStatus()) {
  4264.             for (String alias : this.confCore.getJmxPdDAliases()) {
  4265.                
  4266.                 List<String> caches = this.confCore.getJmxPdDCaches(alias);
  4267.                 if(caches!=null && caches.size()>0){
  4268.                     for (String cache : caches) {
  4269.                    
  4270.                         String stato = null;
  4271.                         try{
  4272.                             stato = this.confCore.getInvoker().readJMXAttribute(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4273.                                     cache,
  4274.                                     this.confCore.getJmxPdDCacheNomeAttributoCacheAbilitata(alias));
  4275.                             if(stato.equalsIgnoreCase("true")){
  4276.                                 stato = "abilitata";
  4277.                             }
  4278.                             else if(stato.equalsIgnoreCase("false")){
  4279.                                 stato = "disabilitata";
  4280.                             }
  4281.                             else{
  4282.                                 throw new DriverControlStationException("Stato ["+stato+"] sconosciuto");
  4283.                             }
  4284.                         }catch(Exception e){
  4285.                             this.logError("Errore durante la lettura dello stato della cache ["+cache+"](jmxResourcePdD): "+e.getMessage(),e);
  4286.                             stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4287.                         }
  4288.                        
  4289.                         if("abilitata".equals(stato)){
  4290.                             resetAllCaches = true;
  4291.                             break;
  4292.                         }
  4293.                     }
  4294.                 }
  4295.                 if(resetAllCaches) {
  4296.                     break;
  4297.                 }
  4298.             }
  4299.         }
  4300.         else {
  4301.             resetAllCaches = true;
  4302.         }
  4303.         if(resetAllCaches){
  4304.             de = new DataElement();
  4305.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD+"?"+
  4306.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_CACHE+"="+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_RESET_ALL_CACHES+
  4307.                     "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_METODO+"="+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_METODO_RESET_ALL_CACHE_ALL_NODES);
  4308.             de.setType(DataElementType.LINK);
  4309.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_RESET_ALL_CACHES);
  4310.             de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_RESET_ALL_NODES);
  4311.             de.setSize(this.getSize());
  4312.             dati.add(de);
  4313.            
  4314.             StringBuilder sb = new StringBuilder("");
  4315.             if(nodiSelezionati!=null && nodiSelezionati.length>0) {
  4316.                 for (int i = 0; i < nodiSelezionati.length; i++) {
  4317.                     sb.append("&");
  4318.                     sb.append(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODI_CLUSTER);
  4319.                     sb.append("=");
  4320.                     sb.append(nodiSelezionati[i]);
  4321.                 }
  4322.             }
  4323.             de = new DataElement();
  4324.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD+"?"+
  4325.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_CACHE+"="+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_RESET_SELECTED_CACHES+
  4326.                     "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_METODO+"="+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_METODO_RESET_ALL_CACHE_SELECTED_NODES+
  4327.                     sb.toString());
  4328.             de.setType(DataElementType.LINK);
  4329.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_RESET_SELECTED_CACHES);
  4330.             de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_RESET_SELECTED_NODES);
  4331.             de.setSize(this.getSize());
  4332.             dati.add(de);
  4333.            
  4334.              Map<String, List<String>> map = this.confCore.getJmxPdDGruppiAliases();
  4335.              if(map!=null && !map.isEmpty()) {
  4336.                  List<String> gruppi = new ArrayList<>();
  4337.                  for (String gruppo : map.keySet()) {
  4338.                      gruppi.add(gruppo);
  4339.                  }
  4340.                  Collections.sort(gruppi);
  4341.                  int indexGr = 0;
  4342.                  for (String gruppo : gruppi) {
  4343.                      
  4344.                      indexGr++;
  4345.                      
  4346.                      List<String> aliases = map.get(gruppo);
  4347.                      StringBuilder sbGruppi = new StringBuilder("");
  4348.                      if(aliases!=null && aliases.size()>0) {
  4349.                          for (int i = 0; i < aliases.size(); i++) {
  4350.                              sbGruppi.append("&");
  4351.                              sbGruppi.append(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODI_CLUSTER);
  4352.                              sbGruppi.append("=");
  4353.                              sbGruppi.append(aliases.get(i));
  4354.                          }
  4355.                          
  4356.                          de = new DataElement();
  4357.                          de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD+"?"+
  4358.                                  ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_CACHE+"="+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_RESET_SELECTED_CACHES+
  4359.                                  "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_METODO+"="+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_METODO_RESET_ALL_CACHE_SELECTED_NODES+
  4360.                                  sbGruppi.toString());
  4361.                          de.setType(DataElementType.LINK);
  4362.                          de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_RESET_SELECTED_CACHES+"__gr"+indexGr);
  4363.                          de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_RESET_GROUPES_NODES.replace(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_RESET_GROUPES_NODES_KEYWORD, gruppo));
  4364.                          de.setSize(this.getSize());
  4365.                          dati.add(de);
  4366.                      }
  4367.                      
  4368.                  }
  4369.              }
  4370.         }      
  4371.        
  4372.         return dati;
  4373.     }
  4374.    
  4375.     private void addInformazioneNonDisponibile(List<DataElement> dati, String label){
  4376.         DataElement de = newDataElementStyleRuntime();
  4377.         de.setLabel(label);
  4378.         de.setValue(ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE);
  4379.         de.setType(DataElementType.TEXT);
  4380.         de.setSize(this.getSize());
  4381.         dati.add(de);
  4382.     }
  4383.    
  4384.     private DataElement newDataElementStyleRuntime() {
  4385.         DataElement de = new DataElement();
  4386.         de.setLabelStyleClass(Costanti.LABEL_MEDIUM_CSS_CLASS);
  4387.         return de;
  4388.     }
  4389.    
  4390.     public List<DataElement> addConfigurazioneSistema(List<DataElement> dati, String alias) throws Exception {
  4391.    
  4392.        
  4393.        
  4394.         DataElement de = newDataElementStyleRuntime();
  4395.         de.setType(DataElementType.TITLE);
  4396.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_RUNTIME);
  4397.         dati.add(de);
  4398.                
  4399.         de = newDataElementStyleRuntime();
  4400.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER);
  4401.         de.setLabel(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER);
  4402.         de.setType(DataElementType.HIDDEN);
  4403.         de.setValue(alias);
  4404.         dati.add(de);
  4405.        
  4406.         de = newDataElementStyleRuntime();
  4407.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_EXPORT);
  4408.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_EXPORTER,
  4409.                 new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER,alias));
  4410.         de.setType(DataElementType.LINK);
  4411.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_EXPORT);
  4412.         de.setValue(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_EXPORT);
  4413.         de.setSize(this.getSize());
  4414.         dati.add(de);
  4415.        

  4416.         boolean resetAllCaches = false;
  4417.         List<String> caches = this.confCore.getJmxPdDCaches(alias);
  4418.         if(caches!=null && !caches.isEmpty()){
  4419.             for (String cache : caches) {
  4420.            
  4421.                 String stato = null;
  4422.                 try{
  4423.                     stato = this.confCore.getInvoker().readJMXAttribute(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4424.                             cache,
  4425.                             this.confCore.getJmxPdDCacheNomeAttributoCacheAbilitata(alias));
  4426.                     if(stato.equalsIgnoreCase("true")){
  4427.                         stato = "abilitata";
  4428.                     }
  4429.                     else if(stato.equalsIgnoreCase("false")){
  4430.                         stato = "disabilitata";
  4431.                     }
  4432.                     else{
  4433.                         throw new DriverControlStationException("Stato ["+stato+"] sconosciuto");
  4434.                     }
  4435.                 }catch(Exception e){
  4436.                     this.logError("Errore durante la lettura dello stato della cache ["+cache+"](jmxResourcePdD): "+e.getMessage(),e);
  4437.                     stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4438.                 }
  4439.                
  4440.                 if("abilitata".equals(stato)){
  4441.                     resetAllCaches = true;
  4442.                     break;
  4443.                 }
  4444.             }
  4445.         }
  4446.         if(resetAllCaches){
  4447.             de = newDataElementStyleRuntime();
  4448.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_RESET);
  4449.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD+"?"+
  4450.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER+"="+alias+
  4451.                     "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_CACHE+"="+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_RESET_ALL_CACHES+
  4452.                     "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_METODO+"="+this.confCore.getJmxPdDCacheNomeMetodoResetCache(alias));
  4453.             de.setType(DataElementType.LINK);
  4454.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_RESET_ALL_CACHES);
  4455.             de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_RESET);
  4456.             de.setSize(this.getSize());
  4457.             dati.add(de);
  4458.         }      
  4459.        

  4460.                
  4461.         de = newDataElementStyleRuntime();
  4462.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_GENERALI);
  4463.         de.setType(DataElementType.TITLE);
  4464.         dati.add(de);
  4465.        
  4466.         String versionePdD = null;
  4467.         try{
  4468.             versionePdD = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4469.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  4470.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoVersionePdD(alias));
  4471.             if(this.isErroreHttp(versionePdD, "versione della PdD")){
  4472.                 // e' un errore
  4473.                 versionePdD = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4474.             }
  4475.         }catch(Exception e){
  4476.             this.logError("Errore durante la lettura della versione della PdD (jmxResourcePdD): "+e.getMessage(),e);
  4477.             versionePdD = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4478.         }
  4479.         if(versionePdD!=null){
  4480.             versionePdD = StringEscapeUtils.escapeHtml(versionePdD);
  4481.         }
  4482.         de = newDataElementStyleRuntime();
  4483.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_VERSIONE_PDD);
  4484.         de.setValue(versionePdD);
  4485.         de.setType(DataElementType.TEXT);
  4486.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_VERSIONE_PDD);
  4487.         de.setSize(this.getSize());
  4488.         dati.add(de);

  4489.        
  4490.         String versioneBaseDati = null;
  4491.         try{
  4492.             versioneBaseDati = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4493.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  4494.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoVersioneBaseDati(alias));
  4495.             if(this.isErroreHttp(versioneBaseDati, "versione della base dati")){
  4496.                 // e' un errore
  4497.                 versioneBaseDati = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4498.             }
  4499.         }catch(Exception e){
  4500.             this.logError("Errore durante la lettura della versione della base dati (jmxResourcePdD): "+e.getMessage(),e);
  4501.             versioneBaseDati = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4502.         }
  4503.         if(versioneBaseDati!=null){
  4504.             versioneBaseDati = StringEscapeUtils.escapeHtml(versioneBaseDati);
  4505.         }
  4506.         de = newDataElementStyleRuntime();
  4507.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_VERSIONE_BASE_DATI);
  4508.         de.setValue(versioneBaseDati);
  4509.         de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  4510.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_VERSIONE_BASE_DATI);
  4511.         de.setRows(4);
  4512.         de.setCols(60);
  4513.         de.setSize(this.getSize());
  4514.         dati.add(de);
  4515.        
  4516.        
  4517.         String confDir = null;
  4518.         try{
  4519.             confDir = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4520.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  4521.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoDirectoryConfigurazione(alias));
  4522.             if(this.isErroreHttp(confDir, "directory di configurazione")){
  4523.                 // e' un errore
  4524.                 confDir = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4525.             }
  4526.         }catch(Exception e){
  4527.             this.logError("Errore durante la lettura della directory di configurazione (jmxResourcePdD): "+e.getMessage(),e);
  4528.             confDir = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4529.         }
  4530.         if(confDir!=null){
  4531.             confDir = StringEscapeUtils.escapeHtml(confDir);
  4532.         }
  4533.         de = newDataElementStyleRuntime();
  4534.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_DIRECTORY_CONFIGURAZIONE);
  4535.         de.setValue(confDir);
  4536.         de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  4537.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_DIRECTORY_CONFIGURAZIONE);
  4538.         de.setRows(4);
  4539.         de.setCols(60);
  4540.         de.setSize(this.getSize());
  4541.         dati.add(de);
  4542.        
  4543.        
  4544.         String vendorJava = null;
  4545.         try{
  4546.             vendorJava = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4547.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  4548.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoVendorJava(alias));
  4549.             if(this.isErroreHttp(vendorJava, "vendor di java")){
  4550.                 // e' un errore
  4551.                 vendorJava = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4552.             }
  4553.         }catch(Exception e){
  4554.             this.logError("Errore durante la lettura delle informazioni sul vendor di java (jmxResourcePdD): "+e.getMessage(),e);
  4555.             vendorJava = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4556.         }
  4557.         if(vendorJava!=null){
  4558.             vendorJava = StringEscapeUtils.escapeHtml(vendorJava);
  4559.         }
  4560.         de = newDataElementStyleRuntime();
  4561.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_VENDOR_JAVA);
  4562.         de.setValue(vendorJava);
  4563.         de.setType(DataElementType.TEXT);
  4564.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_VENDOR_JAVA);
  4565.         de.setSize(this.getSize());
  4566.         dati.add(de);
  4567.        
  4568.        
  4569.         String versioneJava = null;
  4570.         try{
  4571.             versioneJava = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4572.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  4573.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoVersioneJava(alias));
  4574.             if(this.isErroreHttp(versioneJava, "versione di java")){
  4575.                 // e' un errore
  4576.                 versioneJava = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4577.             }
  4578.         }catch(Exception e){
  4579.             this.logError("Errore durante la lettura della versione di java (jmxResourcePdD): "+e.getMessage(),e);
  4580.             versioneJava = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4581.         }
  4582.         if(versioneJava!=null){
  4583.             versioneJava = StringEscapeUtils.escapeHtml(versioneJava);
  4584.         }
  4585.         de = newDataElementStyleRuntime();
  4586.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_VERSIONE_JAVA);
  4587.         de.setValue(versioneJava);
  4588.         de.setType(DataElementType.TEXT);
  4589.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_VERSIONE_JAVA);
  4590.         de.setSize(this.getSize());
  4591.         dati.add(de);
  4592.        
  4593.        
  4594.        
  4595.        
  4596.         String messageFactory = null;
  4597.         try{
  4598.             messageFactory = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4599.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  4600.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoMessageFactory(alias));
  4601.             if(this.isErroreHttp(messageFactory, "message factory")){
  4602.                 // e' un errore
  4603.                 messageFactory = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4604.             }
  4605.         }catch(Exception e){
  4606.             this.logError("Errore durante la lettura della message factory (jmxResourcePdD): "+e.getMessage(),e);
  4607.             messageFactory = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  4608.         }
  4609.         /**if(messageFactory!=null){
  4610.             messageFactory = StringEscapeUtils.escapeHtml(messageFactory);
  4611.         }*/
  4612.         de = newDataElementStyleRuntime();
  4613.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_MESSAGE_FACTORY);
  4614.         de.setValue(messageFactory.trim().contains(" ") ? messageFactory.trim().replaceAll(" ", "\n") : messageFactory);
  4615.         de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  4616.         de.setRows(2);
  4617.         de.setCols(60);
  4618.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_MESSAGE_FACTORY);
  4619.         de.setSize(this.getSize());
  4620.         dati.add(de);
  4621.        
  4622.        
  4623.        
  4624.        
  4625.         de = newDataElementStyleRuntime();
  4626.         de.setType(DataElementType.TITLE);
  4627.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_STATO_SERVIZI);
  4628.         dati.add(de);
  4629.        
  4630.         try{
  4631.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4632.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaStatoServiziPdD(alias),
  4633.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoStatoServizioPortaDelegata(alias));
  4634.             boolean enable = CostantiConfigurazione.ABILITATO.getValue().equals(value);
  4635.            
  4636.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  4637.             de = newDataElementStyleRuntime();
  4638.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_SERVIZIO_PD);
  4639.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO_SERVIZIO_PD);
  4640.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4641.             de.setType(DataElementType.SELECT);
  4642.             de.setValues(tipoMsg);
  4643.             de.setSelected(v);
  4644.             de.setPostBack_viaPOST(true);
  4645.             dati.add(de);
  4646.            
  4647.         }catch(Exception e){
  4648.             this.logError("Errore durante la lettura delle informazioni sullo stato del servizio Porta Delegata (jmxResourcePdD): "+e.getMessage(),e);
  4649.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO_SERVIZIO_PD);
  4650.         }
  4651.        
  4652.         try{
  4653.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4654.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaStatoServiziPdD(alias),
  4655.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoStatoServizioPortaApplicativa(alias));
  4656.             boolean enable = CostantiConfigurazione.ABILITATO.getValue().equals(value);
  4657.            
  4658.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  4659.             de = newDataElementStyleRuntime();
  4660.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_SERVIZIO_PA);
  4661.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO_SERVIZIO_PA);
  4662.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4663.             de.setType(DataElementType.SELECT);
  4664.             de.setValues(tipoMsg);
  4665.             de.setSelected(v);
  4666.             de.setPostBack_viaPOST(true);
  4667.             dati.add(de);
  4668.            
  4669.         }catch(Exception e){
  4670.             this.logError("Errore durante la lettura delle informazioni sullo stato del servizio Porta Applicativa (jmxResourcePdD): "+e.getMessage(),e);
  4671.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO_SERVIZIO_PA);
  4672.         }
  4673.            
  4674.         try{
  4675.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4676.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaStatoServiziPdD(alias),
  4677.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoStatoServizioIntegrationManager(alias));
  4678.             boolean enable = CostantiConfigurazione.ABILITATO.getValue().equals(value);
  4679.            
  4680.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  4681.             de = newDataElementStyleRuntime();
  4682.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_STATO_SERVIZIO_IM);
  4683.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO_SERVIZIO_IM);
  4684.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4685.             de.setType(DataElementType.SELECT);
  4686.             de.setValues(tipoMsg);
  4687.             de.setSelected(v);
  4688.             de.setPostBack_viaPOST(true);
  4689.             dati.add(de);
  4690.            
  4691.         }catch(Exception e){
  4692.             this.logError("Errore durante la lettura delle informazioni sullo stato del servizio Integration Manager (jmxResourcePdD): "+e.getMessage(),e);
  4693.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_STATO_SERVIZIO_IM);
  4694.         }
  4695.        
  4696.        
  4697.        
  4698.        
  4699.        
  4700.         de = newDataElementStyleRuntime();
  4701.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_DIAGNOSTICA);
  4702.         de.setType(DataElementType.TITLE);
  4703.         dati.add(de);

  4704.         try{
  4705.             String livelloSeverita = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4706.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  4707.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoSeveritaDiagnostici(alias));
  4708.            
  4709.             String[] tipoMsg = { LogLevels.LIVELLO_OFF, LogLevels.LIVELLO_FATAL, LogLevels.LIVELLO_ERROR_PROTOCOL, LogLevels.LIVELLO_ERROR_INTEGRATION,
  4710.                     LogLevels.LIVELLO_INFO_PROTOCOL, LogLevels.LIVELLO_INFO_INTEGRATION,
  4711.                     LogLevels.LIVELLO_DEBUG_LOW, LogLevels.LIVELLO_DEBUG_MEDIUM, LogLevels.LIVELLO_DEBUG_HIGH,
  4712.                     LogLevels.LIVELLO_ALL};
  4713.             de = newDataElementStyleRuntime();
  4714.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA);
  4715.             de.setType(DataElementType.SELECT);
  4716.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA);
  4717.             de.setValues(tipoMsg);
  4718.             de.setSelected(livelloSeverita);
  4719.             de.setPostBack_viaPOST(true);
  4720.             dati.add(de);
  4721.            
  4722.         }catch(Exception e){
  4723.             this.logError("Errore durante la lettura delle informazioni sul livello dei diagnostici (jmxResourcePdD): "+e.getMessage(),e);
  4724.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA);
  4725.         }
  4726.        
  4727.         try{
  4728.             String livelloSeverita = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4729.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  4730.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoSeveritaDiagnosticiLog4j(alias));
  4731.            
  4732.             String[] tipoMsg = { LogLevels.LIVELLO_OFF, LogLevels.LIVELLO_FATAL, LogLevels.LIVELLO_ERROR_PROTOCOL, LogLevels.LIVELLO_ERROR_INTEGRATION,
  4733.                     LogLevels.LIVELLO_INFO_PROTOCOL, LogLevels.LIVELLO_INFO_INTEGRATION,
  4734.                     LogLevels.LIVELLO_DEBUG_LOW, LogLevels.LIVELLO_DEBUG_MEDIUM, LogLevels.LIVELLO_DEBUG_HIGH,
  4735.                     LogLevels.LIVELLO_ALL};
  4736.             de = newDataElementStyleRuntime();
  4737.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA_LOG4J);
  4738.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA_LOG4J);
  4739.             if(this.core.isVisualizzazioneConfigurazioneDiagnosticaLog4J()){
  4740.                 de.setType(DataElementType.SELECT);
  4741.                 de.setValues(tipoMsg);
  4742.                 de.setSelected(livelloSeverita);
  4743.                 de.setPostBack_viaPOST(true);
  4744.             }
  4745.             else{
  4746.                 de.setType(DataElementType.TEXT);
  4747.                 de.setValue(livelloSeverita);
  4748.             }
  4749.             dati.add(de);
  4750.            
  4751.         }catch(Exception e){
  4752.             this.logError("Errore durante la lettura delle informazioni sul livello dei diagnostici log4j (jmxResourcePdD): "+e.getMessage(),e);
  4753.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA_LOG4J);
  4754.         }
  4755.        
  4756.         try{
  4757.             String log4j_diagnostica = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4758.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  4759.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoLog4jDiagnostica(alias));
  4760.             boolean enable = "true".equals(log4j_diagnostica);
  4761.            
  4762.             de = newDataElementStyleRuntime();
  4763.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LOG4J_DIAGNOSTICA);
  4764.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DIAGNOSTICA_LABEL);
  4765.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DIAGNOSTICA_NOTE);
  4766.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4767.             de.setType(DataElementType.TEXT);
  4768.             de.setValue(v);
  4769.             dati.add(de);
  4770.            
  4771.         }catch(Exception e){
  4772.             this.logError("Errore durante la lettura delle informazioni sullo stato di log del file govway_diagnostici.log (jmxResourcePdD): "+e.getMessage(),e);
  4773.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DIAGNOSTICA_LABEL);
  4774.         }
  4775.        
  4776.         try{
  4777.             String log4j_openspcoop = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4778.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  4779.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoLog4jOpenspcoop(alias));
  4780.             boolean enable = "true".equals(log4j_openspcoop);
  4781.            
  4782.             de = newDataElementStyleRuntime();
  4783.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LOG4J_OPENSPCOOP);
  4784.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_OPENSPCOOP_LABEL);
  4785.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_OPENSPCOOP_NOTE);
  4786.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4787.             de.setType(DataElementType.TEXT);
  4788.             de.setValue(v);
  4789.             dati.add(de);
  4790.            
  4791.         }catch(Exception e){
  4792.             this.logError("Errore durante la lettura delle informazioni sullo stato di log del file govway.log (jmxResourcePdD): "+e.getMessage(),e);
  4793.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_OPENSPCOOP_LABEL);
  4794.         }
  4795.        
  4796.         try{
  4797.             String log4j_integrationManager = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4798.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  4799.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoLog4jIntegrationManager(alias));
  4800.             boolean enable = "true".equals(log4j_integrationManager);
  4801.            
  4802.             de = newDataElementStyleRuntime();
  4803.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LOG4J_INTEGRATION_MANAGER);
  4804.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_INTEGRATION_MANAGER_LABEL);
  4805.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_INTEGRATION_MANAGER_NOTE);
  4806.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4807.             de.setType(DataElementType.TEXT);
  4808.             de.setValue(v);
  4809.             dati.add(de);
  4810.            
  4811.         }catch(Exception e){
  4812.             this.logError("Errore durante la lettura delle informazioni sullo stato di log del file govway_integrationManager.log (jmxResourcePdD): "+e.getMessage(),e);
  4813.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_INTEGRATION_MANAGER_LABEL);
  4814.         }

  4815.        
  4816.        
  4817.        
  4818.        
  4819.        
  4820.         de = newDataElementStyleRuntime();
  4821.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_TRACCIAMENTO);
  4822.         de.setType(DataElementType.TITLE);
  4823.         dati.add(de);

  4824.         try{
  4825.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4826.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  4827.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTracciamento(alias));
  4828.             boolean enable = "true".equals(value);
  4829.            
  4830.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  4831.             de = newDataElementStyleRuntime();
  4832.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_TRACCE);
  4833.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_TRACCE);
  4834.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4835.             if(this.isModalitaAvanzata()) {
  4836.                 if(this.isModalitaCompleta()){
  4837.                     de.setType(DataElementType.SELECT);
  4838.                     de.setValues(tipoMsg);
  4839.                     de.setSelected(v);
  4840.                     de.setPostBack_viaPOST(true);
  4841.                 }
  4842.                 else{
  4843.                     de.setType(DataElementType.TEXT);
  4844.                     de.setValue(v);
  4845.                 }
  4846.             }
  4847.             else {
  4848.                 de.setType(DataElementType.HIDDEN);
  4849.                 de.setValue(v);
  4850.             }
  4851.             dati.add(de);
  4852.            
  4853.         }catch(Exception e){
  4854.             this.logError("Errore durante la lettura delle informazioni sul tracciamento (jmxResourcePdD): "+e.getMessage(),e);
  4855.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_TRACCE);
  4856.         }
  4857.            
  4858.         try{
  4859.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4860.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  4861.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoDumpPA(alias));
  4862.             boolean enable = "true".equals(value);
  4863.            
  4864.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  4865.             de = newDataElementStyleRuntime();
  4866.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PA);
  4867.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_CONNETTORE_PA_LABEL);
  4868.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_CONNETTORE_PA_NOTE);
  4869.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4870.             de.setType(DataElementType.SELECT);
  4871.             de.setValues(tipoMsg);
  4872.             de.setSelected(v);
  4873.             de.setPostBack_viaPOST(true);
  4874.             dati.add(de);
  4875.            
  4876.         }catch(Exception e){
  4877.             this.logError("Errore durante la lettura delle informazioni sul dump binario sulla Porta Applicativa (jmxResourcePdD): "+e.getMessage(),e);
  4878.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_CONNETTORE_PA_LABEL);
  4879.         }
  4880.        
  4881.         try{
  4882.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4883.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  4884.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoDumpPD(alias));
  4885.             boolean enable = "true".equals(value);
  4886.            
  4887.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  4888.             de = newDataElementStyleRuntime();
  4889.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PD);
  4890.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_CONNETTORE_PD_LABEL);
  4891.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_CONNETTORE_PD_NOTE);
  4892.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4893.             de.setType(DataElementType.SELECT);
  4894.             de.setValues(tipoMsg);
  4895.             de.setSelected(v);
  4896.             de.setPostBack_viaPOST(true);
  4897.             dati.add(de);
  4898.            
  4899.         }catch(Exception e){
  4900.             this.logError("Errore durante la lettura delle informazioni sul dump binario sulla Porta Delegata (jmxResourcePdD): "+e.getMessage(),e);
  4901.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_CONNETTORE_PD_LABEL);
  4902.         }
  4903.                    
  4904.         try{
  4905.             String log4j_tracciamento = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4906.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  4907.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoLog4jTracciamento(alias));
  4908.             boolean enable = "true".equals(log4j_tracciamento);
  4909.            
  4910.             de = newDataElementStyleRuntime();
  4911.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LOG4J_TRACCIAMENTO);
  4912.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_TRACCIAMENTO_LABEL);
  4913.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_TRACCIAMENTO_NOTE);
  4914.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4915.             de.setType(DataElementType.TEXT);
  4916.             de.setValue(v);
  4917.             dati.add(de);
  4918.            
  4919.         }catch(Exception e){
  4920.             this.logError("Errore durante la lettura delle informazioni sullo stato di log del file govway_tracciamento.log (jmxResourcePdD): "+e.getMessage(),e);
  4921.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_TRACCIAMENTO_LABEL);
  4922.         }
  4923.        
  4924.         try{
  4925.             String log4j_dump = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4926.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  4927.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoLog4jDump(alias));
  4928.             boolean enable = "true".equals(log4j_dump);
  4929.            
  4930.             de = newDataElementStyleRuntime();
  4931.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP);
  4932.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_LABEL);
  4933.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_NOTE);
  4934.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4935.             de.setType(DataElementType.TEXT);
  4936.             de.setValue(v);
  4937.             dati.add(de);
  4938.            
  4939.         }catch(Exception e){
  4940.             this.logError("Errore durante la lettura delle informazioni sullo stato di log del file govway_dump.log (jmxResourcePdD): "+e.getMessage(),e);
  4941.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LOG4J_DUMP_LABEL);
  4942.         }
  4943.        
  4944.         try{
  4945.             String fileTraceGovWayState = this.confCore.getInvoker().invokeJMXMethod(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  4946.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  4947.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoGetFileTrace(alias));
  4948.             FileTraceGovWayState stateFileTrace = FileTraceGovWayState.toConfig(fileTraceGovWayState,true);
  4949.             boolean fileTraceEnabled = stateFileTrace!=null && stateFileTrace.isEnabled();
  4950.             if(fileTraceEnabled) {
  4951.                 de = newDataElementStyleRuntime();
  4952.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_FILE_TRACE_LABEL);
  4953.                 de.setType(DataElementType.SUBTITLE);
  4954.                 dati.add(de);
  4955.             }
  4956.            
  4957.             de = newDataElementStyleRuntime();
  4958.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_FILE_TRACE);
  4959.             if(fileTraceEnabled) {
  4960.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_FILE_TRACE_STATO_LABEL);
  4961.             }
  4962.             else {
  4963.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_FILE_TRACE_LABEL);
  4964.             }
  4965.             String v = fileTraceEnabled ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  4966.             de.setType(DataElementType.TEXT);
  4967.             de.setValue(v);
  4968.             dati.add(de);
  4969.            
  4970.             if(fileTraceEnabled) {
  4971.                
  4972.                 de = newDataElementStyleRuntime();
  4973.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_FILE_TRACE_CONFIG);
  4974.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_FILE_TRACE_CONFIGURAZIONE_LABEL);
  4975.                 de.setType(DataElementType.TEXT);
  4976.                 de.setValue(stateFileTrace.getPath());
  4977.                 dati.add(de);
  4978.                
  4979.                 String[] valori = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  4980.                 String[] label = { ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_FILE_TRACE_CONFIGURAZIONE_NOTE, stateFileTrace.getLastModified() };
  4981.                
  4982.                 de = newDataElementStyleRuntime();
  4983.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_FILE_TRACE_UPDATE);
  4984.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_FILE_TRACE_LAST_UPDATE_LABEL);
  4985.                 de.setType(DataElementType.SELECT);
  4986.                 de.setValues(valori);
  4987.                 de.setLabels(label);
  4988.                 de.setSelected(CostantiConfigurazione.DISABILITATO.getValue());
  4989.                 de.setPostBack_viaPOST(true);
  4990.                 dati.add(de);
  4991.                
  4992.             }
  4993.        
  4994.         }catch(Exception e){
  4995.             this.logError("Errore durante la lettura delle informazioni sul FileTrace (jmxResourcePdD): "+e.getMessage(),e);
  4996.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_FILE_TRACE_LABEL);
  4997.         }
  4998.        
  4999.        
  5000.        
  5001.        
  5002.        
  5003.         de = newDataElementStyleRuntime();
  5004.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR);
  5005.         de.setType(DataElementType.TITLE);
  5006.         dati.add(de);
  5007.        
  5008.         de = newDataElementStyleRuntime();
  5009.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_TYPE);
  5010.         de.setType(DataElementType.SUBTITLE);
  5011.         dati.add(de);
  5012.        
  5013.         try{
  5014.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5015.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  5016.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTransactionSpecificErrorTypeInternalRequestError(alias));
  5017.             boolean enable = "true".equals(value);
  5018.            
  5019.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  5020.             de = newDataElementStyleRuntime();
  5021.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_REQUEST);
  5022.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_REQUEST);
  5023.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  5024.             de.setType(DataElementType.SELECT);
  5025.             de.setValues(tipoMsg);
  5026.             String[] labels = { ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_REQUEST_ABILITATO,
  5027.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_REQUEST_DISABILITATO };
  5028.             de.setLabels(labels);
  5029.             de.setSelected(v);
  5030.             de.setPostBack_viaPOST(true);
  5031.             dati.add(de);
  5032.            
  5033.         }catch(Exception e){
  5034.             String tipo = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_TYPE+" ("+
  5035.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_REQUEST+")";
  5036.             this.logError("Errore durante la lettura delle informazioni (jmxResourcePdD) ["+tipo+"]: "+e.getMessage(),e);
  5037.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_REQUEST);
  5038.         }
  5039.        
  5040.         try{
  5041.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5042.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  5043.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTransactionSpecificErrorTypeBadResponse(alias));
  5044.             String value2 = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5045.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  5046.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTransactionSpecificErrorTypeInternalResponseError(alias));
  5047.             boolean enable = "true".equals(value) && "true".equals(value2);
  5048.            
  5049.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  5050.             de = newDataElementStyleRuntime();
  5051.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_RESPONSE);
  5052.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_RESPONSE);
  5053.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  5054.             de.setType(DataElementType.SELECT);
  5055.             de.setValues(tipoMsg);
  5056.             String[] labels = { ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_RESPONSE_ABILITATO,
  5057.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_RESPONSE_DISABILITATO };
  5058.             de.setLabels(labels);
  5059.             de.setSelected(v);
  5060.             de.setPostBack_viaPOST(true);
  5061.             dati.add(de);
  5062.            
  5063.         }catch(Exception e){
  5064.             String tipo = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_TYPE+" ("+
  5065.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_RESPONSE+")";
  5066.             this.logError("Errore durante la lettura delle informazioni (jmxResourcePdD) ["+tipo+"]: "+e.getMessage(),e);
  5067.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_PROCESS_RESPONSE);
  5068.         }
  5069.        
  5070.         try{
  5071.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5072.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  5073.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTransactionSpecificErrorTypeInternalError(alias));
  5074.             boolean enable = "true".equals(value);
  5075.            
  5076.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  5077.             de = newDataElementStyleRuntime();
  5078.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_INTERNAL_ERROR);
  5079.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_INTERNAL_ERROR);
  5080.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  5081.             de.setType(DataElementType.SELECT);
  5082.             de.setValues(tipoMsg);
  5083.             String[] labels = { ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_INTERNAL_ERROR_ABILITATO,
  5084.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_INTERNAL_ERROR_DISABILITATO };
  5085.             de.setLabels(labels);
  5086.             de.setSelected(v);
  5087.             de.setPostBack_viaPOST(true);
  5088.             dati.add(de);
  5089.            
  5090.         }catch(Exception e){
  5091.             String tipo = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_TYPE+" ("+
  5092.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_INTERNAL_ERROR+")";
  5093.             this.logError("Errore durante la lettura delle informazioni (jmxResourcePdD) ["+tipo+"]: "+e.getMessage(),e);
  5094.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_TYPE_INTERNAL_ERROR);
  5095.         }
  5096.        
  5097.         de = newDataElementStyleRuntime();
  5098.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_STATUS);
  5099.         de.setType(DataElementType.SUBTITLE);
  5100.         dati.add(de);
  5101.        
  5102.         try{
  5103.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5104.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  5105.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTransactionErrorStatusCode(alias));
  5106.             boolean enable = "true".equals(value);
  5107.            
  5108.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  5109.             de = newDataElementStyleRuntime();
  5110.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_STATUS_CODE);
  5111.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_STATUS_CODE);
  5112.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  5113.             de.setType(DataElementType.SELECT);
  5114.             de.setValues(tipoMsg);
  5115.             de.setSelected(v);
  5116.             de.setPostBack_viaPOST(true);
  5117.             dati.add(de);
  5118.            
  5119.         }catch(Exception e){
  5120.             String tipo = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_STATUS+" ("+
  5121.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_STATUS_CODE+")";
  5122.             this.logError("Errore durante la lettura delle informazioni (jmxResourcePdD) ["+tipo+"]: "+e.getMessage(),e);
  5123.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_STATUS_CODE);
  5124.         }
  5125.        
  5126.         try{
  5127.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5128.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  5129.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTransactionErrorUseStatusCodeAsFaultCode(alias));
  5130.             boolean enable = "true".equals(value);
  5131.            
  5132.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  5133.             de = newDataElementStyleRuntime();
  5134.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SOAP_USE_STATUS_CODE_AS_SOAP_FAULT);
  5135.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SOAP_USE_STATUS_CODE_AS_SOAP_FAULT);
  5136.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  5137.             de.setType(DataElementType.SELECT);
  5138.             de.setValues(tipoMsg);
  5139.             de.setSelected(v);
  5140.             de.setPostBack_viaPOST(true);
  5141.             dati.add(de);
  5142.            
  5143.         }catch(Exception e){
  5144.             String tipo = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_STATUS+" ("+
  5145.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SOAP_USE_STATUS_CODE_AS_SOAP_FAULT+")";
  5146.             this.logError("Errore durante la lettura delle informazioni (jmxResourcePdD) ["+tipo+"]: "+e.getMessage(),e);
  5147.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SOAP_USE_STATUS_CODE_AS_SOAP_FAULT);
  5148.         }
  5149.        
  5150.         de = newDataElementStyleRuntime();
  5151.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_DETAILS);
  5152.         de.setType(DataElementType.SUBTITLE);
  5153.         dati.add(de);
  5154.        
  5155.         try{
  5156.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5157.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  5158.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTransactionSpecificErrorDetails(alias));
  5159.             boolean enable = "true".equals(value);
  5160.            
  5161.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  5162.             de = newDataElementStyleRuntime();
  5163.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_DETAILS);
  5164.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_DETAILS);
  5165.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  5166.             de.setType(DataElementType.SELECT);
  5167.             de.setValues(tipoMsg);
  5168.             de.setSelected(v);
  5169.             de.setPostBack_viaPOST(true);
  5170.             dati.add(de);
  5171.            
  5172.         }catch(Exception e){
  5173.             String tipo = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_DETAILS+" ("+
  5174.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_DETAILS+")";
  5175.             this.logError("Errore durante la lettura delle informazioni (jmxResourcePdD) ["+tipo+"]: "+e.getMessage(),e);
  5176.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SPECIFIC_ERROR_DETAILS);
  5177.         }
  5178.        
  5179.         de = newDataElementStyleRuntime();
  5180.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_INSTANCE);
  5181.         de.setType(DataElementType.SUBTITLE);
  5182.         dati.add(de);
  5183.        
  5184.         try{
  5185.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5186.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  5187.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTransactionErrorInstanceId(alias));
  5188.             boolean enable = "true".equals(value);
  5189.            
  5190.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  5191.             de = newDataElementStyleRuntime();
  5192.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_INSTANCE_ID);
  5193.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_INSTANCE_ID);
  5194.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  5195.             de.setType(DataElementType.SELECT);
  5196.             de.setValues(tipoMsg);
  5197.             de.setSelected(v);
  5198.             de.setPostBack_viaPOST(true);
  5199.             dati.add(de);
  5200.            
  5201.         }catch(Exception e){
  5202.             String tipo = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_INSTANCE+" ("+
  5203.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_INSTANCE_ID+")";
  5204.             this.logError("Errore durante la lettura delle informazioni (jmxResourcePdD) ["+tipo+"]: "+e.getMessage(),e);
  5205.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_INSTANCE_ID);
  5206.         }
  5207.        
  5208.         de = newDataElementStyleRuntime();
  5209.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SOAP_GENERATE_HTTP);
  5210.         de.setType(DataElementType.SUBTITLE);
  5211.         dati.add(de);
  5212.        
  5213.         try{
  5214.             String value = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5215.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  5216.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTransactionErrorGenerateHttpHeaderGovWayCode(alias));
  5217.             boolean enable = "true".equals(value);
  5218.            
  5219.             String[] tipoMsg = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  5220.             de = newDataElementStyleRuntime();
  5221.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SOAP_GENERATE_HTTP_CODE);
  5222.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SOAP_GENERATE_HTTP_CODE);
  5223.             String v = enable ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue();
  5224.             de.setType(DataElementType.SELECT);
  5225.             de.setValues(tipoMsg);
  5226.             de.setSelected(v);
  5227.             de.setPostBack_viaPOST(true);
  5228.             dati.add(de);
  5229.            
  5230.         }catch(Exception e){
  5231.             String tipo = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SOAP_GENERATE_HTTP+" ("+
  5232.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SOAP_GENERATE_HTTP_CODE+")";
  5233.             this.logError("Errore durante la lettura delle informazioni (jmxResourcePdD) ["+tipo+"]: "+e.getMessage(),e);
  5234.             addInformazioneNonDisponibile(dati, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSACTION_ERROR_SOAP_GENERATE_HTTP_CODE);
  5235.         }
  5236.        
  5237.        
  5238.        
  5239.        
  5240.         de = newDataElementStyleRuntime();
  5241.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_DATABASE);
  5242.         de.setType(DataElementType.TITLE);
  5243.         dati.add(de);
  5244.        
  5245.         String [] infoDatabase = null;
  5246.         try{
  5247.             String tmp = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5248.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  5249.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoInformazioniDatabase(alias));
  5250.             if(this.isErroreHttp(tmp, "informazioni sul database")){
  5251.                 // e' un errore
  5252.                 tmp = null;
  5253.             }
  5254.             infoDatabase = tmp!=null ? tmp.split("\n") : null;
  5255.         }catch(Exception e){
  5256.             this.logError("Errore durante la lettura delle informazioni sul database (jmxResourcePdD): "+e.getMessage(),e);
  5257.         }
  5258.         if(infoDatabase==null || infoDatabase.length<=0){
  5259.             addInformazioneNonDisponibile(dati, "");
  5260.         }
  5261.         else{
  5262.             for (int i = 0; i < infoDatabase.length; i++) {
  5263.                
  5264.                 try{
  5265.                     String label = infoDatabase[i];
  5266.                     String value = "";
  5267.                     if(infoDatabase[i].contains(":")){
  5268.                         label = infoDatabase[i].split(":")[0];
  5269.                         value = infoDatabase[i].split(":")[1];
  5270.                     }
  5271.                    
  5272.                     de = newDataElementStyleRuntime();
  5273.                     de.setLabel(label);
  5274.                     if(value!=null){
  5275.                         value = StringEscapeUtils.escapeHtml(value);
  5276.                     }
  5277.                     de.setValue(value);
  5278.                     de.setType(DataElementType.TEXT);
  5279.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_DATABASE+i);
  5280.                     de.setSize(this.getSize());
  5281.                     dati.add(de);
  5282.                 }catch(Exception e){
  5283.                     this.logError("Errore durante la lettura delle informazioni sul database (jmxResourcePdD): "+e.getMessage(),e);
  5284.                 }
  5285.             }
  5286.         }
  5287.        
  5288.         HashMap<String, String> infoConnessioneAltriDB = null;
  5289.         HashMap<String, String> statoConnessioniAltriDB = null;
  5290.         try{
  5291.             int numeroDatasource = 0;
  5292.             try{
  5293.                 String stato = this.confCore.getInvoker().readJMXAttribute(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5294.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaDatasourceGW(alias),
  5295.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoNumeroDatasourceGW(alias));
  5296.                 if(stato!=null && !"".equals(stato)) {
  5297.                     if(this.isErroreHttp(stato, "stato delle connessioni verso altri database")){
  5298.                         // e' un errore
  5299.                         throw new DriverControlStationException(stato);
  5300.                     }
  5301.                     numeroDatasource = Integer.valueOf(stato);
  5302.                 }
  5303.             }catch(Exception e){
  5304.                 ControlStationCore.logDebug("Numero di datasource attivi non ottenibili: "+e.getMessage());
  5305.             }
  5306.             if(numeroDatasource>0) {
  5307.                 String nomiDatasource = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5308.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaDatasourceGW(alias),
  5309.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoGetDatasourcesGW(alias));
  5310.                 if(nomiDatasource!=null && !"".equals(nomiDatasource)) {
  5311.                     if(this.isErroreHttp(nomiDatasource, "stato delle connessioni verso altri database")){
  5312.                         // e' un errore
  5313.                         throw new DriverControlStationException(nomiDatasource);
  5314.                     }
  5315.                     /* Esempio:
  5316.                      * 3 datasource allocati:
  5317.     (2020-01-23_15:40:22.391) idDatasource:88c4db87-07a5-4fa6-95a5-e6caf4c21a7f jndiName:org.govway.datasource.tracciamento ConnessioniAttive:0
  5318.     (2020-01-23_15:40:22.396) idDatasource:bae6582a-659b-4b70-bc9c-aca3570b45af jndiName:org.govway.datasource.statistiche ConnessioniAttive:0
  5319.     (2020-01-23_15:40:22.627) idDatasource:4ff843af-94d6-4506-8ecf-aac52bcb3525 jndiName:org.govway.datasource.console ConnessioniAttive:0
  5320.                      **/
  5321.                     String [] lines = nomiDatasource.split("\n");
  5322.                     if(lines!=null && lines.length>0) {
  5323.                         for (String line : lines) {
  5324.                             if(line.startsWith("(")) {
  5325.                                 String [] tmp = line.split(" ");
  5326.                                 if(tmp!=null && tmp.length>3) {
  5327.                                     String nomeDS = tmp[2]+" "+tmp[1];
  5328.                                     try{
  5329.                                         // uuid
  5330.                                         //String paramIdentificazioneDataSource = tmp[1].split(":")[1];
  5331.                                         // jndi
  5332.                                         //String paramIdentificazioneDataSource = tmp[2].split(":")[1];
  5333.                                         int indexOf_paramIdentificazioneDataSource = tmp[2].indexOf(":");
  5334.                                         String paramIdentificazioneDataSource = tmp[2].substring(indexOf_paramIdentificazioneDataSource+1, tmp[2].length());
  5335.                                        
  5336.                                         String statoInfo = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5337.                                                 this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaDatasourceGW(alias),
  5338.                                                 this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoGetInformazioniDatabaseDatasourcesGW(alias),
  5339.                                                 paramIdentificazioneDataSource);
  5340.                                         if(infoConnessioneAltriDB==null) {
  5341.                                             infoConnessioneAltriDB = new HashMap<>();
  5342.                                         }
  5343.                                         infoConnessioneAltriDB.put(nomeDS,statoInfo);
  5344.                                        
  5345.                                         if(!this.confCore.isClusterAsyncUpdate()) {
  5346.                                             String statoDB = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5347.                                                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaDatasourceGW(alias),
  5348.                                                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoGetUsedConnectionsDatasourcesGW(alias),
  5349.                                                     paramIdentificazioneDataSource);
  5350.                                             if(this.isErroreHttp(statoDB, "stato delle connessioni verso database "+nomeDS)){
  5351.                                                 // e' un errore
  5352.                                                 throw new DriverControlStationException(statoDB);
  5353.                                             }
  5354.                                             if(statoConnessioniAltriDB==null) {
  5355.                                                 statoConnessioniAltriDB = new HashMap<>();
  5356.                                             }
  5357.                                             statoConnessioniAltriDB.put(nomeDS,statoDB);
  5358.                                         }
  5359.                                        
  5360.                                     }catch(Exception e){
  5361.                                         ControlStationCore.logError("Errore durante la lettura delle informazioni verso il database "+nomeDS+" (jmxResourcePdD): "+e.getMessage(),e);
  5362.                                        
  5363.                                         if(infoConnessioneAltriDB==null) {
  5364.                                             infoConnessioneAltriDB = new HashMap<>();
  5365.                                         }
  5366.                                         infoConnessioneAltriDB.put(nomeDS,ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE);
  5367.                                        
  5368.                                         if(!this.confCore.isClusterAsyncUpdate()) {
  5369.                                             if(statoConnessioniAltriDB==null) {
  5370.                                                 statoConnessioniAltriDB = new HashMap<>();
  5371.                                             }
  5372.                                             statoConnessioniAltriDB.put(nomeDS,ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE);
  5373.                                         }
  5374.                                     }      
  5375.                                 }
  5376.                             }
  5377.                         }
  5378.                     }
  5379.                 }
  5380.             }
  5381.         }catch(Exception e){
  5382.             ControlStationCore.logError("Errore durante la lettura delle informazioni verso gli altri database (jmxResourcePdD): "+e.getMessage(),e);
  5383.            
  5384.             if(infoConnessioneAltriDB==null) {
  5385.                 infoConnessioneAltriDB = new HashMap<>();
  5386.             }
  5387.             infoConnessioneAltriDB.put("GovWayDatasources",ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE);
  5388.            
  5389.             if(!this.confCore.isClusterAsyncUpdate()) {
  5390.                 if(statoConnessioniAltriDB==null) {
  5391.                     statoConnessioniAltriDB = new HashMap<>();
  5392.                 }
  5393.                 statoConnessioniAltriDB.put("GovWayDatasources",ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE);
  5394.             }
  5395.         }
  5396.        
  5397.         if(infoConnessioneAltriDB!=null && infoConnessioneAltriDB.size()>0) {
  5398.             Iterator<String> it = infoConnessioneAltriDB.keySet().iterator();
  5399.             int index = 0;
  5400.             while (it.hasNext()) {
  5401.                 String idAltroDB = (String) it.next();
  5402.                 String infoConnessioneAltroDB = infoConnessioneAltriDB.get(idAltroDB);
  5403.                
  5404.                 de = newDataElementStyleRuntime();
  5405.                 de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_DATABASE+" "+idAltroDB.split(" ")[0]);
  5406.                 de.setType(DataElementType.TITLE);
  5407.                 dati.add(de);
  5408.                
  5409.                 String [] infoConnessioneDatabase = infoConnessioneAltroDB.split("\n");
  5410.                
  5411.                 if(infoConnessioneDatabase==null || infoConnessioneDatabase.length<=0){
  5412.                     addInformazioneNonDisponibile(dati, "");
  5413.                 }
  5414.                 else{
  5415.                     for (int i = 0; i < infoConnessioneDatabase.length; i++) {
  5416.                        
  5417.                         try{
  5418.                             String label = infoConnessioneDatabase[i];
  5419.                             String value = "";
  5420.                             if(infoConnessioneDatabase[i].contains(":")){
  5421.                                 label = infoConnessioneDatabase[i].split(":")[0];
  5422.                                 value = infoConnessioneDatabase[i].split(":")[1];
  5423.                             }
  5424.                            
  5425.                             de = newDataElementStyleRuntime();
  5426.                             de.setLabel(label);
  5427.                             if(value!=null){
  5428.                                 value = StringEscapeUtils.escapeHtml(value);
  5429.                             }
  5430.                             de.setValue(value);
  5431.                             de.setType(DataElementType.TEXT);
  5432.                             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_DATABASE+"_db"+index+"_"+i);
  5433.                             de.setSize(this.getSize());
  5434.                             dati.add(de);
  5435.                         }catch(Exception e){
  5436.                             this.logError("Errore durante la lettura delle informazioni sul database (jmxResourcePdD): "+e.getMessage(),e);
  5437.                         }
  5438.                     }
  5439.                 }
  5440.                
  5441.                 index++;
  5442.             }
  5443.         }
  5444.        
  5445.        
  5446.        
  5447.        
  5448.         de = newDataElementStyleRuntime();
  5449.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_SSL);
  5450.         de.setType(DataElementType.TITLE);
  5451.         dati.add(de);
  5452.        
  5453.         String [] infoSSL = null;
  5454.         try{
  5455.             String tmp = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5456.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  5457.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoInformazioniSSL(alias));
  5458.             if(this.isErroreHttp(tmp, "informazioni SSL")){
  5459.                 // e' un errore
  5460.                 tmp = null;
  5461.             }
  5462.             infoSSL = tmp!=null ? tmp.split("\n") : null;
  5463.         }catch(Exception e){
  5464.             this.logError("Errore durante la lettura delle informazioni SSL (jmxResourcePdD): "+e.getMessage(),e);
  5465.         }
  5466.         if(infoSSL==null || infoSSL.length<=0){
  5467.             addInformazioneNonDisponibile(dati, "");
  5468.         }
  5469.         else{
  5470.             for (int i = 0; i < infoSSL.length; i++) {
  5471.                
  5472.                 try{
  5473.                     String label = infoSSL[i];
  5474.                     String value = "";
  5475.                     if(infoSSL[i].contains(":")){
  5476.                         label = infoSSL[i].split(":")[0];
  5477.                         value = infoSSL[i].split(":")[1];
  5478.                     }
  5479.                    
  5480.                     de = newDataElementStyleRuntime();
  5481.                     de.setLabel(label);
  5482.                     if(value!=null){
  5483.                         value = StringEscapeUtils.escapeHtml(value);
  5484.                     }
  5485.                     de.setValue(value);
  5486.                     de.setType(DataElementType.TEXT);
  5487.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_SSL+i);
  5488.                     de.setSize(this.getSize());
  5489.                     dati.add(de);
  5490.                 }catch(Exception e){
  5491.                     this.logError("Errore durante la lettura delle informazioni SSL (jmxResourcePdD): "+e.getMessage(),e);
  5492.                 }
  5493.             }
  5494.         }
  5495.        
  5496.        
  5497.        
  5498.         if(this.core.isJmxPdD_configurazioneSistemaShowInformazioniCryptographyKeyLength()){
  5499.        
  5500.             de = newDataElementStyleRuntime();
  5501.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_CRYPTOGRAPHY_KEY_LENGTH);
  5502.             de.setType(DataElementType.TITLE);
  5503.             dati.add(de);
  5504.            
  5505.             String [] infoCryptoKeyLength = null;
  5506.             try{
  5507.                 String tmp = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5508.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  5509.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoInformazioniCryptographyKeyLength(alias));
  5510.                 if(this.isErroreHttp(tmp, "informazioni CryptographyKeyLength")){
  5511.                     // e' un errore
  5512.                     tmp = null;
  5513.                 }
  5514.                 infoCryptoKeyLength = tmp!=null ? tmp.split("\n") : null;
  5515.             }catch(Exception e){
  5516.                 this.logError("Errore durante la lettura delle informazioni sulla lunghezza delle chiavi di cifratura (jmxResourcePdD): "+e.getMessage(),e);
  5517.             }
  5518.             if(infoCryptoKeyLength==null || infoCryptoKeyLength.length<=0){
  5519.                 addInformazioneNonDisponibile(dati, "");
  5520.             }
  5521.             else{
  5522.                 for (int i = 0; i < infoCryptoKeyLength.length; i++) {
  5523.                    
  5524.                     try{
  5525.                         String label = infoCryptoKeyLength[i];
  5526.                         String value = "";
  5527.                         if(infoCryptoKeyLength[i].contains(":")){
  5528.                             label = infoCryptoKeyLength[i].split(":")[0];
  5529.                             value = infoCryptoKeyLength[i].split(":")[1];
  5530.                         }
  5531.                        
  5532.                         de = newDataElementStyleRuntime();
  5533.                         de.setLabel(label);
  5534.                         if(value!=null){
  5535.                             value = StringEscapeUtils.escapeHtml(value);
  5536.                         }
  5537.                         de.setValue(value);
  5538.                         de.setType(DataElementType.TEXT);
  5539.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_CRYPTOGRAPHY_KEY_LENGTH+i);
  5540.                         de.setSize(this.getSize());
  5541.                         dati.add(de);
  5542.                     }catch(Exception e){
  5543.                         this.logError("Errore durante la lettura delle informazioni sulla lunghezza delle chiavi di cifratura (jmxResourcePdD): "+e.getMessage(),e);
  5544.                     }
  5545.                 }
  5546.             }
  5547.         }
  5548.        
  5549.        
  5550.        
  5551.        
  5552.        
  5553.        
  5554.        
  5555.        
  5556.        
  5557.        

  5558.         de = newDataElementStyleRuntime();
  5559.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_CHARSET);
  5560.         de.setType(DataElementType.TITLE);
  5561.         dati.add(de);
  5562.        
  5563.         String [] infoCharset = null;
  5564.         try{
  5565.             String tmp = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5566.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  5567.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoInformazioniCharset(alias));
  5568.             if(this.isErroreHttp(tmp, "informazioni Charset")){
  5569.                 // e' un errore
  5570.                 tmp = null;
  5571.             }
  5572.             infoCharset = tmp!=null ? tmp.split("\n") : null;
  5573.         }catch(Exception e){
  5574.             this.logError("Errore durante la lettura delle informazioni sull'internazionalizzazione (jmxResourcePdD): "+e.getMessage(),e);
  5575.         }
  5576.         if(infoCharset==null || infoCharset.length<=0){
  5577.             addInformazioneNonDisponibile(dati, "");
  5578.         }
  5579.         else{
  5580.             for (int i = 0; i < infoCharset.length; i++) {
  5581.                
  5582.                 try{
  5583.                     String label = infoCharset[i];
  5584.                     String value = "";
  5585.                     if(infoCharset[i].contains(":")){
  5586.                         label = infoCharset[i].split(":")[0];
  5587.                         value = infoCharset[i].substring(infoCharset[i].indexOf(":")+1);
  5588.                     }
  5589.                    
  5590.                     de = newDataElementStyleRuntime();
  5591.                     if(value==null || "".equals(value)){
  5592.                         value = label;
  5593.                         label = "Name";
  5594.                     }
  5595.                     de.setLabel(label);
  5596.                     if(value!=null){
  5597.                         value = StringEscapeUtils.escapeHtml(value);
  5598.                     }
  5599.                     de.setValue(value);
  5600.                     de.setType(DataElementType.TEXT);
  5601.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_CHARSET+i);
  5602.                     de.setSize(this.getSize());
  5603.                     dati.add(de);
  5604.                 }catch(Exception e){
  5605.                     this.logError("Errore durante la lettura delle informazioni sul charset (jmxResourcePdD): "+e.getMessage(),e);
  5606.                 }
  5607.             }
  5608.         }
  5609.        
  5610.        
  5611.        
  5612.        
  5613.        
  5614.        
  5615.        
  5616.        
  5617.        
  5618.        
  5619.        
  5620.         de = newDataElementStyleRuntime();
  5621.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_INTERNAZIONALIZZAZIONE);
  5622.         de.setType(DataElementType.TITLE);
  5623.         dati.add(de);
  5624.        
  5625.         String [] infoInternazionalizzazione = null;
  5626.         try{
  5627.             String tmp = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5628.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  5629.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoInformazioniInternazionalizzazione(alias));
  5630.             if(this.isErroreHttp(tmp, "informazioni Internazionalizzazione")){
  5631.                 // e' un errore
  5632.                 tmp = null;
  5633.             }
  5634.             infoInternazionalizzazione = tmp!=null ? tmp.split("\n") : null;
  5635.         }catch(Exception e){
  5636.             this.logError("Errore durante la lettura delle informazioni sull'internazionalizzazione (jmxResourcePdD): "+e.getMessage(),e);
  5637.         }
  5638.         if(infoInternazionalizzazione==null || infoInternazionalizzazione.length<=0){
  5639.             addInformazioneNonDisponibile(dati, "");
  5640.         }
  5641.         else{
  5642.             for (int i = 0; i < infoInternazionalizzazione.length; i++) {
  5643.                
  5644.                 try{
  5645.                     String label = infoInternazionalizzazione[i];
  5646.                     String value = "";
  5647.                     if(infoInternazionalizzazione[i].contains(":")){
  5648.                         label = infoInternazionalizzazione[i].split(":")[0];
  5649.                         value = infoInternazionalizzazione[i].substring(infoInternazionalizzazione[i].indexOf(":")+1);
  5650.                     }
  5651.                    
  5652.                     de = newDataElementStyleRuntime();
  5653.                     if(value==null || "".equals(value)){
  5654.                         value = label;
  5655.                         label = "Name";
  5656.                     }
  5657.                     de.setLabel(label);
  5658.                     if(value!=null){
  5659.                         value = StringEscapeUtils.escapeHtml(value);
  5660.                     }
  5661.                     de.setValue(value);
  5662.                     de.setType(DataElementType.TEXT);
  5663.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_INTERNAZIONALIZZAZIONE+i);
  5664.                     de.setSize(this.getSize());
  5665.                     dati.add(de);
  5666.                 }catch(Exception e){
  5667.                     this.logError("Errore durante la lettura delle informazioni sull'internazionalizzazione (jmxResourcePdD): "+e.getMessage(),e);
  5668.                 }
  5669.             }
  5670.         }
  5671.        
  5672.        
  5673.        
  5674.        
  5675.        
  5676.        
  5677.        
  5678.        
  5679.        
  5680.         de = newDataElementStyleRuntime();
  5681.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_TIMEZONE);
  5682.         de.setType(DataElementType.TITLE);
  5683.         dati.add(de);
  5684.        
  5685.         String [] infoTimezone = null;
  5686.         try{
  5687.             String tmp = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5688.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  5689.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoInformazioniTimeZone(alias));
  5690.             if(this.isErroreHttp(tmp, "informazioni Internazionalizzazione")){
  5691.                 // e' un errore
  5692.                 tmp = null;
  5693.             }
  5694.             infoTimezone = tmp!=null ? tmp.split("\n") : null;
  5695.         }catch(Exception e){
  5696.             this.logError("Errore durante la lettura delle informazioni sul TimeZone (jmxResourcePdD): "+e.getMessage(),e);
  5697.         }
  5698.         if(infoTimezone==null || infoTimezone.length<=0){
  5699.             addInformazioneNonDisponibile(dati, "");
  5700.         }
  5701.         else{
  5702.             for (int i = 0; i < infoTimezone.length; i++) {
  5703.                
  5704.                 try{
  5705.                     String label = infoTimezone[i];
  5706.                     String value = "";
  5707.                     if(infoTimezone[i].contains(":")){
  5708.                         label = infoTimezone[i].split(":")[0];
  5709.                         value = infoTimezone[i].substring(infoTimezone[i].indexOf(":")+1);
  5710.                     }
  5711.                    
  5712.                     de = newDataElementStyleRuntime();
  5713.                     if(value==null || "".equals(value)){
  5714.                         value = label;
  5715.                         label = "Name";
  5716.                     }
  5717.                     de.setLabel(label);
  5718.                     if(value!=null){
  5719.                         value = StringEscapeUtils.escapeHtml(value);
  5720.                     }
  5721.                     de.setValue(value);
  5722.                     de.setType(DataElementType.TEXT);
  5723.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_TIMEZONE+i);
  5724.                     de.setSize(this.getSize());
  5725.                     dati.add(de);
  5726.                 }catch(Exception e){
  5727.                     this.logError("Errore durante la lettura delle informazioni sul TimeZone (jmxResourcePdD): "+e.getMessage(),e);
  5728.                 }
  5729.             }
  5730.         }
  5731.        
  5732.        
  5733.        
  5734.        
  5735.        
  5736.        
  5737.         de = newDataElementStyleRuntime();
  5738.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_JAVA_NET);
  5739.         de.setType(DataElementType.TITLE);
  5740.         dati.add(de);
  5741.        
  5742.         String [] infoJavaNet = null;
  5743.         try{
  5744.             String tmp = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5745.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  5746.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoInformazioniProprietaJavaNetworking(alias));
  5747.             if(this.isErroreHttp(tmp, "informazioni Java Networking")){
  5748.                 // e' un errore
  5749.                 tmp = null;
  5750.             }
  5751.             infoJavaNet = tmp!=null ? tmp.split("\n") : null;
  5752.         }catch(Exception e){
  5753.             this.logError("Errore durante la lettura delle informazioni di Java Networking (jmxResourcePdD): "+e.getMessage(),e);
  5754.         }
  5755.         if(infoJavaNet==null || infoJavaNet.length<=0){
  5756.             addInformazioneNonDisponibile(dati, "");
  5757.         }
  5758.         else{
  5759.             for (int i = 0; i < infoJavaNet.length; i++) {
  5760.                
  5761.                 try{
  5762.                     if(infoJavaNet[i]==null || "".equals(infoJavaNet[i].trim())) {
  5763.                         continue;
  5764.                     }
  5765.                    
  5766.                     String label = infoJavaNet[i];
  5767.                     String value = "";
  5768.                     if(infoJavaNet[i].contains("=")){
  5769.                         label = infoJavaNet[i].split("=")[0];
  5770.                         value = infoJavaNet[i].substring(infoJavaNet[i].indexOf("=")+1);
  5771.                     }
  5772.                    
  5773.                     de = newDataElementStyleRuntime();
  5774.                     if(value==null || "".equals(value)){
  5775.                         if(label.startsWith("SecurityManager ")) {
  5776.                             String tmp = label;
  5777.                             label = "SecurityManager";
  5778.                             value = tmp.substring("SecurityManager ".length());
  5779.                         }
  5780.                         else {
  5781.                             value = label;
  5782.                             label = "Name";
  5783.                         }
  5784.                     }
  5785.                     de.setLabel(label);
  5786.                     if(value!=null){
  5787.                         value = StringEscapeUtils.escapeHtml(value);
  5788.                     }
  5789.                     de.setValue(value);
  5790.                     de.setType(DataElementType.TEXT);
  5791.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_JAVA_NET+i);
  5792.                     de.setSize(this.getSize());
  5793.                     dati.add(de);
  5794.                 }catch(Exception e){
  5795.                     this.logError("Errore durante la lettura delle informazioni di Java Networking (jmxResourcePdD): "+e.getMessage(),e);
  5796.                 }
  5797.             }
  5798.         }
  5799.        
  5800.        
  5801.        
  5802.        
  5803.        
  5804.        
  5805.        
  5806.        
  5807.         de = newDataElementStyleRuntime();
  5808.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_INFO_PROTOCOLLI);
  5809.         de.setType(DataElementType.TITLE);
  5810.         dati.add(de);
  5811.        
  5812.         String [] infoProtocolli = null;
  5813.         try{
  5814.             String tmp = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5815.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  5816.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoPluginProtocols(alias));
  5817.             infoProtocolli = tmp.split("\n");
  5818.         }catch(Exception e){
  5819.             this.logError("Errore durante la lettura delle informazioni sui protocolli (jmxResourcePdD): "+e.getMessage(),e);
  5820.         }
  5821.         if(infoProtocolli==null || infoProtocolli.length<=0){
  5822.             addInformazioneNonDisponibile(dati, "");
  5823.         }
  5824.         else{
  5825.             boolean addProtocollo = false;
  5826.             Map<String, String> map = new HashMap<>();
  5827.             for (int i = 0; i < infoProtocolli.length; i++) {
  5828.                
  5829.                 try{
  5830.                     String context = infoProtocolli[i].split(" ")[0];
  5831.                     String protocol = infoProtocolli[i].split(" ")[1];
  5832.                     protocol = protocol.split(":")[1];
  5833.                     protocol = protocol.substring(0, protocol.length()-1);
  5834.                     if(map.containsKey(protocol)){
  5835.                         String c = map.remove(protocol);
  5836.                         map.put(protocol, (c+", "+context));
  5837.                     }
  5838.                     else{
  5839.                         map.put(protocol, context);
  5840.                     }
  5841.                 }catch(Exception e){
  5842.                     this.logError("Errore durante la lettura delle informazioni sui protocolli (jmxResourcePdD): "+e.getMessage(),e);
  5843.                 }
  5844.                
  5845.             }
  5846.             int index = 0;
  5847.             for (String protocollo : map.keySet()) {
  5848.                
  5849.                 addProtocollo = true;
  5850.                
  5851.                 de = newDataElementStyleRuntime();
  5852.                 de.setLabel(protocollo);
  5853.                 String value = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_PROTOCOLLO_CONTESTO+map.get(protocollo);
  5854.                 if(value!=null){
  5855.                     value = StringEscapeUtils.escapeHtml(value);
  5856.                 }
  5857.                 de.setValue(value);
  5858.                 de.setType(DataElementType.TEXT);
  5859.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_PROTOCOLLO+index);
  5860.                 de.setSize(this.getSize());
  5861.                 dati.add(de);
  5862.                
  5863. //              de = newDataElementStyleLong();
  5864. //              de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_PROTOCOLLO);
  5865. //              de.setValue(protocollo);
  5866. //              de.setType(DataElementType.TEXT);
  5867. //              de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_PROTOCOLLO+index);
  5868. //              de.setSize(this.getSize());
  5869. //              dati.add(de);
  5870. //              
  5871. //              de = newDataElementStyleLong();
  5872. //              de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_PROTOCOLLO_CONTESTO);
  5873. //              de.setValue(map.get(protocollo));
  5874. //              de.setType(DataElementType.TEXT);
  5875. //              de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_INFO_PROTOCOLLO_CONTESTO+index);
  5876. //              de.setSize(this.getSize());
  5877. //              dati.add(de);
  5878.                
  5879.                 index++;
  5880.             }
  5881.            
  5882.             if(!addProtocollo){
  5883.                 addInformazioneNonDisponibile(dati, "");
  5884.             }
  5885.         }
  5886.        
  5887.         caches = this.confCore.getJmxPdDCaches(alias);
  5888.         if(caches!=null && !caches.isEmpty()){
  5889.            
  5890.             de = newDataElementStyleRuntime();
  5891.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_CACHE);
  5892.             de.setType(DataElementType.TITLE);
  5893.             dati.add(de);
  5894.            
  5895.             for (String cache : caches) {
  5896.            
  5897.                 de = newDataElementStyleRuntime();
  5898.                 de.setLabel(cache);
  5899.                 de.setType(DataElementType.SUBTITLE);
  5900.                 dati.add(de);
  5901.                
  5902.                 String stato = null;
  5903.                 try{
  5904.                     stato = this.confCore.getInvoker().readJMXAttribute(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  5905.                             cache,
  5906.                             this.confCore.getJmxPdDCacheNomeAttributoCacheAbilitata(alias));
  5907.                     if(stato.equalsIgnoreCase("true")){
  5908.                         stato = "abilitata";
  5909.                     }
  5910.                     else if(stato.equalsIgnoreCase("false")){
  5911.                         stato = "disabilitata";
  5912.                     }
  5913.                     else{
  5914.                         throw new DriverControlStationException("Stato ["+stato+"] sconosciuto");
  5915.                     }
  5916.                 }catch(Exception e){
  5917.                     this.logError("Errore durante la lettura dello stato della cache ["+cache+"](jmxResourcePdD): "+e.getMessage(),e);
  5918.                     stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  5919.                 }
  5920.                                
  5921.                 if("abilitata".equals(stato)){
  5922.                    
  5923.                     de = newDataElementStyleRuntime();
  5924.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_RESET);
  5925.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD+"?"+
  5926.                             ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER+"="+alias+
  5927.                             "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_CACHE+"="+cache+
  5928.                             "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_METODO+"="+this.confCore.getJmxPdDCacheNomeMetodoResetCache(alias));
  5929.                     de.setType(DataElementType.LINK);
  5930.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_RESET);
  5931.                     de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_RESET_SINGOLA);
  5932.                     de.setSize(this.getSize());
  5933.                     dati.add(de);
  5934.                    
  5935.                     if(this.confCore.getJmxPdDCachesPrefill(alias).contains(cache)){
  5936.                         de = newDataElementStyleRuntime();
  5937.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_PREFILL);
  5938.                         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD+"?"+
  5939.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER+"="+alias+
  5940.                                 "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_CACHE+"="+cache+
  5941.                                 "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_METODO+"="+this.confCore.getJmxPdDCacheNomeMetodoPrefillCache(alias));
  5942.                         de.setType(DataElementType.LINK);
  5943.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_PREFILL);
  5944.                         de.setValue(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_PREFILL);
  5945.                         de.setSize(this.getSize());
  5946.                         dati.add(de);
  5947.                     }
  5948.                    
  5949.                 }
  5950.                
  5951.                 de = newDataElementStyleRuntime();
  5952.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_STATO);
  5953.                 de.setValue(stato);
  5954.                 de.setType(DataElementType.TEXT);
  5955.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_STATO);
  5956.                 de.setSize(this.getSize());
  5957.                 dati.add(de);
  5958.                
  5959.                 if("abilitata".equals(stato)){
  5960.                    
  5961.                     String [] params = null;
  5962.                     try{
  5963.                         String tmp = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDCacheType(alias),
  5964.                                 cache,
  5965.                                 this.confCore.getJmxPdDCacheNomeMetodoStatoCache(alias));
  5966.                         params = tmp.split("\n");
  5967.                     }catch(Exception e){
  5968.                         this.logError("Errore durante la lettura dello stato della cache ["+cache+"](jmxResourcePdD): "+e.getMessage(),e);
  5969.                         stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  5970.                     }
  5971.                    
  5972.                     if(params!=null && params.length>0){
  5973.                        
  5974.                         List<String> listDe = null;
  5975.                         Map<String, List<DataElement>> mapDe = null;
  5976.                         if(CostantiPdD.JMX_GESTORE_RICHIESTE.equals(cache)) {
  5977.                             listDe = new ArrayList<>();
  5978.                             mapDe = new HashMap<String, List<DataElement>>();
  5979.                         }
  5980.                         String internalCache = null;
  5981.                        
  5982.                         for (int i = 0; i < params.length; i++) {
  5983.                            
  5984.                             try{
  5985.                                 String label = params[i];
  5986.                                 String labelCorretta = label;
  5987.                                 String value = "";
  5988.                                 if(params[i].contains(":")){
  5989.                                     label = params[i].split(":")[0];
  5990.                                     labelCorretta = label;
  5991.                                     value = params[i].split(":")[1];
  5992.                                    
  5993.                                     if(ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_ELEMENTI_IN_CACHE.equals(label)) {
  5994.                                         labelCorretta = ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_ELEMENTI_IN_CACHE_LABEL;
  5995.                                     }
  5996.                                     else if(ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_MEMORIA_OCCUPATA.equals(label)) {
  5997.                                         labelCorretta = ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_MEMORIA_OCCUPATA_LABEL;
  5998.                                     }
  5999.                                     else if(ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_IDLE_TIME.equals(label)) {
  6000.                                         labelCorretta = ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_IDLE_TIME_LABEL;
  6001.                                     }
  6002.                                     else if(ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_LIFE_TIME.equals(label)) {
  6003.                                         labelCorretta = ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_LIFE_TIME_LABEL;
  6004.                                     }
  6005.                                    
  6006.                                 }
  6007.                                
  6008.                                 if(CostantiPdD.JMX_GESTORE_RICHIESTE.equals(cache)) {
  6009.                                     if(ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_NOME.equals(label)) {
  6010.                                         internalCache = value;
  6011.                                         if(value.startsWith(GestoreRichieste.GESTORE_RICHIESTE_PREFIX_CACHE_NAME)) {
  6012.                                             internalCache = value.substring(GestoreRichieste.GESTORE_RICHIESTE_PREFIX_CACHE_NAME.length());
  6013.                                         }
  6014.                                         listDe.add(internalCache);
  6015.                                         continue;
  6016.                                     }
  6017.                                     else if(ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_ELEMENTI_IN_CACHE.equals(label)
  6018.                                             ||
  6019.                                             ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI_MEMORIA_OCCUPATA.equals(label)) {
  6020.                                        
  6021.                                         de = newDataElementStyleRuntime();
  6022.                                         de.setLabel(labelCorretta);
  6023.                                         if(value!=null){
  6024.                                             value = StringEscapeUtils.escapeHtml(value);
  6025.                                         }
  6026.                                         de.setValue(value);
  6027.                                         de.setType(DataElementType.TEXT);
  6028.                                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_STATO+"_"+i);
  6029.                                         de.setSize(this.getSize());
  6030.                                        
  6031.                                         List<DataElement> l = mapDe.get(internalCache);
  6032.                                         if(l==null) {
  6033.                                             l = new ArrayList<DataElement>();
  6034.                                             mapDe.put(internalCache, l);
  6035.                                         }
  6036.                                        
  6037.                                         l.add(de);
  6038.                                        
  6039.                                         continue;
  6040.                                     }
  6041.                                 }
  6042.                                
  6043.                                 if(ConfigurazioneCostanti.CONFIGURAZIONE_SISTEMA_CACHE_STATO_ELEMENTI_VISUALIZZATI.contains(label) &&
  6044.                                         (listDe==null || listDe.size()<=1)
  6045.                                     ){
  6046.                                
  6047.                                     de = newDataElementStyleRuntime();
  6048.                                     de.setLabel(labelCorretta);
  6049.                                     if(value!=null){
  6050.                                         value = StringEscapeUtils.escapeHtml(value);
  6051.                                     }
  6052.                                     de.setValue(value);
  6053.                                     de.setType(DataElementType.TEXT);
  6054.                                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_STATO+"_"+i);
  6055.                                     de.setSize(this.getSize());
  6056.                                     dati.add(de);
  6057.                                    
  6058.                                 }
  6059.                                    
  6060.                             }catch(Exception e){
  6061.                                 this.logError("Errore durante la lettura dello stato della cache ["+cache+"]: "+e.getMessage(),e);
  6062.                             }
  6063.                         }
  6064.                        
  6065.                         if(listDe!=null && !listDe.isEmpty()) {
  6066.                             int i = 0;
  6067.                             for (String internalCacheName : listDe) {
  6068.                                
  6069.                                 de = newDataElementStyleRuntime();
  6070.                                 de.setLabel("");
  6071.                                 de.setValue("<i>"+internalCacheName+"</i>");
  6072.                                 de.setType(DataElementType.TEXT);
  6073.                                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CACHE_STATO+"_int_"+i);
  6074.                                 de.setSize(this.getSize());
  6075.                                 dati.add(de);
  6076.                                
  6077.                                 i++;
  6078.                                
  6079.                                 List<DataElement> lDe = mapDe.get(internalCacheName);
  6080.                                 if(lDe!=null && !lDe.isEmpty()) {
  6081.                                     for (DataElement dea : lDe) {
  6082.                                         dati.add(dea);
  6083.                                     }
  6084.                                 }
  6085.                             }
  6086.                         }
  6087.                     }
  6088.                 }
  6089.             }
  6090.                        
  6091.         }
  6092.            
  6093.        
  6094.         String stato = null;
  6095.                
  6096.        
  6097.         if(!this.confCore.isClusterAsyncUpdate()) {
  6098.        
  6099.             de = newDataElementStyleRuntime();
  6100.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_CONNESSIONI);
  6101.             de.setType(DataElementType.TITLE);
  6102.             de.abilitaRefresh();
  6103.             dati.add(de);
  6104.            
  6105.             de = newDataElementStyleRuntime();
  6106.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_CONNESSIONE_DATABASE);
  6107.             de.setType(DataElementType.SUBTITLE);
  6108.             de.abilitaRefresh();
  6109.             dati.add(de);
  6110.            
  6111.             try{
  6112.                 stato = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  6113.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaMonitoraggio(alias),
  6114.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoConnessioniDB(alias));
  6115.                 if(this.isErroreHttp(stato, "stato delle connessioni al database")){
  6116.                     // e' un errore
  6117.                     stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6118.                 }
  6119.             }catch(Exception e){
  6120.                 this.logError("Errore durante la lettura dello stato delle connessioni al database (jmxResourcePdD): "+e.getMessage(),e);
  6121.                 stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6122.             }
  6123.            
  6124.             de = newDataElementStyleRuntime();
  6125.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CONNESSIONI_STATO);
  6126.             if(stato!=null){
  6127.                 stato = StringEscapeUtils.escapeHtml(stato);
  6128.             }
  6129.             de.setValue(stato);
  6130.             de.setLabelAffiancata(false);
  6131.             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6132.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CONNESSIONI_DB);
  6133.             de.setSize(this.getSize());
  6134.             de.setRows(6);
  6135.             de.setCols(80);
  6136.             dati.add(de);
  6137.            
  6138.            
  6139.             // statoConnessioniAltriDB, letto prima durante l'acquisizione delle informazion
  6140.             if(statoConnessioniAltriDB!=null && statoConnessioniAltriDB.size()>0) {
  6141.                 Iterator<String> it = statoConnessioniAltriDB.keySet().iterator();
  6142.                 int index = 0;
  6143.                 while (it.hasNext()) {
  6144.                     String idAltroDB = it.next();
  6145.                     String statoConnessioniAltroDB = statoConnessioniAltriDB.get(idAltroDB);
  6146.                    
  6147.                     de = newDataElementStyleRuntime();
  6148.                     de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_CONNESSIONE_DATABASE+" "+idAltroDB.split(" ")[0]);
  6149.                     de.setType(DataElementType.SUBTITLE);
  6150.                     de.abilitaRefresh();
  6151.                     dati.add(de);
  6152.                    
  6153.                     de = newDataElementStyleRuntime();
  6154.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CONNESSIONI_STATO);
  6155.                     if(statoConnessioniAltroDB!=null){
  6156.                         statoConnessioniAltroDB = StringEscapeUtils.escapeHtml(statoConnessioniAltroDB);
  6157.                     }
  6158.                     de.setValue(statoConnessioniAltroDB);
  6159.                     de.setLabelAffiancata(false);
  6160.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6161.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CONNESSIONI_DB+"_ds"+index++);
  6162.                     de.setSize(this.getSize());
  6163.                     de.setRows(6);
  6164.                     de.setCols(80);
  6165.                     dati.add(de);
  6166.                 }
  6167.             }
  6168.            
  6169.            
  6170.             de = newDataElementStyleRuntime();
  6171.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_CONNESSIONE_JMS);
  6172.             de.setType(DataElementType.SUBTITLE);
  6173.             de.abilitaRefresh();
  6174.             dati.add(de);
  6175.            
  6176.             stato = null;
  6177.             try{
  6178.                 stato = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  6179.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaMonitoraggio(alias),
  6180.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoConnessioniJMS(alias));
  6181.                 if(this.isErroreHttp(stato, "stato delle connessioni JMS")){
  6182.                     // e' un errore
  6183.                     stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6184.                 }
  6185.             }catch(Exception e){
  6186.                 this.logError("Errore durante la lettura dello stato delle connessioni JMS (jmxResourcePdD): "+e.getMessage(),e);
  6187.                 stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6188.             }
  6189.            
  6190.             de = newDataElementStyleRuntime();
  6191.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CONNESSIONI_STATO);
  6192.             if(stato!=null){
  6193.                 stato = StringEscapeUtils.escapeHtml(stato);
  6194.             }
  6195.             de.setValue(stato);
  6196.             de.setLabelAffiancata(false);
  6197.             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6198.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CONNESSIONI_JMS);
  6199.             de.setSize(this.getSize());
  6200.             de.setRows(6);
  6201.             de.setCols(80);
  6202.             dati.add(de);
  6203.            
  6204.         }
  6205.        
  6206.        
  6207.        
  6208.         if(!this.confCore.isClusterAsyncUpdate()) {
  6209.        
  6210.             de = newDataElementStyleRuntime();
  6211.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_TRANSAZIONI);
  6212.             de.setType(DataElementType.TITLE);
  6213.             de.abilitaRefresh();
  6214.             dati.add(de);
  6215.            
  6216.             de = newDataElementStyleRuntime();
  6217.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_TRANSAZIONI_ID);
  6218.             de.setType(DataElementType.SUBTITLE);
  6219.             de.abilitaRefresh();
  6220.             dati.add(de);
  6221.            
  6222.             stato = null;
  6223.             try{
  6224.                 stato = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  6225.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaMonitoraggio(alias),
  6226.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoIdTransazioniAttive(alias));
  6227.                 if(this.isErroreHttp(stato, "identificativi delle transazioni attive")){
  6228.                     // e' un errore
  6229.                     stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6230.                 }
  6231.             }catch(Exception e){
  6232.                 this.logError("Errore durante la lettura degli identificativi delle transazioni attive (jmxResourcePdD): "+e.getMessage(),e);
  6233.                 stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6234.             }
  6235.            
  6236.             de = newDataElementStyleRuntime();
  6237.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_TRANSAZIONI_STATO);
  6238.             if(stato!=null){
  6239.                 stato = StringEscapeUtils.escapeHtml(stato);
  6240.             }
  6241.             de.setValue(stato);
  6242.             de.setLabelAffiancata(false);
  6243.             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6244.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_TRANSAZIONI_ID);
  6245.             de.setSize(this.getSize());
  6246.             de.setRows(6);
  6247.             de.setCols(80);
  6248.             dati.add(de);
  6249.            
  6250.             de = newDataElementStyleRuntime();
  6251.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_TRANSAZIONI_ID_PROTOCOLLO);
  6252.             de.setType(DataElementType.SUBTITLE);
  6253.             de.abilitaRefresh();
  6254.             dati.add(de);
  6255.            
  6256.             stato = null;
  6257.             try{
  6258.                 stato = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  6259.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaMonitoraggio(alias),
  6260.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoIdProtocolloTransazioniAttive(alias));
  6261.                 if(this.isErroreHttp(stato, "identificativi di protocollo delle transazioni attive")){
  6262.                     // e' un errore
  6263.                     stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6264.                 }
  6265.             }catch(Exception e){
  6266.                 this.logError("Errore durante la lettura degli identificativi di protocollo delle transazioni attive (jmxResourcePdD): "+e.getMessage(),e);
  6267.                 stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6268.             }
  6269.            
  6270.             de = newDataElementStyleRuntime();
  6271.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_TRANSAZIONI_STATO);
  6272.             if(stato!=null){
  6273.                 stato = StringEscapeUtils.escapeHtml(stato);
  6274.             }
  6275.             de.setValue(stato);
  6276.             de.setLabelAffiancata(false);
  6277.             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6278.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_TRANSAZIONI_ID_PROTOCOLLO);
  6279.             de.setSize(this.getSize());
  6280.             de.setRows(6);
  6281.             de.setCols(80);
  6282.             dati.add(de);
  6283.            
  6284.         }
  6285.        
  6286.        
  6287.        
  6288.        
  6289.        
  6290.        
  6291.         de = newDataElementStyleRuntime();
  6292.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_CONNESSIONI_HTTP);
  6293.         de.setType(DataElementType.TITLE);
  6294.         de.abilitaRefresh();
  6295.         dati.add(de);
  6296.                
  6297.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreMessaggiVerificaConnessioniAttive(alias),
  6298.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_MESSAGGI_VERIFICA_CONNESSIONI_ATTIVE,
  6299.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_MESSAGGI_VERIFICA_CONNESSIONI_ATTIVE);
  6300.        
  6301.         if(!this.confCore.isClusterAsyncUpdate()) {
  6302.        
  6303.             de = newDataElementStyleRuntime();
  6304.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_CONNESSIONE_PD);
  6305.             de.setType(DataElementType.SUBTITLE);
  6306.             de.abilitaRefresh();
  6307.             dati.add(de);
  6308.            
  6309.             stato = null;
  6310.             try{
  6311.                 stato = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  6312.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaMonitoraggio(alias),
  6313.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoConnessioniPD(alias));
  6314.                 if(this.isErroreHttp(stato, "stato delle connessioni http verso le PD")){
  6315.                     // e' un errore
  6316.                     stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6317.                 }
  6318.             }catch(Exception e){
  6319.                 this.logError("Errore durante la lettura dello stato delle connessioni http verso le PD (jmxResourcePdD): "+e.getMessage(),e);
  6320.                 stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6321.             }
  6322.            
  6323.             de = newDataElementStyleRuntime();
  6324.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CONNESSIONI_STATO);
  6325.             if(stato!=null){
  6326.                 stato = StringEscapeUtils.escapeHtml(stato);
  6327.             }
  6328.             de.setValue(stato);
  6329.             de.setLabelAffiancata(false);
  6330.             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6331.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CONNESSIONI_PD);
  6332.             de.setSize(this.getSize());
  6333.             de.setRows(6);
  6334.             de.setCols(80);
  6335.             dati.add(de);
  6336.            
  6337.            
  6338.            
  6339.             de = newDataElementStyleRuntime();
  6340.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_CONNESSIONE_PA);
  6341.             de.setType(DataElementType.SUBTITLE);
  6342.             de.abilitaRefresh();
  6343.             dati.add(de);
  6344.            
  6345.             stato = null;
  6346.             try{
  6347.                 stato = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  6348.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaMonitoraggio(alias),
  6349.                         this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoConnessioniPA(alias));
  6350.                 if(this.isErroreHttp(stato, "stato delle connessioni http verso le PA")){
  6351.                     // e' un errore
  6352.                     stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6353.                 }
  6354.             }catch(Exception e){
  6355.                 this.logError("Errore durante la lettura dello stato delle connessioni http verso le PA (jmxResourcePdD): "+e.getMessage(),e);
  6356.                 stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6357.             }
  6358.            
  6359.             de = newDataElementStyleRuntime();
  6360.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CONNESSIONI_STATO);
  6361.             if(stato!=null){
  6362.                 stato = StringEscapeUtils.escapeHtml(stato);
  6363.             }
  6364.             de.setValue(stato);
  6365.             de.setLabelAffiancata(false);
  6366.             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6367.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CONNESSIONI_PA);
  6368.             de.setSize(this.getSize());
  6369.             de.setRows(6);
  6370.             de.setCols(80);
  6371.             dati.add(de);
  6372.            
  6373.         }
  6374.        
  6375.        
  6376.        
  6377.        
  6378.        
  6379.        
  6380.        
  6381.        
  6382.         List<String> code = this.confCore.getConsegnaNotificaCode();
  6383.        
  6384.         if(code.size()<=1) {
  6385.             de = newDataElementStyleRuntime();
  6386.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_THREADS);
  6387.             de.setType(DataElementType.TITLE);
  6388.             dati.add(de);
  6389.         }
  6390.        
  6391.         de = newDataElementStyleRuntime();
  6392.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_NOTIFICHE);
  6393.         if(code.size()<=1) {
  6394.             de.setType(DataElementType.SUBTITLE);
  6395.         }
  6396.         else {
  6397.             de.setType(DataElementType.TITLE);
  6398.         }
  6399.         de.abilitaRefresh();
  6400.         dati.add(de);
  6401.        
  6402.         boolean timerAttivo = addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerConsegnaContenutiApplicativi(alias),
  6403.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_CONSEGNA_CONTENUTI_APPLICATIVI,
  6404.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_CONSEGNA_CONTENUTI_APPLICATIVI);
  6405.                
  6406.         if(timerAttivo) {
  6407.             for (String coda : code) {
  6408.    
  6409.                 String labelCoda = this.confCore.getConsegnaNotificaCodaLabel(coda);
  6410.                
  6411.                 if(code.size()>1) {
  6412.                     de = newDataElementStyleRuntime();
  6413.                     de.setLabel(labelCoda);
  6414.                     de.setType(DataElementType.SUBTITLE);
  6415.                     dati.add(de);
  6416.                 }
  6417.                
  6418.                 stato = null;
  6419.                 try{
  6420.                     stato = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  6421.                             this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConsegnaContenutiApplicativi(alias),
  6422.                             this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoGetThreadPoolStatus(alias),
  6423.                             coda);
  6424.                     if(this.isErroreHttp(stato, "stato del thread pool per la consegna agli applicativi")){
  6425.                         // e' un errore
  6426.                         stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6427.                     }
  6428.                 }catch(Exception e){
  6429.                     this.logError("Errore durante la lettura dello stato del thread pool per la consegna agli applicativi (jmxResourcePdD): "+e.getMessage(),e);
  6430.                     stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6431.                 }
  6432.                
  6433.                 de = newDataElementStyleRuntime();
  6434.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_THREAD_POOL_STATO);
  6435.                 if(stato!=null){
  6436.                     stato = StringEscapeUtils.escapeHtml(stato);
  6437.                 }
  6438.                 de.setValue(stato);
  6439.                 de.setLabelAffiancata(false);
  6440.                 de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6441.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_THREADS_CONSEGNA_APPLICATIVI);
  6442.                 de.setSize(this.getSize());
  6443.                 de.setRows(2);
  6444.                 de.setCols(80);
  6445.                 dati.add(de);
  6446.                
  6447.                 String configurazioneCoda = null;
  6448.                 try{
  6449.                     configurazioneCoda = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  6450.                             this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConsegnaContenutiApplicativi(alias),
  6451.                             this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoGetQueueConfig(alias),
  6452.                             coda);
  6453.                     if(this.isErroreHttp(configurazioneCoda, "Configurazione del thread pool '"+labelCoda+"' per la consegna agli applicativi")){
  6454.                         // e' un errore
  6455.                         configurazioneCoda = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6456.                     }
  6457.                 }catch(Exception e){
  6458.                     this.logError("Errore durante la lettura della configurazione del thread pool '"+labelCoda+"' per la consegna agli applicativi (jmxResourcePdD): "+e.getMessage(),e);
  6459.                     configurazioneCoda = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6460.                 }
  6461.                
  6462.                 de = newDataElementStyleRuntime();
  6463.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_POOL_CONFIG);
  6464.                 if(configurazioneCoda!=null){
  6465.                     configurazioneCoda = StringEscapeUtils.escapeHtml(configurazioneCoda);
  6466.                 }
  6467.                 de.setValue(configurazioneCoda);
  6468.                 de.setLabelAffiancata(false);
  6469.                 de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6470.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_THREADS_CONSEGNA_APPLICATIVI_CONFIG);
  6471.                 de.setSize(this.getSize());
  6472.                 de.setRows(2);
  6473.                 de.setCols(80);
  6474.                 dati.add(de);
  6475.                
  6476.                 String connettoriPrioritari = null;
  6477.                 try{
  6478.                     connettoriPrioritari = this.confCore.getInvoker().invokeJMXMethod(alias,this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  6479.                             this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConsegnaContenutiApplicativi(alias),
  6480.                             this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoGetConnettoriPrioritari(alias),
  6481.                             coda);
  6482.                     if(this.isErroreHttp(connettoriPrioritari, "Connettori prioritari del thread pool '"+labelCoda+"' per la consegna agli applicativi")){
  6483.                         // e' un errore
  6484.                         connettoriPrioritari = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6485.                     }
  6486.                 }catch(Exception e){
  6487.                     this.logError("Errore durante la lettura dei connettori prioritari del thread pool '"+labelCoda+"' per la consegna agli applicativi (jmxResourcePdD): "+e.getMessage(),e);
  6488.                     connettoriPrioritari = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6489.                 }
  6490.                
  6491.                 de = newDataElementStyleRuntime();
  6492.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_POOL_CONNNETTORI_PRIORITARI);
  6493.                 if(connettoriPrioritari!=null){
  6494.                     connettoriPrioritari = StringEscapeUtils.escapeHtml(connettoriPrioritari);
  6495.                 }
  6496.                 de.setValue(connettoriPrioritari);
  6497.                 de.setLabelAffiancata(false);
  6498.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_THREADS_CONSEGNA_APPLICATIVI_CONNNETTORI_PRIORITARI);
  6499.                 if("".equals(connettoriPrioritari)) {
  6500.                     de.setType(DataElementType.TEXT);
  6501.                     de.setValue("Nessun Connettore");
  6502.                 }
  6503.                 else {
  6504.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6505.                     de.setSize(this.getSize());
  6506.                     de.setRows(2);
  6507.                     de.setCols(80);
  6508.                 }
  6509.                 dati.add(de);
  6510.                
  6511.                 if(!"".equals(connettoriPrioritari)) {
  6512.                     de = newDataElementStyleRuntime();
  6513.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_THREAD_POOL_ELIMINA_CONNETTORI_PRIORITARI);
  6514.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD+"?"+
  6515.                             ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER+"="+alias+
  6516.                             "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_CACHE+"="+coda+
  6517.                             "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NOME_METODO+"="+this.confCore.getJmxPdDConfigurazioneSistemaNomeMetodoResetConnettoriPrioritari(alias));
  6518.                     de.setType(DataElementType.LINK);
  6519.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_THREAD_POOL_ELIMINA_CONNETTORI_PRIORITARI);
  6520.                     de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_THREAD_POOL_ELIMINA_CONNETTORI_PRIORITARI);
  6521.                     de.setSize(this.getSize());
  6522.                     dati.add(de);
  6523.                 }
  6524.             }
  6525.         }
  6526.        
  6527.        
  6528.         if(code.size()>1) {
  6529.             de = newDataElementStyleRuntime();
  6530.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_THREADS);
  6531.             de.setType(DataElementType.TITLE);
  6532.             dati.add(de);
  6533.         }
  6534.        
  6535.            
  6536.         de = newDataElementStyleRuntime();
  6537.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_TIMERS_STATISTICHE);
  6538.         de.setType(DataElementType.SUBTITLE);
  6539.         dati.add(de);

  6540.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerStatisticheOrarie(alias),
  6541.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_STATISTICHE_ORARIE,
  6542.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_STATISTICHE_ORARIE);
  6543.        
  6544.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerStatisticheGiornaliere(alias),
  6545.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_STATISTICHE_GIORNALIERE,
  6546.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_STATISTICHE_GIORNALIERE);
  6547.        
  6548.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerStatisticheSettimanali(alias),
  6549.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_STATISTICHE_SETTIMANALI,
  6550.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_STATISTICHE_SETTIMANALI);
  6551.        
  6552.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerStatisticheMensili(alias),
  6553.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_STATISTICHE_MENSILI,
  6554.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_STATISTICHE_MENSILI);
  6555.        
  6556.         if(ProtocolFactoryManager.getInstance().existsProtocolFactory(CostantiLabel.MODIPA_PROTOCOL_NAME)) {
  6557.            
  6558.             de = newDataElementStyleRuntime();
  6559.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_TIMERS_PDND);
  6560.             de.setType(DataElementType.SUBTITLE);
  6561.             dati.add(de);
  6562.            
  6563.             addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreChiaviPDND(alias),
  6564.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_CHIAVI_PDND,
  6565.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_CHIAVI_PDND);
  6566.            
  6567.             addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreCacheChiaviPDND(alias),
  6568.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_CACHE_CHIAVI_PDND,
  6569.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_CACHE_CHIAVI_PDND);
  6570.         }
  6571.            
  6572.         de = newDataElementStyleRuntime();
  6573.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_TIMERS_RUNTIME);
  6574.         de.setType(DataElementType.SUBTITLE);
  6575.         dati.add(de);

  6576.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreMessaggiPuliziaMessaggiEliminati(alias),
  6577.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_MESSAGGI_PULIZIA_MESSAGGI_ELIMINATI,
  6578.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_MESSAGGI_PULIZIA_MESSAGGI_ELIMINATI);
  6579.        
  6580.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreMessaggiPuliziaMessaggiScaduti(alias),
  6581.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_MESSAGGI_PULIZIA_MESSAGGI_SCADUTI,
  6582.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_MESSAGGI_PULIZIA_MESSAGGI_SCADUTI);
  6583.        
  6584.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreRepositoryBuste(alias),
  6585.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_REPOSITORY_BUSTE,
  6586.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_REPOSITORY_BUSTE);
  6587.        
  6588.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreMessaggiPuliziaCorrelazioneApplicativa(alias),
  6589.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_MESSAGGI_PULIZIA_CORRELAZIONE_APPLICATIVA,
  6590.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_MESSAGGI_PULIZIA_CORRELAZIONE_APPLICATIVA);
  6591.        
  6592.        
  6593.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreMessaggiPuliziaMessaggiNonGestiti(alias),
  6594.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_MESSAGGI_PULIZIA_MESSAGGI_NON_GESTITI,
  6595.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_MESSAGGI_PULIZIA_MESSAGGI_NON_GESTITI);
  6596.        
  6597.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestorePuliziaMessaggiAnomali(alias),
  6598.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_PULIZIA_MESSAGGI_ANOMALI,
  6599.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_PULIZIA_MESSAGGI_ANOMALI);
  6600.        
  6601.         if(this.confCore.isClusterAsyncUpdate()) {
  6602.            
  6603.             addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreOperazioniRemote(alias),
  6604.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_OPERAZIONI_REMOTE,
  6605.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_OPERAZIONI_REMOTE,
  6606.                     true);
  6607.            
  6608.             addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerSvecchiamentoOperazioniRemote(alias),
  6609.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_SVECCHIAMENTO_OPERAZIONI_REMOTE,
  6610.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_SVECCHIAMENTO_OPERAZIONI_REMOTE);
  6611.            
  6612.         }
  6613.        
  6614.         de = newDataElementStyleRuntime();
  6615.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_TIMERS_MONITORAGGIO);
  6616.         de.setType(DataElementType.SUBTITLE);
  6617.         dati.add(de);

  6618.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerMonitoraggioRisorseThread(alias),
  6619.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_MONITORAGGIO_RISORSE_THREAD,
  6620.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_MONITORAGGIO_RISORSE_THREAD);
  6621.        
  6622.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerThresholdThread(alias),
  6623.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_THRESHOLD_THREAD,
  6624.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_THRESHOLD_THREAD);
  6625.        
  6626.        
  6627.         de = newDataElementStyleRuntime();
  6628.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_SISTEMA_TIMERS_SISTEMA);
  6629.         de.setType(DataElementType.SUBTITLE);
  6630.         dati.add(de);

  6631.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerEventi(alias),
  6632.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_EVENTI,
  6633.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_EVENTI);
  6634.        
  6635.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerFileSystemRecovery(alias),
  6636.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_FILE_SYSTEM_RECOVERY,
  6637.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_FILE_SYSTEM_RECOVERY);
  6638.        
  6639.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreBusteOnewayNonRiscontrate(alias),
  6640.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_BUSTE_ONEWAY_NON_RISCONTRATE,
  6641.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_BUSTE_ONEWAY_NON_RISCONTRATE);
  6642.        
  6643.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerGestoreBusteAsincroneNonRiscontrate(alias),
  6644.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_BUSTE_ASINCRONE_NON_RISCONTRATE,
  6645.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_GESTORE_BUSTE_ASINCRONE_NON_RISCONTRATE);
  6646.        
  6647.         addTimerState(dati, alias, this.confCore.getJmxPdDConfigurazioneSistemaNomeAttributoTimerRepositoryStatefulThread(alias),
  6648.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_REPOSITORY_STATEFUL_THREAD,
  6649.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_REPOSITORY_STATEFUL_THREAD);

  6650.         if(this.confCore.isConfigurazioneAllarmiEnabled()) {
  6651.            
  6652.             de = newDataElementStyleRuntime();
  6653.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_ATTIVI);
  6654.             de.setType(DataElementType.SUBTITLE);
  6655.             dati.add(de);
  6656.            
  6657.             AlarmEngineConfig alarmEngineConfig = this.confCore.getAllarmiConfig();
  6658.             stato = null;
  6659.             try{
  6660.                 stato = AllarmiUtils.getActiveThreadImages(this.log, alarmEngineConfig);
  6661.             }catch(Exception e){
  6662.                 this.logError("Riscontrato errore durante la lettura dello stato degli allarmi attivi: "+e.getMessage(),e);
  6663.                 stato = ConfigurazioneCostanti.LABEL_INFORMAZIONE_NON_DISPONIBILE;
  6664.             }
  6665.            
  6666.            
  6667.             if(stato !=null && !"".equals(stato)) {
  6668.            
  6669.                 de = newDataElementStyleRuntime();
  6670.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_ALLARMI_ATTIVI_STOP);
  6671.                 de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_ATTIVI_STOP);
  6672.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_ATTIVI_STOP);
  6673.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD+"?"+
  6674.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER+"="+alias+
  6675.                         "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_ALLARMI_ATTIVI_MANAGER+"="+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_ALLARMI_ATTIVI_STOP);
  6676.                 de.setType(DataElementType.LINK);
  6677.                 dati.add(de);
  6678.                
  6679.                 de = newDataElementStyleRuntime();
  6680.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_ALLARMI_ATTIVI_RESTART);
  6681.                 de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_ATTIVI_RESTART);
  6682.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_ATTIVI_RESTART);
  6683.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD+"?"+
  6684.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER+"="+alias+
  6685.                         "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_ALLARMI_ATTIVI_MANAGER+"="+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_ALLARMI_ATTIVI_RESTART);
  6686.                 de.setType(DataElementType.LINK);
  6687.                 dati.add(de);

  6688.             }
  6689.             else {
  6690.                
  6691.                 boolean existsAllarmi = this.confCore.existsAllarmi(TipoAllarme.ATTIVO);
  6692.                 if(existsAllarmi) {
  6693.                     de = newDataElementStyleRuntime();
  6694.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_ALLARMI_ATTIVI_START);
  6695.                     de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_ATTIVI_START);
  6696.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_ATTIVI_START);
  6697.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD+"?"+
  6698.                             ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER+"="+alias+
  6699.                             "&"+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_ALLARMI_ATTIVI_MANAGER+"="+ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_ALLARMI_ATTIVI_START);
  6700.                     de.setType(DataElementType.LINK);
  6701.                     dati.add(de);
  6702.                 }
  6703.                
  6704.             }
  6705.            
  6706.            
  6707.             de = newDataElementStyleRuntime();
  6708.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_ATTIVI_STATO);
  6709.             if("".equals(stato)) {
  6710.                 stato = "Nessun allarme attivo";
  6711.             }
  6712.             if(stato!=null){
  6713.                 stato = StringEscapeUtils.escapeHtml(stato);
  6714.             }
  6715.             de.setValue(stato);
  6716.             de.setLabelAffiancata(false);
  6717.             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6718.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_ALLARMI_ATTIVI);
  6719.             de.setSize(this.getSize());
  6720.             de.setRows(5);
  6721.             de.setCols(80);
  6722.             dati.add(de);
  6723.            
  6724.         }
  6725.        
  6726.         return dati;
  6727.     }

  6728.     private boolean addTimerState(List<DataElement> dati, String alias, String nomeAttributo, String nomeParametro, String labelParametro) {
  6729.         return addTimerState(dati, alias, nomeAttributo, nomeParametro, labelParametro, false);
  6730.     }
  6731.     private boolean addTimerState(List<DataElement> dati, String alias, String nomeAttributo, String nomeParametro, String labelParametro, boolean forceText) {
  6732.         try{
  6733.             String stato = this.confCore.getInvoker().readJMXAttribute(alias, this.confCore.getJmxPdDConfigurazioneSistemaType(alias),
  6734.                     this.confCore.getJmxPdDConfigurazioneSistemaNomeRisorsaConfigurazionePdD(alias),
  6735.                     nomeAttributo);
  6736.            
  6737.             TimerState timerState = TimerState.valueOf(stato);
  6738.            
  6739.             DataElement de = newDataElementStyleRuntime();
  6740.             de.setName(nomeParametro);
  6741.             de.setLabel(labelParametro);
  6742.             if(TimerState.OFF.equals(timerState)) {
  6743.                 de.setType(DataElementType.TEXT);
  6744.                 de.setValue(TimerState.OFF.name());
  6745.             }
  6746.             else if(forceText) {
  6747.                 de.setType(DataElementType.TEXT);
  6748.                 switch (timerState) {
  6749.                 case ENABLED:
  6750.                     de.setValue(CostantiConfigurazione.ABILITATO.getValue());
  6751.                     break;
  6752.                 case DISABLED:
  6753.                     de.setValue(CostantiConfigurazione.DISABILITATO.getValue());
  6754.                     break;
  6755.                 default:
  6756.                     de.setValue(TimerState.OFF.name());
  6757.                     break;
  6758.                 }  
  6759.             }
  6760.             else {
  6761.                 String[] labels = { CostantiConfigurazione.ABILITATO.getValue(), CostantiConfigurazione.DISABILITATO.getValue() };
  6762.                 String[] values = { TimerState.ENABLED.name(), TimerState.DISABLED.name() };
  6763.                 de.setType(DataElementType.SELECT);
  6764.                 de.setValues(values);
  6765.                 de.setLabels(labels);
  6766.                 de.setSelected(stato);
  6767.                 de.setPostBack_viaPOST(true);
  6768.             }
  6769.             dati.add(de);
  6770.            
  6771.             return !TimerState.OFF.equals(timerState);
  6772.            
  6773.         }catch(Exception e){
  6774.             this.logError("Errore durante la lettura delle informazioni sul '"+nomeAttributo+"' (jmxResourcePdD): "+e.getMessage(),e);
  6775.             addInformazioneNonDisponibile(dati, labelParametro);
  6776.             return false;
  6777.         }
  6778.     }
  6779.    
  6780.     public boolean isErroreHttp(String stato, String risorsa){
  6781.         if(stato!=null && stato.startsWith("[httpCode ")){
  6782.             this.logError("Errore durante la lettura della risorsa ["+risorsa+"]: "+stato);
  6783.             return true;
  6784.         }
  6785.         return false;
  6786.     }
  6787.    

  6788.    
  6789.     public boolean checkConfigurazioneTracciamento(TipoOperazione tipoOperazione, String configurazioneEsiti, String tipoConfigurazione) throws DriverControlStationException {

  6790.         if(ConfigurazioneCostanti.VALORE_PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE_TRACCIAMENTO.equals(tipoConfigurazione)) {
  6791.             String registrazioneTracce = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_TRACCE);
  6792.             if (!registrazioneTracce.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  6793.                     !registrazioneTracce.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  6794.                 this.pd.setMessage("Buste dev'essere abilitato o disabilitato");
  6795.                 return false;
  6796.             }
  6797.         }
  6798.         else if(ConfigurazioneCostanti.VALORE_PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE_TRACCIAMENTO_PD.equals(tipoConfigurazione)
  6799.                 ||
  6800.                 ConfigurazioneCostanti.VALORE_PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE_TRACCIAMENTO_PA.equals(tipoConfigurazione)) {
  6801.             // nop
  6802.         }
  6803.         else if(ConfigurazioneCostanti.VALORE_PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE_REGISTRAZIONE_MESSAGGI.equals(tipoConfigurazione)) {
  6804.             String dumpApplicativo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_APPLICATIVO);
  6805.             String dumpPD = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PD);
  6806.             String dumpPA = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_DUMP_CONNETTORE_PA);
  6807.             if (!dumpApplicativo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  6808.                     !dumpApplicativo.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  6809.                 this.pd.setMessage("Dump Applicativo dev'essere abilitato o disabilitato");
  6810.                 return false;
  6811.             }
  6812.             if (!dumpPD.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  6813.                     !dumpPD.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  6814.                 this.pd.setMessage("Dump Binario Porta Delegata dev'essere abilitato o disabilitato");
  6815.                 return false;
  6816.             }
  6817.             if (!dumpPA.equals(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO) &&
  6818.                     !dumpPA.equals(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO)) {
  6819.                 this.pd.setMessage("Dump Binario Porta Applicativa dev'essere abilitato o disabilitato");
  6820.                 return false;
  6821.             }
  6822.            
  6823.         }

  6824.         return true;
  6825.     }
  6826.    
  6827.     public void addConfigurazionControlloTrafficoToDati(List<DataElement> dati, TipoOperazione tipoOperazione, org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale configurazioneControlloTraffico, long sizePolicy, long sizeGlobalPolicy, boolean configurazioneTerminata) throws Exception {
  6828.        
  6829.        
  6830.         boolean first = this.isFirstTimeFromHttpParameters(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_FIRST_TIME);
  6831.        
  6832.         // Limitazione
  6833.        
  6834.         this.addToDatiConfigurazioneControlloTraffico(dati, tipoOperazione, configurazioneControlloTraffico.getControlloTraffico());
  6835.        
  6836.                            
  6837.         // Rate Limiting
  6838.        
  6839.         this.addToDatiConfigurazioneRateLimiting(dati, tipoOperazione, configurazioneControlloTraffico, first, configurazioneTerminata,sizePolicy,sizeGlobalPolicy);
  6840.        
  6841.        
  6842.         // Tempi di Risposta
  6843.        
  6844.         DataElement de = new DataElement();
  6845.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA);
  6846.         de.setType(DataElementType.TITLE);
  6847.         dati.add(de);
  6848.        
  6849.         this.addToDatiTempiRispostaFruizione(dati, tipoOperazione, true, configurazioneControlloTraffico.getTempiRispostaFruizione());
  6850.        
  6851.         this.addToDatiTempiRispostaErogazione(dati, tipoOperazione, true, configurazioneControlloTraffico.getTempiRispostaErogazione());
  6852.        
  6853.         // Cache
  6854.         this.addToDatiConfigurazioneCache(dati, tipoOperazione, configurazioneControlloTraffico.getCache(), this.isModalitaAvanzata());
  6855.        
  6856.         // Set First Time == false
  6857.         this.addToDatiFirstTimeDisabled(dati,ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_FIRST_TIME);
  6858.            
  6859.     }
  6860.    
  6861.     public void addToDatiConfigurazioneControlloTraffico(List<DataElement> dati, TipoOperazione tipoOperazione, ConfigurazioneControlloTraffico controlloTraffico) throws Exception {
  6862.    
  6863.         // **** Limitazione Numero di Richieste Complessive Gestite dalla PdD ****
  6864.        
  6865.         DataElement de = new DataElement();
  6866.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_LIMITAZIONE_NUMERO_RICHIESTE_COMPLESSIVE);
  6867.         de.setType(DataElementType.TITLE);
  6868.         dati.add(de);
  6869.        
  6870.         // stato
  6871.        
  6872.         de = new DataElement();
  6873.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_STATO);
  6874.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_STATO);
  6875.         de.setType(DataElementType.SELECT);
  6876.         de.setValues(ConfigurazioneCostanti.STATI_CON_WARNING);
  6877.         if(controlloTraffico!=null && controlloTraffico.isControlloMaxThreadsEnabled()) {
  6878.             if(controlloTraffico.isControlloMaxThreadsWarningOnly()) {
  6879.                 de.setSelected(CostantiConfigurazione.STATO_CON_WARNING_WARNING_ONLY.getValue());
  6880.             }
  6881.             else {
  6882.                 de.setSelected(CostantiConfigurazione.STATO_CON_WARNING_ABILITATO.getValue());
  6883.             }
  6884.         }
  6885.         else {
  6886.             de.setSelected(CostantiConfigurazione.STATO_CON_WARNING_DISABILITATO.getValue());
  6887.         }
  6888.         de.setPostBack(true);
  6889.         dati.add(de);
  6890.        
  6891.        
  6892.         // soglia
  6893.         Long numeroThreadComplessivi = null;
  6894.         de = new DataElement();
  6895.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_SOGLIA);
  6896.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_SOGLIA);
  6897.         if(controlloTraffico!=null && controlloTraffico.isControlloMaxThreadsEnabled()) {
  6898.             de.setType(DataElementType.TEXT_EDIT);
  6899.             de.setRequired(true);
  6900.         }
  6901.         else {
  6902.             de.setType(DataElementType.HIDDEN);
  6903.         }
  6904.         if(controlloTraffico!=null &&
  6905.                 controlloTraffico.getControlloMaxThreadsSoglia()!=null){
  6906.             numeroThreadComplessivi = controlloTraffico.getControlloMaxThreadsSoglia();
  6907.             de.setValue(numeroThreadComplessivi+"");
  6908.         }
  6909.         dati.add(de);
  6910.    
  6911.                
  6912.         // messaggio di errore
  6913.         de = new DataElement();
  6914.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_TIPOLOGIA_ERRORE_DESCRIZIONE);
  6915.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_TIPOLOGIA_ERRORE_DESCRIZIONE);
  6916.         if(!this.isModalitaStandard() && controlloTraffico.isControlloMaxThreadsEnabled() && (controlloTraffico.isControlloMaxThreadsWarningOnly() == false)) {
  6917.             de.setType(DataElementType.CHECKBOX);
  6918.             de.setSelected(controlloTraffico.isControlloMaxThreadsTipoErroreIncludiDescrizione());
  6919.         }
  6920.         else {
  6921.             de.setType(DataElementType.HIDDEN);
  6922.             de.setValue(controlloTraffico.isControlloMaxThreadsTipoErroreIncludiDescrizione()+"");
  6923.         }
  6924.         dati.add(de);
  6925.            
  6926.         // tipo errore
  6927.        
  6928.         de = new DataElement();
  6929.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_TIPOLOGIA_ERRORE);
  6930.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_TIPOLOGIA_ERRORE);
  6931.         if(controlloTraffico.isControlloMaxThreadsEnabled() && (controlloTraffico.isControlloMaxThreadsWarningOnly() == false)) {
  6932.             if(this.isModalitaStandard()) {
  6933.                 de.setType(DataElementType.HIDDEN);
  6934.             }
  6935.             else {
  6936.                 de.setType(DataElementType.SELECT);
  6937.                 de.setValues(ConfigurazioneCostanti.TIPI_ERRORE);
  6938.                 de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_ERRORE);
  6939.                 if(controlloTraffico.getControlloMaxThreadsTipoErrore()!=null) {
  6940.                     TipoErrore tipoErroEnum = TipoErrore.toEnumConstant(controlloTraffico.getControlloMaxThreadsTipoErrore());
  6941.                     if(tipoErroEnum!=null) {
  6942.                         de.setSelected(tipoErroEnum.getValue());
  6943.                     }
  6944.                 }
  6945.             }
  6946.         }
  6947.         else {
  6948.             de.setType(DataElementType.HIDDEN);
  6949.         }
  6950.         if(controlloTraffico.getControlloMaxThreadsTipoErrore()!=null) {
  6951.             TipoErrore tipoErroEnum = TipoErrore.toEnumConstant(controlloTraffico.getControlloMaxThreadsTipoErrore());
  6952.             if(tipoErroEnum!=null) {
  6953.                 de.setValue(tipoErroEnum.getValue());
  6954.             }
  6955.         }
  6956.         dati.add(de);
  6957.        
  6958.         if(controlloTraffico.isControlloMaxThreadsEnabled()) {
  6959.            
  6960.             // Link visualizza stato
  6961.             de = new DataElement();
  6962.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_VISUALIZZA_STATO);
  6963.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_VISUALIZZA_STATO);
  6964.             de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_VISUALIZZA_STATO);
  6965.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RUNTIME);
  6966.             de.setType(DataElementType.LINK);
  6967.             dati.add(de);
  6968.            
  6969.         }
  6970.        
  6971.        
  6972.        
  6973.         // *** Controllo del Traffico ***
  6974.        
  6975.         if(controlloTraffico.isControlloMaxThreadsEnabled()) {
  6976.        
  6977.             de = new DataElement();
  6978.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO_STATO_CONTROLLO_CONGESTIONE);
  6979.             de.setType(DataElementType.TITLE);
  6980.             dati.add(de);
  6981.            
  6982.        
  6983.             // stato
  6984.            
  6985.             de = new DataElement();
  6986.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_STATO_CONTROLLO_CONGESTIONE);
  6987.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_STATO_CONTROLLO_CONGESTIONE);
  6988.             de.setType(DataElementType.SELECT);
  6989.             de.setValues(ConfigurazioneCostanti.STATI);
  6990.             de.setSelected(controlloTraffico.isControlloCongestioneEnabled() ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue());
  6991.             de.setPostBack(true);
  6992.             dati.add(de);
  6993.                    
  6994.            
  6995.             // threshold
  6996.            
  6997.             de = new DataElement();
  6998.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_THRESHOLD_CONTROLLO_CONGESTIONE);
  6999.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_THRESHOLD_CONTROLLO_CONGESTIONE);
  7000.             if(controlloTraffico.isControlloCongestioneEnabled()){
  7001.                 de.setType(DataElementType.SELECT);
  7002.                 String [] v = new String[100];
  7003.                 for (int i = 0; i < 100; i++) {
  7004.                     v[i] = (i+1)+"";
  7005.                 }
  7006.                 de.setValues(v);
  7007.                 if(controlloTraffico.getControlloCongestioneThreshold()!=null){
  7008.                     de.setSelected(controlloTraffico.getControlloCongestioneThreshold()+"");
  7009.                 }
  7010.                 de.setPostBack(true);
  7011.             }
  7012.             else{
  7013.                 de.setType(DataElementType.HIDDEN);
  7014.             }
  7015.             if(controlloTraffico.getControlloCongestioneThreshold()!=null){
  7016.                 de.setValue(controlloTraffico.getControlloCongestioneThreshold()+"");
  7017.             }
  7018.             dati.add(de);
  7019.            
  7020.             Integer soglia = controlloTraffico.getControlloCongestioneThreshold();
  7021.             Long numeroThreadCongestionamento = null;
  7022.             if(numeroThreadComplessivi!=null && soglia!=null){
  7023.                 double numD = numeroThreadComplessivi.doubleValue();
  7024.                 double totale = 100d;
  7025.                 double sogliaD = soglia.doubleValue();
  7026.                 Double numeroThreadCongestionamentoD = (numD / totale) *  sogliaD;
  7027.                 numeroThreadCongestionamento = numeroThreadCongestionamentoD.longValue();
  7028.             }
  7029.             if(numeroThreadCongestionamento!=null && controlloTraffico.isControlloCongestioneEnabled()){
  7030.                 de = new DataElement();
  7031.                 de.setType(DataElementType.NOTE);
  7032.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_CONGESTIONE_THRESHOLD_DESCRIZIONE.
  7033.                         replace(ConfigurazioneCostanti.CONFIGURAZIONE_CONTROLLO_CONGESTIONE_THRESHOLD_DESCRIZIONE_TEMPLATE, numeroThreadCongestionamento+""));
  7034.                 dati.add(de);
  7035.             }
  7036.                    
  7037.         }
  7038.     }
  7039.    
  7040.     public void addToDatiConfigurazioneRateLimiting(List<DataElement> dati, TipoOperazione tipoOperazione, org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale controlloTraffico, boolean first, boolean finished, long sizePolicy, long sizeGlobalPolicy) throws Exception {
  7041.            
  7042.         // Policy
  7043. //      if( first || finished ){

  7044.         DataElement de = new DataElement();
  7045.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING);
  7046.         de.setType(DataElementType.TITLE);
  7047.         dati.add(de);
  7048.                
  7049.         // messaggio di errore
  7050.         de = new DataElement();
  7051.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_TIPOLOGIA_ERRORE_DESCRIZIONE);
  7052.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_TIPOLOGIA_ERRORE_DESCRIZIONE);
  7053.         if(this.isModalitaStandard()) {
  7054.             de.setType(DataElementType.HIDDEN);
  7055.             de.setValue(controlloTraffico.getRateLimiting().isTipoErroreIncludiDescrizione()+"");
  7056.         }
  7057.         else {
  7058.             de.setType(DataElementType.CHECKBOX);
  7059.             de.setSelected(controlloTraffico.getRateLimiting().isTipoErroreIncludiDescrizione());
  7060.         }
  7061.         dati.add(de);
  7062.        
  7063.         // tipo errore
  7064.        
  7065.         de = new DataElement();
  7066.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_TIPOLOGIA_ERRORE);
  7067.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_TIPOLOGIA_ERRORE);
  7068.         TipoErrore tipoErroEnum = null;
  7069.         if(controlloTraffico.getRateLimiting().getTipoErrore()!=null) {
  7070.             tipoErroEnum = TipoErrore.toEnumConstant(controlloTraffico.getRateLimiting().getTipoErrore());
  7071.         }  
  7072.         if(this.isModalitaStandard()) {
  7073.             de.setType(DataElementType.HIDDEN);
  7074.             if(tipoErroEnum!=null) {
  7075.                 de.setValue(tipoErroEnum.getValue());
  7076.             }
  7077.         }
  7078.         else {
  7079.             de.setType(DataElementType.SELECT);
  7080.             de.setValues(ConfigurazioneCostanti.TIPI_ERRORE);
  7081.             de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_ERRORE);
  7082.             if(tipoErroEnum!=null) {
  7083.                 de.setSelected(tipoErroEnum.getValue());
  7084.             }
  7085.         }
  7086.         dati.add(de);
  7087.        
  7088.         List<Proprieta> listProprieta = new ArrayList<Proprieta>();
  7089.         if(controlloTraffico.getRateLimiting().sizeProprietaList()>0) {
  7090.             for (ConfigurazioneRateLimitingProprieta rtProp : controlloTraffico.getRateLimiting().getProprietaList()) {
  7091.                 Proprieta p = new Proprieta();
  7092.                 p.setNome(rtProp.getNome());
  7093.                 p.setValore(rtProp.getValore());
  7094.                 listProprieta.add(p);
  7095.             }
  7096.         }
  7097.         PolicyConfiguration policyConfig = new PolicyConfiguration(listProprieta, this.core.getControlloTrafficoPolicyRateLimitingTipiGestori(), false);
  7098.         String ctModalitaSincronizzazione = policyConfig.getSyncMode();
  7099.         String ctImplementazione = policyConfig.getImpl();
  7100.         String ctContatori = policyConfig.getCount();
  7101.         String ctTipologia = policyConfig.getEngineType();
  7102.         String ctHeaderHttp = policyConfig.getHttpMode();
  7103.         String ctHeaderHttp_limit = policyConfig.getHttpMode_limit();
  7104.         String ctHeaderHttp_remaining = policyConfig.getHttpMode_remaining();
  7105.         String ctHeaderHttp_reset = policyConfig.getHttpMode_reset();
  7106.         String ctHeaderHttp_retryAfter = policyConfig.getHttpMode_retry_after();
  7107.         String ctHeaderHttp_retryAfterBackoff = policyConfig.getHttpMode_retry_after_backoff();
  7108.         this.addOpzioniAvanzateRateLimitingToDati(dati,
  7109.                 false,
  7110.                 false,
  7111.                 ctModalitaSincronizzazione, ctImplementazione, ctContatori, ctTipologia,
  7112.                 ctHeaderHttp, ctHeaderHttp_limit, ctHeaderHttp_remaining, ctHeaderHttp_reset,
  7113.                 ctHeaderHttp_retryAfter, ctHeaderHttp_retryAfterBackoff);
  7114.        
  7115.        
  7116.         de = new DataElement();
  7117.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY);
  7118.         de.setType(DataElementType.SUBTITLE);
  7119.         dati.add(de);
  7120.        
  7121.         de = new DataElement();
  7122.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_LINK);
  7123.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_LINK);
  7124.         de.setType(DataElementType.LINK);
  7125.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONFIGURAZIONE_POLICY_LIST);
  7126.         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO_POLICY+" (" +sizePolicy+ ")");
  7127.         dati.add(de);
  7128.                
  7129.         de = new DataElement();
  7130.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK);
  7131.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK);
  7132.         de.setType(DataElementType.LINK);
  7133.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_LIST);
  7134.         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK+" (" + sizeGlobalPolicy+ ")");
  7135.         dati.add(de);
  7136. //      }
  7137.        
  7138.     }
  7139.    
  7140.     public void addConfigurazioneControlloTrafficoJmxStateToDati(List<DataElement> dati, TipoOperazione tipoOperazione) throws Exception {
  7141.         // jmx
  7142.        
  7143.         List<String> aliases = this.getCore().getJmxPdDAliases();
  7144.         if(aliases==null || aliases.size()<=0){
  7145.             throw new DriverControlStationException("Pagina non prevista, la sezione configurazione non permette di accedere a questa pagina, se la configurazione non e' corretta");
  7146.         }
  7147.        
  7148.         DataElement de = new DataElement();
  7149.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_STATO_RUNTIME);
  7150.         de.setType(DataElementType.TITLE);
  7151.         dati.add(de);
  7152.        
  7153.         // Link visualizza stato
  7154.         de = new DataElement();
  7155.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_VISUALIZZA_STATO);
  7156.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_VISUALIZZA_STATO_REFRESH);
  7157.         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_VISUALIZZA_STATO_REFRESH);
  7158.         de.setUrl(org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RUNTIME);
  7159.         de.setType(DataElementType.LINK);
  7160.         dati.add(de);
  7161.        
  7162.        
  7163.         for (String alias : aliases) {
  7164.            
  7165.             String descrizioneAlias = this.getCore().getJmxPdDDescrizione(alias);
  7166.            
  7167.             de = new DataElement();
  7168.             de.setLabel(descrizioneAlias);
  7169.             de.setValue(descrizioneAlias);
  7170.             de.setType(DataElementType.TITLE);
  7171.             dati.add(de);
  7172.            
  7173.             String threadsAttivi = null;
  7174.             try{
  7175.                 threadsAttivi = this.getCore().getInvoker().readJMXAttribute(alias, JMXConstants.JMX_TYPE,
  7176.                         JMXConstants.JMX_NAME, JMXConstants.CC_ATTRIBUTE_ACTIVE_THREADS);
  7177.             }catch(Exception e){
  7178.                 String errorMessage = "Errore durante il recupero dell'attributo ["+JMXConstants.CC_ATTRIBUTE_ACTIVE_THREADS+"] sulla risorsa ["+JMXConstants.JMX_NAME+"]: "+e.getMessage();
  7179.                 ControlStationCore.getLog().error(errorMessage,e);
  7180.                 threadsAttivi = errorMessage;
  7181.             }
  7182.            
  7183.             de = new DataElement();
  7184.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_VISUALIZZA_STATO_THREADS_ATTIVI);
  7185.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_VISUALIZZA_STATO_THREADS_ATTIVI);
  7186.             de.setType(DataElementType.TEXT);
  7187.             de.setValue(threadsAttivi);
  7188.             dati.add(de);
  7189.            
  7190.             String pddCongestionata = null;
  7191.             try{
  7192.                 pddCongestionata = this.getCore().getInvoker().readJMXAttribute(alias, JMXConstants.JMX_TYPE,
  7193.                         JMXConstants.JMX_NAME, JMXConstants.CC_ATTRIBUTE_PDD_CONGESTIONATA);
  7194.             }catch(Exception e){
  7195.                 String errorMessage = "Errore durante il recupero dell'attributo ["+JMXConstants.CC_ATTRIBUTE_PDD_CONGESTIONATA+"] sulla risorsa ["+JMXConstants.JMX_NAME+"]: "+e.getMessage();
  7196.                 ControlStationCore.getLog().error(errorMessage,e);
  7197.                 pddCongestionata = errorMessage;
  7198.             }
  7199.            
  7200.             de = new DataElement();
  7201.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_VISUALIZZA_STATO_CONGESTIONE);
  7202.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_VISUALIZZA_STATO_CONGESTIONE);
  7203.             de.setType(DataElementType.TEXT);
  7204.             de.setValue(pddCongestionata);
  7205.             dati.add(de);
  7206.            
  7207.             this.getPd().disableEditMode();
  7208.            
  7209.         }
  7210.     }
  7211.    
  7212.     public void addToDatiTempiRispostaFruizione(List<DataElement> dati, TipoOperazione tipoOperazione, boolean editEnabled, TempiRispostaFruizione tempiRispostaFruizione) throws Exception {
  7213.        
  7214.         DataElement de = new DataElement();
  7215.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FRUIZIONI);
  7216.         de.setType(DataElementType.SUBTITLE);
  7217.         dati.add(de);
  7218.        
  7219.         de = new DataElement();
  7220.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT_LABEL);
  7221.         de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_MILLISECONDI_NOTE);
  7222.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT_FRUIZIONE);
  7223.         if(editEnabled){
  7224.             de.setType(DataElementType.TEXT_EDIT);
  7225.             de.setRequired(true);
  7226.         }
  7227.         else{
  7228.             de.setType(DataElementType.TEXT);
  7229.         }
  7230.         if(tempiRispostaFruizione.getConnectionTimeout()!=null)
  7231.             de.setValue(tempiRispostaFruizione.getConnectionTimeout()+"");
  7232.         dati.add(de);
  7233.        
  7234.         de = new DataElement();
  7235.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_READ_TIMEOUT_LABEL);
  7236.         de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_MILLISECONDI_NOTE);
  7237.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_READ_TIMEOUT_FRUIZIONE);
  7238.         if(editEnabled){
  7239.             de.setType(DataElementType.TEXT_EDIT);
  7240.             de.setRequired(true);
  7241.         }
  7242.         else{
  7243.             de.setType(DataElementType.TEXT);
  7244.         }
  7245.         if(tempiRispostaFruizione.getReadTimeout()!=null)
  7246.             de.setValue(tempiRispostaFruizione.getReadTimeout()+"");
  7247.         dati.add(de);
  7248.        
  7249.         de = new DataElement();
  7250.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_TEMPO_MEDIO_RISPOSTA_LABEL);
  7251.         de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_MILLISECONDI_NOTE);
  7252.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_TEMPO_MEDIO_RISPOSTA_FRUIZIONE);
  7253.         if(editEnabled){
  7254.             de.setType(DataElementType.TEXT_EDIT);
  7255.             de.setRequired(true);
  7256.         }
  7257.         else{
  7258.             de.setType(DataElementType.TEXT);
  7259.         }
  7260.         if(tempiRispostaFruizione.getTempoMedioRisposta()!=null)
  7261.             de.setValue(tempiRispostaFruizione.getTempoMedioRisposta()+"");
  7262.         dati.add(de);
  7263.        
  7264.     }
  7265.    
  7266.    
  7267.     public void addToDatiTempiRispostaErogazione(List<DataElement> dati, TipoOperazione tipoOperazione, boolean editEnabled, TempiRispostaErogazione tempiRispostaErogazione) throws Exception {
  7268.        
  7269.         DataElement de = new DataElement();
  7270.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_EROGAZIONI);
  7271.         de.setType(DataElementType.SUBTITLE);
  7272.         dati.add(de);
  7273.        
  7274.         de = new DataElement();
  7275.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT_LABEL);
  7276.         de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_MILLISECONDI_NOTE);
  7277.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT_EROGAZIONE);
  7278.         if(editEnabled){
  7279.             de.setType(DataElementType.TEXT_EDIT);
  7280.             de.setRequired(true);
  7281.         }
  7282.         else{
  7283.             de.setType(DataElementType.TEXT);
  7284.         }
  7285.         if(tempiRispostaErogazione.getConnectionTimeout()!=null)
  7286.             de.setValue(tempiRispostaErogazione.getConnectionTimeout()+"");
  7287.         dati.add(de);
  7288.        
  7289.         de = new DataElement();
  7290.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_READ_TIMEOUT_LABEL);
  7291.         de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_MILLISECONDI_NOTE);
  7292.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_READ_TIMEOUT_EROGAZIONE);
  7293.         if(editEnabled){
  7294.             de.setType(DataElementType.TEXT_EDIT);
  7295.             de.setRequired(true);
  7296.         }
  7297.         else{
  7298.             de.setType(DataElementType.TEXT);
  7299.         }
  7300.         if(tempiRispostaErogazione.getReadTimeout()!=null)
  7301.             de.setValue(tempiRispostaErogazione.getReadTimeout()+"");
  7302.         dati.add(de);
  7303.        
  7304.         de = new DataElement();
  7305.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_TEMPO_MEDIO_RISPOSTA_LABEL);
  7306.         de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_MILLISECONDI_NOTE);
  7307.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_TEMPO_MEDIO_RISPOSTA_EROGAZIONE);
  7308.         if(editEnabled){
  7309.             de.setType(DataElementType.TEXT_EDIT);
  7310.             de.setRequired(true);
  7311.         }
  7312.         else{
  7313.             de.setType(DataElementType.TEXT);
  7314.         }
  7315.         if(tempiRispostaErogazione.getTempoMedioRisposta()!=null)
  7316.             de.setValue(tempiRispostaErogazione.getTempoMedioRisposta()+"");
  7317.         dati.add(de);
  7318.        
  7319.     }
  7320.    
  7321.    
  7322.     public void addToDatiConfigurazioneCache(List<DataElement> dati, TipoOperazione tipoOperazione,
  7323.             Cache cache, boolean enabled) throws Exception {
  7324.        
  7325.    
  7326.         if(enabled){
  7327.             DataElement de = new DataElement();
  7328.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONFIGURAZIONE_CACHE_DATI_STATISTICI);
  7329.             de.setType(DataElementType.TITLE);
  7330.             dati.add(de);
  7331.         }
  7332.        
  7333.         DataElement de = new DataElement();
  7334.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_STATO);
  7335.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_STATO);
  7336.         if(enabled){
  7337.             //de.setType(DataElementType.CHECKBOX);
  7338.             de.setType(DataElementType.SELECT);
  7339.         }
  7340.         else{
  7341.             de.setType(DataElementType.HIDDEN);
  7342.         }
  7343.         de.setValues(ConfigurazioneCostanti.STATI);
  7344.         de.setSelected(cache.isCache() ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue());
  7345.         de.setValue(cache.isCache() ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue());
  7346.         de.setPostBack(true);
  7347.         dati.add(de);
  7348.                
  7349.         de = new DataElement();
  7350.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_DIMENSIONE);
  7351.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_DIMENSIONE);
  7352.         if(enabled && cache.isCache()){
  7353.             de.setType(DataElementType.TEXT_EDIT);
  7354.             de.setRequired(true);
  7355.         }
  7356.         else{
  7357.             de.setType(DataElementType.HIDDEN);
  7358.         }
  7359.         if(cache.getSize()!=null)
  7360.             de.setValue(cache.getSize()+"");
  7361.         dati.add(de);
  7362.        
  7363.        
  7364.         String[] tipoAlgoritmo = {
  7365.                 CacheAlgorithm.LRU.name(),
  7366.                 CacheAlgorithm.MRU.name()
  7367.         };
  7368.         de = new DataElement();
  7369.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_ALGORITMO);
  7370.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_ALGORITMO);
  7371.         if(enabled && cache.isCache()){
  7372.             de.setType(DataElementType.SELECT);
  7373.             de.setValues(tipoAlgoritmo);
  7374.             if(cache.getAlgorithm()!=null){
  7375.                 de.setSelected(cache.getAlgorithm().name());
  7376.             }
  7377.         }
  7378.         else{
  7379.             de.setType(DataElementType.HIDDEN);
  7380.         }
  7381.         if(cache.getAlgorithm()!=null){
  7382.             de.setValue(cache.getAlgorithm().name());
  7383.         }
  7384.         dati.add(de);
  7385.        
  7386.         de = new DataElement();
  7387.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_LIFE_TIME);
  7388.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_LIFE_TIME);
  7389.         if(enabled && cache.isCache()){
  7390.             de.setType(DataElementType.TEXT_EDIT);
  7391.             //de.setRequired(true);
  7392.         }
  7393.         else{
  7394.             de.setType(DataElementType.HIDDEN);
  7395.         }
  7396.         if(cache.getLifeTime()!=null)
  7397.             de.setValue(cache.getLifeTime()+"");
  7398.         dati.add(de);
  7399.        
  7400.         de = new DataElement();
  7401.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_IDLE_TIME);
  7402.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_IDLE_TIME);
  7403.         if(enabled && cache.isCache()){
  7404.             de.setType(DataElementType.TEXT_EDIT);
  7405.             de.setNote(ConfigurazioneCostanti.LABEL_CACHE_SECONDS_NOTE);
  7406.         }
  7407.         else{
  7408.             de.setType(DataElementType.HIDDEN);
  7409.         }
  7410.         if(cache.getIdleTime()!=null)
  7411.             de.setValue(cache.getIdleTime()+"");
  7412.         dati.add(de);
  7413.        
  7414.        
  7415.     }
  7416.    
  7417.     public String readConfigurazioneControlloTrafficoFromHttpParameters(ConfigurazioneControlloTraffico controlloTraffico, boolean first) throws Exception {
  7418.        
  7419.         StringBuilder sbParsingError = new StringBuilder();
  7420.         // **** Limitazione Numero di Richieste Complessive Gestite dalla PdD ****
  7421.        
  7422.         // enabled
  7423.         String statoMaxThreads = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_STATO);
  7424.         if(statoMaxThreads!=null && !"".equals(statoMaxThreads)){
  7425.             controlloTraffico.setControlloMaxThreadsEnabled(CostantiConfigurazione.STATO_CON_WARNING_ABILITATO.getValue().equals(statoMaxThreads) ||
  7426.                     CostantiConfigurazione.STATO_CON_WARNING_WARNING_ONLY.getValue().equals(statoMaxThreads));
  7427.             controlloTraffico.setControlloMaxThreadsWarningOnly(CostantiConfigurazione.STATO_CON_WARNING_WARNING_ONLY.getValue().equals(statoMaxThreads));
  7428.         }
  7429.        
  7430.         // soglia      
  7431.         String numRichieste = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_SOGLIA);
  7432.         if(numRichieste!=null && !"".equals(numRichieste)){
  7433.             try{
  7434.                 long l = Long.parseLong(numRichieste);
  7435.                 if(l<=0){
  7436.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7437.                 }
  7438.                 controlloTraffico.setControlloMaxThreadsSoglia(l);
  7439.             }catch(Exception e){
  7440.                 String messaggio = "Il valore ("+numRichieste+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_SOGLIA+"' deve essere un numero intero maggiore di 0 e minore di "+Long.MAX_VALUE;
  7441.                 ControlStationCore.getLog().error(messaggio,e);
  7442.                 this.addParsingError(sbParsingError,messaggio);
  7443.             }
  7444.         }
  7445.         else{
  7446.             if(first==false)
  7447.                 controlloTraffico.setControlloMaxThreadsSoglia(null); // il check segnalera' l'errore  
  7448.         }
  7449.            
  7450.         // tipo errore
  7451.         String tipoErroreMaxThreads = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_TIPOLOGIA_ERRORE);
  7452.         if(tipoErroreMaxThreads!=null && !"".equals(tipoErroreMaxThreads)){
  7453.             try{
  7454.                 TipoErrore tipo = TipoErrore.toEnumConstant(tipoErroreMaxThreads, true);
  7455.                 controlloTraffico.setControlloMaxThreadsTipoErrore(tipo.getValue());
  7456.             }catch(Exception e){
  7457.                 String messaggio = "Il valore ("+tipoErroreMaxThreads+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_TIPOLOGIA_ERRORE+"' deve assumere uno dei seguenti valori: "+
  7458.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_ERRORE_FAULT +","+
  7459.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_ERRORE_HTTP_429 +","+
  7460.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_ERRORE_HTTP_503+","+
  7461.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_ERRORE_HTTP_500;
  7462.                 ControlStationCore.getLog().error(messaggio,e);
  7463.                 this.addParsingError(sbParsingError,messaggio);
  7464.             }
  7465.         }
  7466.         else{
  7467.             if(first){
  7468.                 if(controlloTraffico.getControlloMaxThreadsTipoErrore()==null){
  7469.                     // default
  7470.                     controlloTraffico.setControlloMaxThreadsTipoErrore(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_TIPOLOGIA_ERRORE);
  7471.                 }
  7472.             }
  7473.         }
  7474.        
  7475.         // includi descrizione
  7476.         String tipoErroreIncludiDescrizioneMaxThreads = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_TIPOLOGIA_ERRORE_DESCRIZIONE);
  7477.         if(tipoErroreMaxThreads!=null && !"".equals(tipoErroreMaxThreads)){
  7478.             controlloTraffico.setControlloMaxThreadsTipoErroreIncludiDescrizione(ServletUtils.isCheckBoxEnabled(tipoErroreIncludiDescrizioneMaxThreads));
  7479.         }
  7480.        
  7481.        
  7482.         // *** Controllo della Congestione ***
  7483.        
  7484.         // enabled
  7485.         String statoControlloCongestione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_STATO_CONTROLLO_CONGESTIONE);
  7486.         if(statoControlloCongestione!=null && !"".equals(statoControlloCongestione)){
  7487.             controlloTraffico.setControlloCongestioneEnabled(CostantiConfigurazione.ABILITATO.getValue().equals(statoControlloCongestione));
  7488.         }
  7489.        
  7490.         // threshold
  7491.         String threshold = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_THRESHOLD_CONTROLLO_CONGESTIONE);
  7492.         if(threshold!=null && !"".equals(threshold)){
  7493.             try{
  7494.                 int t = Integer.parseInt(threshold);
  7495.                 if(t<=0 || t>100){
  7496.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7497.                 }
  7498.                 controlloTraffico.setControlloCongestioneThreshold(t);
  7499.             }catch(Exception e){
  7500.                 String messaggio = "Il valore ("+threshold+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_THRESHOLD_CONTROLLO_CONGESTIONE+"' deve essere un numero compreso nell'intervallo [1,100]";
  7501.                 ControlStationCore.getLog().error(messaggio,e);
  7502.                 this.addParsingError(sbParsingError,messaggio);
  7503.             }
  7504.         }
  7505.         else{
  7506.             if(controlloTraffico.isControlloCongestioneEnabled()){
  7507.                 if(controlloTraffico.getControlloCongestioneThreshold()==null){
  7508.                     // default
  7509.                     controlloTraffico.setControlloCongestioneThreshold(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_PARAMETRO_CONTROLLO_CONGESTIONE_THRESHOLD);
  7510.                 }
  7511.             }
  7512.         }
  7513.                
  7514.         if(sbParsingError.length() > 0){
  7515.             return sbParsingError.toString();
  7516.         }
  7517.         return null;
  7518.     }
  7519.    
  7520.    
  7521.     public String readConfigurazioneRateLimitingFromHttpParameters(ConfigurazioneRateLimiting rateLimiting, boolean first) throws Exception {
  7522.        
  7523.         StringBuilder sbParsingError = new StringBuilder();
  7524.         // tipo errore
  7525.         String tipoErroreMaxThreads = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_TIPOLOGIA_ERRORE);
  7526.         if(tipoErroreMaxThreads!=null && !"".equals(tipoErroreMaxThreads)){
  7527.             try{
  7528.                 TipoErrore tipo = TipoErrore.toEnumConstant(tipoErroreMaxThreads, true);
  7529.                 rateLimiting.setTipoErrore(tipo.getValue());
  7530.             }catch(Exception e){
  7531.                 String messaggio = "Il valore ("+tipoErroreMaxThreads+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_TIPOLOGIA_ERRORE+"' deve assumere uno dei seguenti valori: "+
  7532.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_ERRORE_FAULT +","+
  7533.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_ERRORE_HTTP_429 +","+
  7534.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_ERRORE_HTTP_503+","+
  7535.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_ERRORE_HTTP_500;
  7536.                 ControlStationCore.getLog().error(messaggio,e);
  7537.                 this.addParsingError(sbParsingError,messaggio);
  7538.             }
  7539.         }
  7540.         else{
  7541.             if(first){
  7542.                 if(rateLimiting.getTipoErrore()==null){
  7543.                     // default
  7544.                     rateLimiting.setTipoErrore(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_TIPOLOGIA_ERRORE);
  7545.                 }
  7546.             }
  7547.         }
  7548.        
  7549.         // includi descrizione
  7550.         String tipoErroreIncludiDescrizioneMaxThreads = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_TIPOLOGIA_ERRORE_DESCRIZIONE);
  7551.         if(tipoErroreMaxThreads!=null && !"".equals(tipoErroreMaxThreads)){
  7552.             rateLimiting.setTipoErroreIncludiDescrizione(ServletUtils.isCheckBoxEnabled(tipoErroreIncludiDescrizioneMaxThreads));
  7553.         }
  7554.        
  7555.        
  7556.         // parametri    
  7557.         String ctModalitaSincronizzazione = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_SINCRONIZZAZIONE);
  7558.         String ctImplementazione = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_IMPLEMENTAZIONE);
  7559.         String ctContatori = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_CONTATORI);
  7560.         String ctTipologia = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_TIPOLOGIA);
  7561.         String ctHeaderHttp = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP);
  7562.         String ctHeaderHttp_limit = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_LIMIT);
  7563.         String ctHeaderHttp_remaining = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_REMAINING);
  7564.         String ctHeaderHttp_reset = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_RESET);
  7565.         String ctHeaderHttp_retryAfter = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER);
  7566.         String ctHeaderHttp_retryAfterBackoff = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER_BACKOFF_SECONDS);
  7567.        
  7568.         if(ctModalitaSincronizzazione!=null && !"".equals(ctModalitaSincronizzazione)) {
  7569.             List<Proprieta> oldList= new ArrayList<Proprieta>();
  7570.             if(rateLimiting.getProprietaList()!=null && !rateLimiting.getProprietaList().isEmpty()) {
  7571.                 for (ConfigurazioneRateLimitingProprieta rt : rateLimiting.getProprietaList()) {
  7572.                     Proprieta proprieta = new Proprieta();
  7573.                     proprieta.setNome(rt.getNome());
  7574.                     proprieta.setValore(rt.getValore());
  7575.                 }
  7576.             }
  7577.             PolicyConfiguration oldPolicyConfig = new PolicyConfiguration(oldList, this.core.getControlloTrafficoPolicyRateLimitingTipiGestori(), false);
  7578.             boolean changeImpl = false;
  7579.             if(oldPolicyConfig.getEngineType()!=null) {
  7580.                 changeImpl=!oldPolicyConfig.getEngineType().equals(ctTipologia);
  7581.             }
  7582.             else if(ctContatori!=null) {
  7583.                 changeImpl=true;
  7584.             }
  7585.            
  7586.             PolicyConfiguration policyConfig = new PolicyConfiguration();
  7587.             if(changeImpl) {
  7588.                 policyConfig.setGestorePolicyConfigDate(DateManager.getTimeMillis());
  7589.             }
  7590.             else {
  7591.                 policyConfig.setGestorePolicyConfigDate(oldPolicyConfig.getGestorePolicyConfigDate());
  7592.             }
  7593.             policyConfig.setSyncMode(ctModalitaSincronizzazione);
  7594.             policyConfig.setImpl(ctImplementazione);
  7595.             policyConfig.setCount(ctContatori);
  7596.             policyConfig.setEngineType(ctTipologia);
  7597.             policyConfig.setHttpMode(ctHeaderHttp);
  7598.             policyConfig.setHttpMode_limit(ctHeaderHttp_limit);
  7599.             policyConfig.setHttpMode_remaining(ctHeaderHttp_remaining);
  7600.             policyConfig.setHttpMode_reset(ctHeaderHttp_reset);
  7601.             policyConfig.setHttpMode_retry_after(ctHeaderHttp_retryAfter);
  7602.             policyConfig.setHttpMode_retry_after_backoff(ctHeaderHttp_retryAfterBackoff);
  7603.             List<Proprieta> list= new ArrayList<Proprieta>();
  7604.             policyConfig.saveIn(list);
  7605.             if(rateLimiting.getProprietaList()!=null) {
  7606.                 rateLimiting.getProprietaList().clear();
  7607.             }
  7608.             if(list!=null && !list.isEmpty()){
  7609.                 for (Proprieta proprieta : list) {
  7610.                     ConfigurazioneRateLimitingProprieta rtProp = new ConfigurazioneRateLimitingProprieta();
  7611.                     rtProp.setNome(proprieta.getNome());
  7612.                     rtProp.setValore(proprieta.getValore());
  7613.                     rateLimiting.addProprieta(rtProp);
  7614.                 }
  7615.             }
  7616.         }
  7617.        
  7618.         if(sbParsingError.length() > 0){
  7619.             return sbParsingError.toString();
  7620.         }
  7621.         return null;
  7622.     }
  7623.    

  7624.     public String readTempiRispostaFruizioneFromHttpParameters(TempiRispostaFruizione tempiRispostaFruizione, boolean first) throws Exception {
  7625.            
  7626.         StringBuilder sbParsingError = new StringBuilder();
  7627.         // connection-timeout
  7628.         String connectionTimeout = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT_FRUIZIONE);
  7629.         if(connectionTimeout!=null && !"".equals(connectionTimeout)){
  7630.             try{
  7631.                 int l = Integer.parseInt(connectionTimeout);
  7632.                 if(l<=0){
  7633.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7634.                 }
  7635.                 tempiRispostaFruizione.setConnectionTimeout(l);
  7636.             }catch(Exception e){
  7637.                 String messaggio = "Il valore ("+connectionTimeout+") indicato nella sezione '"+
  7638.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_FRUIZIONE
  7639.                         +"' in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT_LABEL+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  7640.                 ControlStationCore.getLog().error(messaggio,e);
  7641.                 this.addParsingError(sbParsingError,messaggio);
  7642.             }
  7643.         }
  7644.         else{
  7645.             if(first==false){
  7646.                 tempiRispostaFruizione.setConnectionTimeout(null); // il check segnalera' l'errore  
  7647.             }
  7648.         }
  7649.        
  7650.         // read-timeout
  7651.         String readTimeout = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_READ_TIMEOUT_FRUIZIONE);
  7652.         if(readTimeout!=null && !"".equals(readTimeout)){
  7653.             try{
  7654.                 int l = Integer.parseInt(readTimeout);
  7655.                 if(l<=0){
  7656.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7657.                 }
  7658.                 tempiRispostaFruizione.setReadTimeout(l);
  7659.             }catch(Exception e){
  7660.                 String messaggio = "Il valore ("+readTimeout+") indicato nella sezione '"+
  7661.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_FRUIZIONE
  7662.                         +"' in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_READ_TIMEOUT_LABEL+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  7663.                 ControlStationCore.getLog().error(messaggio,e);
  7664.                 this.addParsingError(sbParsingError,messaggio);
  7665.             }
  7666.         }
  7667.         else{
  7668.             if(first==false){
  7669.                 tempiRispostaFruizione.setReadTimeout(null); // il check segnalera' l'errore  
  7670.             }
  7671.         }
  7672.        
  7673.         // tempo medio risposta
  7674.         String tempoMedioRisposta = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_TEMPO_MEDIO_RISPOSTA_FRUIZIONE);
  7675.         if(tempoMedioRisposta!=null && !"".equals(tempoMedioRisposta)){
  7676.             try{
  7677.                 int l = Integer.parseInt(tempoMedioRisposta);
  7678.                 if(l<=0){
  7679.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7680.                 }
  7681.                 tempiRispostaFruizione.setTempoMedioRisposta(l);
  7682.             }catch(Exception e){
  7683.                 String messaggio = "Il valore ("+tempoMedioRisposta+") indicato nella sezione '"+
  7684.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_FRUIZIONE
  7685.                         +"' in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_TEMPO_MEDIO_RISPOSTA_LABEL+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  7686.                 ControlStationCore.getLog().error(messaggio,e);
  7687.                 this.addParsingError(sbParsingError,messaggio);
  7688.             }
  7689.         }
  7690.         else{
  7691.             if(first==false){
  7692.                 tempiRispostaFruizione.setTempoMedioRisposta(null); // il check segnalera' l'errore  
  7693.             }
  7694.         }
  7695.                
  7696.         if(sbParsingError.length() > 0){
  7697.             return sbParsingError.toString();
  7698.         }
  7699.         return null;
  7700.     }
  7701.    
  7702.     public String readTempiRispostaErogazioneFromHttpParameters(TempiRispostaErogazione tempiRispostaErogazione, boolean first) throws Exception {
  7703.        
  7704.         StringBuilder sbParsingError = new StringBuilder();
  7705.         // connection-timeout
  7706.         String connectionTimeout = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT_EROGAZIONE);
  7707.         if(connectionTimeout!=null && !"".equals(connectionTimeout)){
  7708.             try{
  7709.                 int l = Integer.parseInt(connectionTimeout);
  7710.                 if(l<=0){
  7711.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7712.                 }
  7713.                 tempiRispostaErogazione.setConnectionTimeout(l);
  7714.             }catch(Exception e){
  7715.                 String messaggio = "Il valore ("+connectionTimeout+") indicato nella sezione '"+
  7716.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_EROGAZIONE
  7717.                         +"' in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT_LABEL+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  7718.                 ControlStationCore.getLog().error(messaggio,e);
  7719.                 this.addParsingError(sbParsingError,messaggio);
  7720.             }
  7721.         }
  7722.         else{
  7723.             if(first==false){
  7724.                 tempiRispostaErogazione.setConnectionTimeout(null); // il check segnalera' l'errore  
  7725.             }
  7726.         }
  7727.        
  7728.         // read-timeout
  7729.         String readTimeout = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_READ_TIMEOUT_EROGAZIONE);
  7730.         if(readTimeout!=null && !"".equals(readTimeout)){
  7731.             try{
  7732.                 int l = Integer.parseInt(readTimeout);
  7733.                 if(l<=0){
  7734.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7735.                 }
  7736.                 tempiRispostaErogazione.setReadTimeout(l);
  7737.             }catch(Exception e){
  7738.                 String messaggio = "Il valore ("+readTimeout+") indicato nella sezione '"+
  7739.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_EROGAZIONE
  7740.                         +"' in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_READ_TIMEOUT_LABEL+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  7741.                 ControlStationCore.getLog().error(messaggio,e);
  7742.                 this.addParsingError(sbParsingError,messaggio);
  7743.             }
  7744.         }
  7745.         else{
  7746.             if(first==false){
  7747.                 tempiRispostaErogazione.setReadTimeout(null); // il check segnalera' l'errore  
  7748.             }
  7749.         }
  7750.        
  7751.         // tempo medio risposta
  7752.         String tempoMedioRisposta = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_TEMPO_MEDIO_RISPOSTA_EROGAZIONE);
  7753.         if(tempoMedioRisposta!=null && !"".equals(tempoMedioRisposta)){
  7754.             try{
  7755.                 int l = Integer.parseInt(tempoMedioRisposta);
  7756.                 if(l<=0){
  7757.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7758.                 }
  7759.                 tempiRispostaErogazione.setTempoMedioRisposta(l);
  7760.             }catch(Exception e){
  7761.                 String messaggio = "Il valore ("+tempoMedioRisposta+") indicato nella sezione '"+
  7762.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_EROGAZIONE
  7763.                         +"' in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_TEMPO_MEDIO_RISPOSTA_LABEL+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  7764.                 ControlStationCore.getLog().error(messaggio,e);
  7765.                 this.addParsingError(sbParsingError,messaggio);
  7766.             }
  7767.         }
  7768.         else{
  7769.             if(first==false){
  7770.                 tempiRispostaErogazione.setTempoMedioRisposta(null); // il check segnalera' l'errore  
  7771.             }
  7772.         }
  7773.                
  7774.         if(sbParsingError.length() > 0){
  7775.             return sbParsingError.toString();
  7776.         }
  7777.         return null;
  7778.     }
  7779.    
  7780.    
  7781.     public String readConfigurazioneCacheFromHttpParameters(Cache cache, boolean first) throws Exception {
  7782.        
  7783.         StringBuilder sbParsingError = new StringBuilder();
  7784.         // cache enable
  7785.         String cacheStato = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_STATO);
  7786.         //cache.setCache(ServletUtils.isCheckBoxEnabled(cacheStato));
  7787.         if(cacheStato!=null && !"".equals(cacheStato)){
  7788.             cache.setCache(CostantiConfigurazione.ABILITATO.getValue().equals(cacheStato));
  7789.         }
  7790.        
  7791.         // cache dimensione
  7792.         String cacheDimensione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_DIMENSIONE);
  7793.         if(cacheDimensione!=null && !"".equals(cacheDimensione)){
  7794.             try{
  7795.                 long l = Long.parseLong(cacheDimensione);
  7796.                 if(l<=0){
  7797.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7798.                 }
  7799.                 cache.setSize(l);
  7800.             }catch(Exception e){
  7801.                 String messaggio = "Il valore ("+cacheDimensione+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_DIMENSIONE+"' deve essere un numero intero maggiore di 0 e minore di "+Long.MAX_VALUE;
  7802.                 ControlStationCore.getLog().error(messaggio,e);
  7803.                 this.addParsingError(sbParsingError,messaggio);
  7804.             }
  7805.         }
  7806.         else{
  7807.             if(first){
  7808.                 if(cache.getSize()==null){
  7809.                     // default
  7810.                     cache.setSize(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_DIMENSIONE);
  7811.                 }
  7812.             }
  7813.             else{
  7814.                 cache.setSize(null); // il check segnalera' l'errore  
  7815.             }  
  7816.         }
  7817.        
  7818.         // cache item life
  7819.         String cacheItemLife = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_LIFE_TIME);
  7820.         if(cacheItemLife!=null && !"".equals(cacheItemLife)){
  7821.             try{
  7822.                 long l = Long.parseLong(cacheItemLife);
  7823.                 if(l<=0){
  7824.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7825.                 }
  7826.                 cache.setLifeTime(l);
  7827.             }catch(Exception e){
  7828.                 String messaggio = "Il valore ("+cacheItemLife+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_LIFE_TIME+"' deve essere un numero intero maggiore di 0 e minore di "+Long.MAX_VALUE;
  7829.                 ControlStationCore.getLog().error(messaggio,e);
  7830.                 this.addParsingError(sbParsingError,messaggio);
  7831.             }
  7832.         }
  7833.         else{
  7834.             if(first){
  7835.                 if(cache.getLifeTime()==null){
  7836.                     // default
  7837.                     //cache.setLifeTime(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_LIFE_TIME);
  7838.                 }
  7839.             }else{
  7840.                 cache.setLifeTime(null); // il check segnalera' l'errore  
  7841.             }  
  7842.         }
  7843.        
  7844.         // cache item idle
  7845.         String cacheItemIdle = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_IDLE_TIME);
  7846.         if(cacheItemIdle!=null && !"".equals(cacheItemIdle)){
  7847.             try{
  7848.                 long l = Long.parseLong(cacheItemIdle);
  7849.                 if(l<=0){
  7850.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7851.                 }
  7852.                 cache.setIdleTime(l);
  7853.             }catch(Exception e){
  7854.                 String messaggio = "Il valore ("+cacheItemIdle+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_IDLE_TIME+"' deve essere un numero intero maggiore di 0 e minore di "+Long.MAX_VALUE;
  7855.                 ControlStationCore.getLog().error(messaggio,e);
  7856.                 this.addParsingError(sbParsingError,messaggio);
  7857.             }
  7858.         }
  7859.         else{
  7860.             if(first){
  7861.                 if(cache.getIdleTime()==null){
  7862.                     // default is null
  7863.                     //cache.setCacheIdleTime(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONTROLLO_CONGESTIONE_CACHE_IDLE_TIME);
  7864.                 }
  7865.             }
  7866.             else{
  7867.                 cache.setIdleTime(null);
  7868.             }
  7869.         }
  7870.        
  7871.         // cache algorithm
  7872.         String cacheAlgorithm = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_ALGORITMO);
  7873.         if(cacheAlgorithm!=null && !"".equals(cacheAlgorithm)){
  7874.             try{
  7875.                 if(!CacheAlgorithm.LRU.name().equals(cacheAlgorithm) &&
  7876.                         !CacheAlgorithm.MRU.name().equals(cacheAlgorithm)){
  7877.                     throw new DriverControlStationException("Valore non nell'intervallo");
  7878.                 }
  7879.                 cache.setAlgorithm(CacheAlgorithm.toEnumConstant(cacheAlgorithm));
  7880.             }catch(Exception e){
  7881.                 String messaggio = "Il valore ("+cacheAlgorithm+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_ALGORITMO+"' deve assumere uno dei seguenti valori: "+
  7882.                         CacheAlgorithm.LRU.name() +","+CacheAlgorithm.MRU.name();
  7883.                 ControlStationCore.getLog().error(messaggio,e);
  7884.                 this.addParsingError(sbParsingError,messaggio);
  7885.             }
  7886.         }
  7887.         else{
  7888.             if(first){
  7889.                 if(cache.getAlgorithm()==null){
  7890.                     // default
  7891.                     cache.setAlgorithm(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_ALGORITMO);
  7892.                 }
  7893.             }
  7894.         }
  7895.        
  7896.        
  7897.         if(sbParsingError.length() > 0){
  7898.             return sbParsingError.toString();
  7899.         }
  7900.         return null;
  7901.     }
  7902.    
  7903.     public void addParsingError(StringBuilder sbParsingError, String parsingError) {
  7904.         if(sbParsingError.length() == 0)
  7905.             sbParsingError.append(parsingError);
  7906.         else
  7907.             sbParsingError.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE).append(parsingError);
  7908.     }
  7909.    
  7910.    
  7911.     public boolean checkDatiConfigurazioneControlloTraffico(TipoOperazione tipoOperazione, StringBuilder sbParsingError, org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale configurazioneControlloTraffico) throws Exception {

  7912.         // errori di parsing letti durante la read della richiesta
  7913.         if(sbParsingError.length() >0){
  7914.             this.pd.setMessage(sbParsingError.toString());
  7915.             return false;
  7916.         }
  7917.        
  7918.         if(configurazioneControlloTraffico.getControlloTraffico().getControlloMaxThreadsSoglia()==null){
  7919.             String messaggio = "Deve essere indicato un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_SOGLIA+"'";
  7920.             this.pd.setMessage(messaggio);
  7921.             return false;
  7922.         }
  7923.        
  7924.         // rate limiting
  7925.         List<Proprieta> listProprieta = new ArrayList<Proprieta>();
  7926.         if(configurazioneControlloTraffico.getRateLimiting().sizeProprietaList()>0) {
  7927.             for (ConfigurazioneRateLimitingProprieta rtProp : configurazioneControlloTraffico.getRateLimiting().getProprietaList()) {
  7928.                 Proprieta p = new Proprieta();
  7929.                 p.setNome(rtProp.getNome());
  7930.                 p.setValore(rtProp.getValore());
  7931.                 listProprieta.add(p);
  7932.             }
  7933.         }
  7934.         PolicyConfiguration policyConfig = new PolicyConfiguration(listProprieta, this.core.getControlloTrafficoPolicyRateLimitingTipiGestori(), false);
  7935.         String ctModalitaSincronizzazione = policyConfig.getSyncMode();
  7936.         String ctImplementazione = policyConfig.getImpl();
  7937.         String ctContatori = policyConfig.getCount();
  7938.         String ctTipologia = policyConfig.getEngineType();
  7939.         String ctHeaderHttp = policyConfig.getHttpMode();
  7940.         String ctHeaderHttp_limit = policyConfig.getHttpMode_limit();
  7941.         String ctHeaderHttp_remaining = policyConfig.getHttpMode_remaining();
  7942.         String ctHeaderHttp_reset = policyConfig.getHttpMode_reset();
  7943.         String ctHeaderHttp_retryAfter = policyConfig.getHttpMode_retry_after();
  7944.         String ctHeaderHttp_retryAfterBackoff = policyConfig.getHttpMode_retry_after_backoff();
  7945.        
  7946.         boolean validitaParametri = validaOpzioniAvanzateRateLimiting(null, null,
  7947.                 ctModalitaSincronizzazione, ctImplementazione, ctContatori, ctTipologia,
  7948.                 ctHeaderHttp, ctHeaderHttp_limit, ctHeaderHttp_remaining, ctHeaderHttp_reset,
  7949.                 ctHeaderHttp_retryAfter, ctHeaderHttp_retryAfterBackoff);
  7950.         if(!validitaParametri) {
  7951.             return false;
  7952.         }  
  7953.        
  7954.         // tempi risposta fruizione
  7955.        
  7956.         if(configurazioneControlloTraffico.getTempiRispostaFruizione().getConnectionTimeout()==null){
  7957.             String messaggio = "Deve essere indicato nella sezione '"+
  7958.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_FRUIZIONE
  7959.                         +"' un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT_LABEL+"'";
  7960.             this.pd.setMessage(messaggio);
  7961.             return false;
  7962.         }
  7963.        
  7964.         if(configurazioneControlloTraffico.getTempiRispostaFruizione().getReadTimeout()==null){
  7965.             String messaggio = "Deve essere indicato nella sezione '"+
  7966.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_FRUIZIONE
  7967.                         +"' un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_READ_TIMEOUT_LABEL+"'";
  7968.             this.pd.setMessage(messaggio);
  7969.             return false;
  7970.         }
  7971.        
  7972.         if(configurazioneControlloTraffico.getTempiRispostaFruizione().getTempoMedioRisposta()==null){
  7973.             String messaggio = "Deve essere indicato nella sezione '"+
  7974.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_FRUIZIONE
  7975.                         +"' un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_TEMPO_MEDIO_RISPOSTA_LABEL+"'";
  7976.             this.pd.setMessage(messaggio);
  7977.             return false;
  7978.         }
  7979.        
  7980.         // tempi risposta erogazione
  7981.        
  7982.         if(configurazioneControlloTraffico.getTempiRispostaErogazione().getConnectionTimeout()==null){
  7983.             String messaggio = "Deve essere indicato nella sezione '"+
  7984.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_EROGAZIONE
  7985.                         +"' un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT_LABEL+"'";
  7986.             this.pd.setMessage(messaggio);
  7987.             return false;
  7988.         }
  7989.        
  7990.         if(configurazioneControlloTraffico.getTempiRispostaErogazione().getReadTimeout()==null){
  7991.             String messaggio = "Deve essere indicato nella sezione '"+
  7992.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_EROGAZIONE
  7993.                         +"' un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_READ_TIMEOUT_LABEL+"'";
  7994.             this.pd.setMessage(messaggio);
  7995.             return false;
  7996.         }
  7997.        
  7998.         if(configurazioneControlloTraffico.getTempiRispostaErogazione().getTempoMedioRisposta()==null){
  7999.             String messaggio = "Deve essere indicato nella sezione '"+
  8000.                         ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TEMPI_RISPOSTA_EROGAZIONE
  8001.                         +"' un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_TEMPO_MEDIO_RISPOSTA_LABEL+"'";
  8002.             this.pd.setMessage(messaggio);
  8003.             return false;
  8004.         }
  8005.                
  8006.         // cache
  8007.        
  8008.         if(configurazioneControlloTraffico.getCache().isCache()){
  8009.            
  8010.             if(configurazioneControlloTraffico.getCache().getSize()==null){
  8011.                 String messaggio = "Deve essere indicato un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_DIMENSIONE+"'";
  8012.                 this.pd.setMessage(messaggio);
  8013.                 return false;
  8014.             }
  8015.            
  8016. //          if(configurazioneControlloTraffico.getCache().getLifeTime()==null){
  8017. //              String messaggio = "Deve essere indicato un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CACHE_DIMENSIONE+"'";
  8018. //              this.pd.setMessage(messaggio);
  8019. //              return false;
  8020. //          }
  8021.            
  8022.         }
  8023.         return true;
  8024.     }
  8025.    
  8026.     public void prepareConfigurazionePolicyList(ConsoleSearch ricerca, List<ConfigurazionePolicy> lista, int idLista) throws Exception{
  8027.         try {
  8028.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONFIGURAZIONE_POLICY);

  8029.             int limit = ricerca.getPageSize(idLista);
  8030.             int offset = ricerca.getIndexIniziale(idLista);
  8031.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);    

  8032.             this.pd.setIndex(offset);
  8033.             this.pd.setPageSize(limit);
  8034.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  8035. //
  8036. //          this.pd.setSearchDescription("");
  8037. //          this.pd.setSearch("off");
  8038.            
  8039.             String filterTipoPolicy = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_TIPO_POLICY);
  8040.             this.addFilterTipoPolicy(filterTipoPolicy,false);
  8041.            
  8042.             // setto la barra del titolo
  8043.             List<Parameter> lstParam = new ArrayList<>();

  8044.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO));
  8045.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO_POLICY, null));

  8046.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  8047.             // controllo eventuali risultati ricerca
  8048.             if (!search.equals("")) {
  8049.                 ServletUtils.enabledPageDataSearch(this.pd, "Policy", search);
  8050.             }
  8051.            
  8052.             // setto le label delle colonne
  8053.             String[] labels = {
  8054.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NOME,
  8055.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPO,
  8056.                     CostantiControlStation.LABEL_IN_USO_COLONNA_HEADER // inuso
  8057.             };
  8058.             this.pd.setLabels(labels);
  8059.        
  8060.             // preparo i dati
  8061.             List<List<DataElement>> dati = new ArrayList<>();

  8062.             if (lista != null) {
  8063.                 for (int i = 0; i < lista.size(); i++) {
  8064.                     List<DataElement> e = new ArrayList<>();
  8065.                     ConfigurazionePolicy policy = lista.get(i);
  8066.                    
  8067.                     String nDesr = policy.getDescrizione();
  8068.                    
  8069.                     Parameter pPolicyId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID, policy.getId() + "");

  8070.                     DataElement de = new DataElement();
  8071.                     de.setSize(100);
  8072.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONFIGURAZIONE_POLICY_CHANGE, pPolicyId);
  8073.                     de.setValue(policy.getIdPolicy());
  8074.                     de.setIdToRemove(""+policy.getId());
  8075.                     de.setToolTip(policy.getIdPolicy()+"\n"+nDesr);
  8076.                     e.add(de);
  8077.                    
  8078.                     de = new DataElement();
  8079.                     if(policy.isBuiltIn()) {
  8080.                         de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPO_BUILT_IN);
  8081.                     }
  8082.                     else {
  8083.                         de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPO_UTENTE);
  8084.                     }
  8085.                     e.add(de);
  8086.                    
  8087.                     this.addInUsoButtonVisualizzazioneClassica(e, policy.getIdPolicy(), policy.getId()+"", InUsoType.RATE_LIMITING_POLICY);
  8088.                    
  8089.                     dati.add(e);
  8090.                 }
  8091.             }

  8092.             this.pd.setDati(dati);
  8093.             this.pd.setAddButton(true);
  8094.            
  8095.             // preparo bottoni
  8096.             if(lista!=null && lista.size()>0){
  8097.                 if (this.core.isShowPulsantiImportExport()) {

  8098.                     ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);
  8099.                     if(exporterUtils.existsAtLeastOneExportMode(org.openspcoop2.protocol.sdk.constants.ArchiveType.CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONFIG_POLICY, this.request, this.session)){

  8100.                         List<AreaBottoni> bottoni = new ArrayList<>();

  8101.                         AreaBottoni ab = new AreaBottoni();
  8102.                         List<DataElement> otherbott = new ArrayList<>();
  8103.                         DataElement de = new DataElement();
  8104.                         de.setValue(ConfigurazioneCostanti.LABEL_CONTROLLO_TRAFFICO_CONFIG_POLICY_ESPORTA_SELEZIONATI);
  8105.                         de.setOnClick(ConfigurazioneCostanti.LABEL_CONTROLLO_TRAFFICO_CONFIG_POLICY_ESPORTA_SELEZIONATI_ONCLICK);
  8106.                         de.setDisabilitaAjaxStatus();
  8107.                         otherbott.add(de);
  8108.                         ab.setBottoni(otherbott);
  8109.                         bottoni.add(ab);

  8110.                         this.pd.setAreaBottoni(bottoni);

  8111.                     }

  8112.                 }
  8113.             }
  8114.            
  8115.         } catch (Exception e) {
  8116.             this.logError("Exception: " + e.getMessage(), e);
  8117.             throw new DriverControlStationException(e);
  8118.         }
  8119.     }

  8120.     public List<Parameter> getTitleListAttivazionePolicy(RuoloPolicy ruoloPorta, String nomePorta, ServiceBinding serviceBinding, String nomeOggetto) throws Exception{
  8121.         List<Parameter> lstParamPorta = null;
  8122.         if(ruoloPorta!=null) {
  8123.        
  8124.             String labelPerPorta = null;
  8125.             if(RuoloPolicy.DELEGATA.equals(ruoloPorta)) {
  8126.                 // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  8127.                 Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  8128.                 if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  8129.                
  8130.                 IDPortaDelegata idPortaDelegata = new IDPortaDelegata();
  8131.                 idPortaDelegata.setNome(nomePorta);
  8132.                 PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(idPortaDelegata);
  8133.                 String idporta = myPD.getNome();
  8134.                
  8135.                 MappingFruizionePortaDelegata mappingPD = this.porteDelegateCore.getMappingFruizionePortaDelegata(myPD);
  8136.                 long idSoggetto = myPD.getIdSoggetto().longValue();
  8137.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPD.getIdServizio());
  8138.                 long idFruizione = this.apsCore.getIdFruizioneAccordoServizioParteSpecifica(mappingPD.getIdFruitore(),mappingPD.getIdServizio());
  8139.                
  8140.                 PorteDelegateHelper porteDelegateHelper = new PorteDelegateHelper(this.request, this.pd, this.session);
  8141.                 lstParamPorta = porteDelegateHelper.getTitoloPD(parentPD,idSoggetto +"", idAsps+"", idFruizione+"");
  8142.                
  8143.                 if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  8144.                     labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  8145.                             ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_DI,
  8146.                             ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING,
  8147.                             myPD);
  8148.                 }
  8149.                 else {
  8150.                     labelPerPorta = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_DI+idporta;
  8151.                 }
  8152.                
  8153.             }
  8154.             else {
  8155.                 Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, this.session, this.request);
  8156.                
  8157.                 IDPortaApplicativa idPortaApplicativa = new IDPortaApplicativa();
  8158.                 idPortaApplicativa.setNome(nomePorta);
  8159.                 PortaApplicativa myPA = this.porteApplicativeCore.getPortaApplicativa(idPortaApplicativa);
  8160.                 String idporta = myPA.getNome();
  8161.                
  8162.                 MappingErogazionePortaApplicativa mappingPA = this.porteApplicativeCore.getMappingErogazionePortaApplicativa(myPA);
  8163.                 long idSoggetto = myPA.getIdSoggetto().longValue();
  8164.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPA.getIdServizio());
  8165.                
  8166.                 PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(this.request, this.pd, this.session);
  8167.                 lstParamPorta = porteApplicativeHelper.getTitoloPA(parentPA, idSoggetto+"", idAsps+"");
  8168.                
  8169.                 if(parentPA!=null && (parentPA.intValue() == PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE)) {
  8170.                     labelPerPorta = this.porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  8171.                             ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_DI,
  8172.                             ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING,
  8173.                             myPA);
  8174.                 }
  8175.                 else {
  8176.                     labelPerPorta = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_DI+idporta;
  8177.                 }
  8178.                
  8179.             }
  8180.            
  8181.             if(nomeOggetto==null) {
  8182.                 lstParamPorta.add(new Parameter(labelPerPorta,null));
  8183.             }
  8184.             else {
  8185.                 List<Parameter> list = new ArrayList<>();
  8186.                 list.add(new Parameter( ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_RUOLO_PORTA, ruoloPorta.getValue()));
  8187.                 list.add(new Parameter( ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_NOME_PORTA, nomePorta));
  8188.                 if(serviceBinding!=null) {
  8189.                     list.add(new Parameter( ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_SERVICE_BINDING,serviceBinding.name()));
  8190.                 }
  8191.                 lstParamPorta.add(new Parameter(labelPerPorta,
  8192.                         ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_LIST,
  8193.                         list
  8194.                         ));
  8195.                 lstParamPorta.add(new Parameter(nomeOggetto,null));
  8196.             }
  8197.         }
  8198.        
  8199.         return lstParamPorta;
  8200.     }
  8201.    
  8202.     public void impostaComandiMenuContestualeAttivazionePolicy(RuoloPolicy ruoloPorta, String nomePorta) throws Exception{
  8203.         if(ruoloPorta!=null) {
  8204.             if(RuoloPolicy.DELEGATA.equals(ruoloPorta)) {
  8205.                 IDPortaDelegata idPortaDelegata = new IDPortaDelegata();
  8206.                 idPortaDelegata.setNome(nomePorta);
  8207.                 PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(idPortaDelegata);
  8208.                
  8209.                 MappingFruizionePortaDelegata mappingPD = this.porteDelegateCore.getMappingFruizionePortaDelegata(myPD);
  8210.                 long idSoggetto = myPD.getIdSoggetto().longValue();
  8211.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPD.getIdServizio());
  8212.                 long idFruizione = this.apsCore.getIdFruizioneAccordoServizioParteSpecifica(mappingPD.getIdFruitore(),mappingPD.getIdServizio());
  8213.                
  8214.                 PorteDelegateHelper porteDelegateHelper = new PorteDelegateHelper(this.request, this.pd, this.session);
  8215.                 porteDelegateHelper.impostaComandiMenuContestualePD(idSoggetto +"", idAsps+"", idFruizione+"");
  8216.             }
  8217.             else {
  8218.                 IDPortaApplicativa idPortaApplicativa = new IDPortaApplicativa();
  8219.                 idPortaApplicativa.setNome(nomePorta);
  8220.                 PortaApplicativa myPA = this.porteApplicativeCore.getPortaApplicativa(idPortaApplicativa);
  8221.                
  8222.                 MappingErogazionePortaApplicativa mappingPA = this.porteApplicativeCore.getMappingErogazionePortaApplicativa(myPA);
  8223.                 long idSoggetto = myPA.getIdSoggetto().longValue();
  8224.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPA.getIdServizio());
  8225.                
  8226.                 PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(this.request, this.pd, this.session);
  8227.                 porteApplicativeHelper.impostaComandiMenuContestualePA(idSoggetto+"", idAsps+"");
  8228.             }
  8229.         }
  8230.     }
  8231.    
  8232.     public List<TipoRisorsaPolicyAttiva> gestisciCriteriFiltroRisorsaPolicy(ConsoleSearch ricerca, RuoloPolicy ruoloPorta, String nomePorta) throws Exception {
  8233.        
  8234.         int idLista = Liste.CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY;
  8235.        
  8236.         // Gestione risorsa
  8237.         List<TipoRisorsaPolicyAttiva> listaTipoRisorsa = this.confCore.attivazionePolicyTipoRisorsaList(ricerca, ruoloPorta, nomePorta);
  8238.         String filterTipoRisorsaPolicy = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_TIPO_RISORSA_POLICY);
  8239.         if(filterTipoRisorsaPolicy!=null && !"".equals(filterTipoRisorsaPolicy)) {
  8240.             TipoRisorsaPolicyAttiva filterTipoRisorsaPolicyAsObject = TipoRisorsaPolicyAttiva.toEnumConstant(filterTipoRisorsaPolicy, false);
  8241.             if(filterTipoRisorsaPolicyAsObject==null) {
  8242.                 filterTipoRisorsaPolicy = null;
  8243.             }
  8244.             else {
  8245.                 if(!listaTipoRisorsa.contains(filterTipoRisorsaPolicyAsObject)) {
  8246.                     filterTipoRisorsaPolicy = null; // in seguito ad una eliminazione
  8247.                 }
  8248.             }
  8249.         }
  8250.         // gestione default
  8251.         if(filterTipoRisorsaPolicy==null || "".equals(filterTipoRisorsaPolicy)) {
  8252.            
  8253.             TipoRisorsaPolicyAttiva defaultValue = CostantiControlStation.DEFAULT_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA_TIPO_VALUE;
  8254.             if(listaTipoRisorsa!=null && !listaTipoRisorsa.isEmpty() && !listaTipoRisorsa.contains(defaultValue)) {
  8255.                 // cerco le metriche più gettonate, altrimeni uso la prima che esiste
  8256.                 if(listaTipoRisorsa.contains(TipoRisorsaPolicyAttiva.NUMERO_RICHIESTE)) {
  8257.                     defaultValue = TipoRisorsaPolicyAttiva.NUMERO_RICHIESTE;
  8258.                 }
  8259.                 else if(listaTipoRisorsa.contains(TipoRisorsaPolicyAttiva.NUMERO_RICHIESTE_SIMULTANEE)) {
  8260.                     defaultValue = TipoRisorsaPolicyAttiva.NUMERO_RICHIESTE_SIMULTANEE;
  8261.                 }
  8262.                 else if(listaTipoRisorsa.contains(TipoRisorsaPolicyAttiva.DIMENSIONE_MASSIMA_MESSAGGIO)) {
  8263.                     defaultValue = TipoRisorsaPolicyAttiva.DIMENSIONE_MASSIMA_MESSAGGIO;
  8264.                 }
  8265.                 else if(listaTipoRisorsa.contains(TipoRisorsaPolicyAttiva.OCCUPAZIONE_BANDA)) {
  8266.                     defaultValue = TipoRisorsaPolicyAttiva.OCCUPAZIONE_BANDA;
  8267.                 }
  8268.                 else {
  8269.                     defaultValue = listaTipoRisorsa.get(0);
  8270.                 }
  8271.             }
  8272.            
  8273.             ricerca.addFilter(idLista, Filtri.FILTRO_TIPO_RISORSA_POLICY, defaultValue.getValue());
  8274.         }
  8275.        
  8276.         return listaTipoRisorsa;
  8277.     }
  8278.    
  8279.     public void prepareAttivazionePolicyList(ConsoleSearch ricerca, List<AttivazionePolicy> lista, List<TipoRisorsaPolicyAttiva> listaTipoRisorsa,
  8280.             int idLista,RuoloPolicy ruoloPorta, String nomePorta, ServiceBinding serviceBinding) throws Exception{
  8281.         try {
  8282.             List<Parameter> lstParamSession = new ArrayList<>();

  8283.             Parameter parRuoloPorta = null;
  8284.             if(ruoloPorta!=null) {
  8285.                 parRuoloPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_RUOLO_PORTA, ruoloPorta.getValue());
  8286.                 lstParamSession.add(parRuoloPorta);
  8287.             }
  8288.             Parameter parNomePorta = null;
  8289.             if(nomePorta!=null) {
  8290.                 parNomePorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_NOME_PORTA, nomePorta);
  8291.                 lstParamSession.add(parNomePorta);
  8292.             }
  8293.             Parameter parServiceBinding = null;
  8294.             if(serviceBinding!=null) {
  8295.                 parServiceBinding = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_SERVICE_BINDING, serviceBinding.name());
  8296.                 lstParamSession.add(parServiceBinding);
  8297.             }
  8298.            
  8299.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY, lstParamSession);

  8300.             List<Parameter> lstParamPorta = null;
  8301.             if(ruoloPorta!=null) {
  8302.                 lstParamPorta = getTitleListAttivazionePolicy(ruoloPorta, nomePorta, serviceBinding, null);
  8303.             }

  8304.             int limit = ricerca.getPageSize(idLista);
  8305.             int offset = ricerca.getIndexIniziale(idLista);
  8306.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);    

  8307.             this.pd.setIndex(offset);
  8308.             this.pd.setPageSize(limit);
  8309.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  8310.             String filterTipoRisorsaPolicy = null;
  8311.             if(listaTipoRisorsa!=null && !listaTipoRisorsa.isEmpty()) {
  8312.                 filterTipoRisorsaPolicy = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_TIPO_RISORSA_POLICY);
  8313.                 this.addFilterTipoRisorsaPolicy(listaTipoRisorsa,filterTipoRisorsaPolicy, false);
  8314.             }
  8315.             else {
  8316.                 this.removeFilterTipoRisorsaPolicy();
  8317.             }
  8318.            
  8319. //          this.pd.setSearchDescription("");
  8320. //          this.pd.setSearch("off");

  8321.             // controllo eventuali risultati ricerca
  8322.             if (!search.equals("") || (filterTipoRisorsaPolicy!=null && !"".equals(filterTipoRisorsaPolicy))) {
  8323.                 ServletUtils.enabledPageDataSearch(this.pd, "Policy", search);
  8324.             }
  8325.            
  8326.             boolean showMetricaColumn = false;
  8327.            
  8328.             // setto la barra del titolo
  8329.             List<Parameter> lstParam = null;
  8330.             if(lstParamPorta!=null) {
  8331.                 lstParam = lstParamPorta;
  8332.             }
  8333.             else {
  8334.                 lstParam = new ArrayList<>();
  8335.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO));
  8336.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK, null));
  8337.             }

  8338.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  8339.            
  8340.             if(ruoloPorta!=null) {
  8341.                 this.impostaComandiMenuContestualeAttivazionePolicy(ruoloPorta, nomePorta);
  8342.             }
  8343.                
  8344.             String labelSogliaColonna = null;
  8345.             TipoRisorsaPolicyAttiva tipoRisorsa = null;
  8346.             if(filterTipoRisorsaPolicy!=null && !"".equals(filterTipoRisorsaPolicy)){
  8347.                 tipoRisorsa = TipoRisorsaPolicyAttiva.toEnumConstant(filterTipoRisorsaPolicy, true);
  8348.                 switch (tipoRisorsa) {
  8349.                 case NUMERO_RICHIESTE:
  8350.                 case NUMERO_RICHIESTE_SIMULTANEE:
  8351.                 case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO:
  8352.                 case NUMERO_RICHIESTE_FALLITE:
  8353.                 case NUMERO_FAULT_APPLICATIVI:
  8354.                 case NUMERO_RICHIESTE_FALLITE_OFAULT_APPLICATIVI:
  8355.                 case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_OFAULT_APPLICATIVI:
  8356.                     //labelSogliaColonna =ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE_ESTESA;
  8357.                     labelSogliaColonna =ConfigurazioneCostanti.LABEL_POLICY_INFORMAZIONI_SOGLIA_NUMERO;
  8358.                     break;
  8359.                 case DIMENSIONE_MASSIMA_MESSAGGIO:
  8360.                     //labelSogliaColonna =ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_OCCUPAZIONE_DI_BANDA_KB_LABEL;
  8361.                     labelSogliaColonna =ConfigurazioneCostanti.LABEL_POLICY_INFORMAZIONI_SOGLIA_DIMENSIONE_MESSAGGIO;
  8362.                     break;
  8363.                 case OCCUPAZIONE_BANDA:
  8364.                     //labelSogliaColonna =ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_OCCUPAZIONE_DI_BANDA_KB_LABEL;
  8365.                     labelSogliaColonna =ConfigurazioneCostanti.LABEL_POLICY_INFORMAZIONI_SOGLIA_BANDA;
  8366.                     break;
  8367.                 case TEMPO_MEDIO_RISPOSTA:
  8368.                     //labelSogliaColonna =ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_MS_LABEL;
  8369.                     labelSogliaColonna =ConfigurazioneCostanti.LABEL_POLICY_INFORMAZIONI_SOGLIA_TEMPI_MS;
  8370.                     break;
  8371.                 case TEMPO_COMPLESSIVO_RISPOSTA:
  8372.                     //labelSogliaColonna =ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_MS_LABEL;
  8373.                     labelSogliaColonna =ConfigurazioneCostanti.LABEL_POLICY_INFORMAZIONI_SOGLIA_TEMPI_SECONDI;
  8374.                     break;
  8375.                 }
  8376.             }
  8377.            
  8378.            
  8379.             // setto le label delle colonne
  8380.             List<String> lstLabels = new ArrayList<>();
  8381.             if(lista != null && lista.size() > 1) {
  8382.                 lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POSIZIONE);
  8383.             }
  8384.             lstLabels.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO);
  8385.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NOME);
  8386.             if(labelSogliaColonna!=null) {
  8387.                 lstLabels.add(labelSogliaColonna);
  8388.             }
  8389.             if(showMetricaColumn) {
  8390.                 if((filterTipoRisorsaPolicy==null || "".equals(filterTipoRisorsaPolicy))) {
  8391.                     lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_RISORSA);
  8392.                 }
  8393.             }
  8394.             if(!TipoRisorsaPolicyAttiva.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)) {
  8395.                 lstLabels.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RUNTIME);
  8396.             }
  8397.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_CONTINUE);
  8398.             //lstLabels.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILTRO);
  8399.             //lstLabels.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RAGGRUPPAMENTO_COLUMN);
  8400.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));
  8401.            
  8402.             // preparo i dati
  8403.             List<List<DataElement>> dati = new ArrayList<>();

  8404.             if (lista != null) {
  8405.                
  8406.                 int numeroElementi = lista.size();
  8407.                
  8408.                 Integer sizeColumn = null;
  8409.                
  8410.                 for (int i = 0; i < lista.size(); i++) {
  8411.                     AttivazionePolicy policy = lista.get(i);
  8412.                     List<DataElement> e = new ArrayList<>();
  8413.                    
  8414.                     // Fix retrocompatibilita dove il nome non era obbligatorio.
  8415.                     policy.setAlias(PolicyUtilities.getNomeActivePolicy(policy.getAlias(), policy.getIdActivePolicy()));
  8416.                    
  8417.                     String descrizionePolicy = "";
  8418.                     try{
  8419.                         descrizionePolicy = this.confCore.getInfoPolicy(policy.getIdPolicy()).getDescrizione();
  8420.                     }catch(Exception ex){
  8421.                         ControlStationCore.getLog().error(ex.getMessage(),ex);
  8422.                     }
  8423.                     String nDescr = "";
  8424.                     if(StringUtils.isNotEmpty(policy.getAlias())) {
  8425.                         nDescr = policy.getAlias();
  8426.                     }
  8427.                     nDescr = nDescr + "\n"+"Identificativo Runtime: "+ policy.getIdActivePolicy();  
  8428.                     nDescr = nDescr + "\n"+"Policy: "+ policy.getIdPolicy();
  8429.                     nDescr = nDescr+"\n"+descrizionePolicy;
  8430.                                        
  8431.                    
  8432.                     Parameter pPolicyId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID, policy.getId() + "");
  8433.                     Parameter pPolicyRisorsa = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA, filterTipoRisorsaPolicy);



  8434.                     // Posizione
  8435.                     if(lista.size() > 1) {
  8436.                         DataElement de = new DataElement();
  8437.                         de.setWidthPx(48);
  8438.                         de.setType(DataElementType.IMAGE);
  8439.                         DataElementImage imageUp = new DataElementImage();
  8440.                         Parameter pDirezioneSu = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POSIZIONE,
  8441.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SU);
  8442.                         Parameter pDirezioneGiu = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POSIZIONE,
  8443.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_GIU);
  8444.                                
  8445.                         if(i > 0) {
  8446.                             imageUp.setImage(CostantiControlStation.ICONA_FRECCIA_SU);
  8447.                             imageUp.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_SU);
  8448.                             List<Parameter> listP = new ArrayList<>();
  8449.                             listP.add(pPolicyId);
  8450.                             listP.add(pPolicyRisorsa);
  8451.                             if(ruoloPorta!=null) {
  8452.                                 listP.add(parRuoloPorta);
  8453.                                 listP.add(parNomePorta);
  8454.                                 listP.add(parServiceBinding);
  8455.                             }
  8456.                             listP.add(pDirezioneSu);
  8457.                             imageUp.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_LIST, listP.toArray(new Parameter[1]));
  8458.                         }
  8459.                         else {
  8460.                             imageUp.setImage(CostantiControlStation.ICONA_PLACEHOLDER);
  8461.                         }
  8462.                         de.addImage(imageUp);
  8463.                        
  8464.                         if(i < numeroElementi -1) {
  8465.                             DataElementImage imageDown = new DataElementImage();
  8466.                             imageDown.setImage(CostantiControlStation.ICONA_FRECCIA_GIU);
  8467.                             imageDown.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_GIU);
  8468.                             List<Parameter> listP = new ArrayList<>();
  8469.                             listP.add(pPolicyId);
  8470.                             listP.add(pPolicyRisorsa);
  8471.                             if(ruoloPorta!=null) {
  8472.                                 listP.add(parRuoloPorta);
  8473.                                 listP.add(parNomePorta);
  8474.                                 listP.add(parServiceBinding);
  8475.                             }
  8476.                             listP.add(pDirezioneGiu);
  8477.                             imageDown.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_LIST, listP.toArray(new Parameter[1]));
  8478.                             de.addImage(imageDown);
  8479.                         }
  8480.                         de.setValue(policy.getPosizione()+"");
  8481.                         e.add(de);
  8482.                     }
  8483.                                        
  8484.                     // Stato
  8485.                     DataElement de = new DataElement();
  8486.                     de.setWidthPx(10);
  8487.                     de.setType(DataElementType.CHECKBOX);
  8488.                     if(policy.isEnabled()){
  8489.                         if(policy.isWarningOnly()){
  8490.                             de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_WARNING_ONLY);
  8491.                             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_WARNING_ONLY);
  8492.                             de.setSelected(CheckboxStatusType.CONFIG_WARNING);
  8493.                         }
  8494.                         else{
  8495.                             de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  8496.                             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  8497.                             de.setSelected(CheckboxStatusType.CONFIG_ENABLE);
  8498.                         }
  8499.                     }
  8500.                     else{
  8501.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  8502.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  8503.                         de.setSelected(CheckboxStatusType.CONFIG_DISABLE);
  8504.                     }
  8505.                     if(ruoloPorta!=null) {
  8506.                         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId, parRuoloPorta, parNomePorta, parServiceBinding);
  8507.                     }
  8508.                     else {
  8509.                         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId);
  8510.                     }
  8511.                     e.add(de);
  8512.                    
  8513.                    
  8514.                     // nome
  8515.                     de = new DataElement();
  8516.                     if(ruoloPorta!=null) {
  8517.                         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId, parRuoloPorta, parNomePorta, parServiceBinding);
  8518.                     }
  8519.                     else {
  8520.                         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId);
  8521.                     }
  8522.                    
  8523.                     if(StringUtils.isNotEmpty(policy.getAlias()))
  8524.                         de.setValue(policy.getAlias());
  8525.                     else
  8526.                         de.setValue(policy.getIdActivePolicy());
  8527.                    
  8528.                     de.setIdToRemove(""+policy.getId());
  8529.                     de.setToolTip(nDescr);
  8530.                     e.add(de);

  8531.                    
  8532.                     ConfigurazionePolicy configPolicy = null;
  8533.                    
  8534.                    
  8535.                     // Soglia
  8536.                     if(labelSogliaColonna!=null) {
  8537.                         de = new DataElement();
  8538.                        
  8539.                         Integer maxLength = null;
  8540.                         if(TipoRisorsaPolicyAttiva.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)) {
  8541.                             String vReq = null;
  8542.                             String vRes = null;
  8543.                             if(policy.isRidefinisci()) {
  8544.                                 vReq = policy.getValore2()+"";
  8545.                                 vRes = policy.getValore()+"";
  8546.                             }
  8547.                             else {
  8548.                                 if(configPolicy==null) {
  8549.                                     configPolicy = this.confCore.getConfigurazionePolicy(policy.getIdPolicy());
  8550.                                 }
  8551.                                 vReq = configPolicy.getValore2()+"";
  8552.                                 vRes = configPolicy.getValore()+"";
  8553.                             }
  8554.                             if(vReq.length()>vRes.length()) {
  8555.                                 maxLength = vReq.length();
  8556.                             }
  8557.                             else {
  8558.                                 maxLength = vRes.length();
  8559.                             }
  8560.                             String rigaRichiesta = "richiesta: "+vReq;
  8561.                             String rigaRisposta = "risposta:  "+vRes;
  8562.                             de.setValue(rigaRichiesta+"<BR/>"+rigaRisposta);
  8563.                         }
  8564.                         else {
  8565.                             if(policy.isRidefinisci()) {
  8566.                                 de.setValue(policy.getValore()+"");
  8567.                             }
  8568.                             else {
  8569.                                 if(configPolicy==null) {
  8570.                                     configPolicy = this.confCore.getConfigurazionePolicy(policy.getIdPolicy());
  8571.                                 }
  8572.                                 de.setValue(configPolicy.getValore()+"");
  8573.                             }
  8574.                         }
  8575.                        
  8576.                        
  8577.                         int checkLength = de.getValue().length();
  8578.                         int guiPrefix = 0;
  8579.                         if(maxLength!=null) {
  8580.                             checkLength = maxLength;
  8581.                             guiPrefix=50;
  8582.                         }
  8583.                        
  8584.                         if(sizeColumn==null) {
  8585.                             de.setWidthPx(guiPrefix+70);
  8586.                             sizeColumn = guiPrefix+70;
  8587.                         }
  8588.                         if(checkLength>(12)) {
  8589.                             if(sizeColumn<(guiPrefix+110)) {
  8590.                                 de.setWidthPx(guiPrefix+110);
  8591.                                 sizeColumn = guiPrefix+110;
  8592.                             }
  8593.                         }
  8594.                         else if(checkLength>(9)) {
  8595.                             if(sizeColumn<(guiPrefix+90)) {
  8596.                                 de.setWidthPx(guiPrefix+90);
  8597.                                 sizeColumn = guiPrefix+90;
  8598.                             }
  8599.                         }
  8600.                        
  8601.                         de.allineaTdAlCentro();
  8602.                         e.add(de);
  8603.                     }
  8604.                    
  8605.                    
  8606.                     // Tipo Risorsa
  8607.                                    
  8608.                     if(showMetricaColumn) {
  8609.                         if((filterTipoRisorsaPolicy==null || "".equals(filterTipoRisorsaPolicy))) {
  8610.                        
  8611.                             if(configPolicy==null) {
  8612.                                 configPolicy = this.confCore.getConfigurazionePolicy(policy.getIdPolicy());
  8613.                             }
  8614.                             TipoRisorsaPolicyAttiva tipoRisorsaPolicyAttiva = TipoRisorsaPolicyAttiva.getTipo(configPolicy.getRisorsa(),configPolicy.isSimultanee());
  8615.                             String labelRisorsaPolicyAttiva = this.getLabelTipoRisorsaPolicyAttiva(tipoRisorsaPolicyAttiva);                            
  8616.                             de = new DataElement();
  8617.                             de.setValue(labelRisorsaPolicyAttiva);
  8618.                             e.add(de);
  8619.                            
  8620.                         }
  8621.                     }
  8622.                    
  8623.                                        
  8624.                     if(!TipoRisorsaPolicyAttiva.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)) {
  8625.                         de = new DataElement();
  8626.                         if(policy.isEnabled()){
  8627.                             de.setValue("Visualizza");
  8628.                         }
  8629.                         else{
  8630.                             de.setValue("-");
  8631.                         }
  8632.                         de.allineaTdAlCentro();
  8633.                         de.setWidthPx(60);
  8634.    
  8635.                         Parameter pJmx = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE, true+"");
  8636.                         if(policy.isEnabled()){
  8637.                             if(ruoloPorta!=null) {
  8638.                                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId,pJmx, parRuoloPorta, parNomePorta, parServiceBinding);
  8639.                             }
  8640.                             else {
  8641.                                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId,pJmx);
  8642.                             }
  8643.                         }
  8644.                         e.add(de);
  8645.                     }
  8646.                                
  8647.                    
  8648.                    
  8649.                     // Continue
  8650.                    
  8651.                     de = new DataElement();
  8652.                     de.setWidthPx(24);
  8653.                     de.setType(DataElementType.IMAGE);
  8654.                    
  8655.                     DataElementImage imageUp = new DataElementImage();
  8656.                     if(policy.isContinuaValutazione()) {
  8657.                         imageUp.setImage(CostantiControlStation.ICONA_CONTINUE);
  8658.                         imageUp.setToolTip(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_CONTINUE_PROSEGUI_TOOLTIP);
  8659.                     }
  8660.                     else {
  8661.                         imageUp.setImage(CostantiControlStation.ICONA_BREAK);
  8662.                         imageUp.setToolTip(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_CONTINUE_INTERROMPI_TOOLTIP);
  8663.                     }
  8664.                     if(ruoloPorta!=null) {
  8665.                         imageUp.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId, parRuoloPorta, parNomePorta, parServiceBinding);
  8666.                     }
  8667.                     else {
  8668.                         imageUp.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId);
  8669.                     }
  8670.                     de.addImage(imageUp);
  8671.                    
  8672.                     de.allineaTdAlCentro();
  8673.                    
  8674.                     de.setValue(policy.getPosizione()+"");
  8675.                     e.add(de);
  8676.                    
  8677.                    
  8678. //                  de = new DataElement();
  8679. //                  String filtro = this.toStringCompactFilter(policy.getFiltro(),ruoloPorta,nomePorta);
  8680. //                  if(filtro.length()>60){
  8681. //                      de.setValue(filtro.substring(0,57)+"...");
  8682. //                  }else{
  8683. //                      de.setValue(filtro);
  8684. //                  }
  8685. //                  de.setToolTip(filtro);
  8686. //                  if(ruoloPorta!=null) {
  8687. //                      de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId, parRuoloPorta, parNomePorta, parServiceBinding);
  8688. //                  }
  8689. //                  else {
  8690. //                      de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId);
  8691. //                  }
  8692. //                  e.add(de);
  8693. //                  
  8694. //                  de = new DataElement();
  8695. //                  String groupBy = this.toStringCompactGroupBy(policy.getGroupBy(),ruoloPorta,nomePorta);
  8696. //                  if(groupBy.length()>60){
  8697. //                      de.setValue(groupBy.substring(0,57)+"...");
  8698. //                  }else{
  8699. //                      de.setValue(groupBy);
  8700. //                  }
  8701. //                  de.setToolTip(groupBy);
  8702. //                  if(ruoloPorta!=null) {
  8703. //                      de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId, parRuoloPorta, parNomePorta, parServiceBinding);
  8704. //                  }
  8705. //                  else {
  8706. //                      de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE, pPolicyId);
  8707. //                  }
  8708. //                  e.add(de);
  8709.                    
  8710.                     dati.add(e);
  8711.                 }
  8712.             }

  8713.             this.pd.setDati(dati);
  8714.             this.pd.setAddButton(true);
  8715.            
  8716.             // preparo bottoni
  8717.             if(lista!=null && lista.size()>0){
  8718.                 if (this.core.isShowPulsantiImportExport() && (nomePorta==null || StringUtils.isEmpty(nomePorta))) {

  8719.                     ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);
  8720.                     if(exporterUtils.existsAtLeastOneExportMode(org.openspcoop2.protocol.sdk.constants.ArchiveType.CONFIGURAZIONE_CONTROLLO_TRAFFICO_ACTIVE_POLICY, this.request, this.session)){

  8721.                         List<AreaBottoni> bottoni = new ArrayList<>();

  8722.                         AreaBottoni ab = new AreaBottoni();
  8723.                         List<DataElement> otherbott = new ArrayList<>();
  8724.                         DataElement de = new DataElement();
  8725.                         de.setValue(ConfigurazioneCostanti.LABEL_CONTROLLO_TRAFFICO_ACTIVE_POLICY_ESPORTA_SELEZIONATI);
  8726.                         de.setOnClick(ConfigurazioneCostanti.LABEL_CONTROLLO_TRAFFICO_ACTIVE_POLICY_ESPORTA_SELEZIONATI_ONCLICK);
  8727.                         de.setDisabilitaAjaxStatus();
  8728.                         otherbott.add(de);
  8729.                         ab.setBottoni(otherbott);
  8730.                         bottoni.add(ab);

  8731.                         this.pd.setAreaBottoni(bottoni);

  8732.                     }

  8733.                 }
  8734.             }
  8735.            
  8736.         } catch (Exception e) {
  8737.             this.logError("Exception: " + e.getMessage(), e);
  8738.             throw new DriverControlStationException(e);
  8739.         }
  8740.     }
  8741.    
  8742.     public String toStringCompactFilter(AttivazionePolicyFiltro filtro, RuoloPolicy ruoloPorta, String nomePorta, ServiceBinding serviceBinding) throws Exception {
  8743.        
  8744.         boolean delegata = false;
  8745.         boolean applicativa = false;
  8746.         boolean configurazione = false;
  8747.         if(ruoloPorta!=null) {
  8748.             if(RuoloPolicy.DELEGATA.equals(ruoloPorta)) {
  8749.                 delegata = (nomePorta!=null);
  8750.             }
  8751.             else if(RuoloPolicy.APPLICATIVA.equals(ruoloPorta)) {
  8752.                 applicativa = (nomePorta!=null);
  8753.             }
  8754.         }
  8755.         configurazione = !delegata && !applicativa;
  8756.        
  8757.         StringBuilder bf = new StringBuilder("");
  8758.         if(filtro.isEnabled()){

  8759.             if(configurazione) {
  8760.                 if( (filtro.getRuoloPorta()!=null && !RuoloPolicy.ENTRAMBI.equals(filtro.getRuoloPorta())) ){
  8761.                     if(bf.length()>0){
  8762.                         bf.append(", ");
  8763.                     }
  8764.                     if(RuoloPolicy.DELEGATA.equals(filtro.getRuoloPorta())){
  8765.                         bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_PDD).append(": ");
  8766.                         bf.append(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RUOLO_PORTA_DELEGATA);
  8767.                     }
  8768.                     else if(RuoloPolicy.APPLICATIVA.equals(filtro.getRuoloPorta())){
  8769.                         bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_PDD).append(": ");
  8770.                         bf.append(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RUOLO_PORTA_APPLICATIVA);
  8771.                     }
  8772.                 }
  8773.             }

  8774.             if(configurazione) {
  8775.                 if( !(filtro.getProtocollo()==null || "".equals(filtro.getProtocollo())) ){
  8776.                     if(bf.length()>0){
  8777.                         bf.append(", ");
  8778.                     }
  8779.                     bf.append(CostantiControlStation.LABEL_PARAMETRO_PROTOCOLLO_COMPACT+": ");
  8780.                     bf.append(this.getLabelProtocollo(filtro.getProtocollo()));
  8781.                 }
  8782.             }
  8783.                
  8784.             if(configurazione) {
  8785.                 if( !(filtro.getNomePorta()==null || "".equals(filtro.getNomePorta())) ){
  8786.                     if(bf.length()>0){
  8787.                         bf.append(", ");
  8788.                     }
  8789.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PORTA).append(": ");
  8790.                     bf.append(filtro.getNomePorta());
  8791.                 }
  8792.             }
  8793.                        
  8794.             if(configurazione) {
  8795.                 if(filtro.getRuoloErogatore()!=null) {
  8796.                     if(bf.length()>0){
  8797.                         bf.append(", ");
  8798.                     }
  8799.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_EROGATORE).append(": ");
  8800.                     bf.append(filtro.getRuoloErogatore());
  8801.                 }
  8802.                 else if( !( (filtro.getTipoErogatore()==null || "".equals(filtro.getTipoErogatore()))
  8803.                         ||
  8804.                         (filtro.getNomeErogatore()==null || "".equals(filtro.getNomeErogatore())) ) ){
  8805.                     if(bf.length()>0){
  8806.                         bf.append(", ");
  8807.                     }
  8808.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_EROGATORE_COMPACT).append(": ");
  8809.                     IDSoggetto idSoggetto = new IDSoggetto(filtro.getTipoErogatore(), filtro.getNomeErogatore());
  8810.                     bf.append(this.getLabelNomeSoggetto(idSoggetto));
  8811.                 }
  8812.             }

  8813.             if(configurazione) {
  8814.                 if( !(filtro.getTag()==null || "".equals(filtro.getTag())) ){
  8815.                     if(bf.length()>0){
  8816.                         bf.append(", ");
  8817.                     }
  8818.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TAG).append(": ");
  8819.                     bf.append(filtro.getTag());
  8820.                 }
  8821.             }
  8822.            
  8823.             if(configurazione) {
  8824.                 if( !( (filtro.getTipoServizio()==null || "".equals(filtro.getTipoServizio()))
  8825.                         ||
  8826.                         (filtro.getNomeServizio()==null || "".equals(filtro.getNomeServizio()))
  8827.                         ||
  8828.                         (filtro.getVersioneServizio()==null)
  8829.                         ||
  8830.                         (filtro.getTipoErogatore()==null || "".equals(filtro.getTipoErogatore()))
  8831.                         ||
  8832.                         (filtro.getNomeErogatore()==null || "".equals(filtro.getNomeErogatore()))
  8833.                         ) ){
  8834.                     if(bf.length()>0){
  8835.                         bf.append(", ");
  8836.                     }
  8837.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SERVIZIO).append(": ");
  8838.                     IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(filtro.getTipoServizio(), filtro.getNomeServizio(),
  8839.                             filtro.getTipoErogatore(), filtro.getNomeErogatore(),
  8840.                             filtro.getVersioneServizio());
  8841.                     bf.append(this.getLabelIdServizio(idServizio));
  8842.                 }
  8843.             }
  8844.            
  8845.             if( !(filtro.getAzione()==null || "".equals(filtro.getAzione())) ){
  8846.                 if(bf.length()>0){
  8847.                     bf.append(", ");
  8848.                 }
  8849.                 bf.append(this.getLabelAzione(serviceBinding)).append(": ");
  8850.                 bf.append(filtro.getAzione());
  8851.             }
  8852.            
  8853.             if(configurazione) {
  8854.                 if( !(filtro.getServizioApplicativoErogatore()==null || "".equals(filtro.getServizioApplicativoErogatore())) ){
  8855.                     if(bf.length()>0){
  8856.                         bf.append(", ");
  8857.                     }
  8858.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_EROGATORE).append(": ");
  8859.                     bf.append(filtro.getServizioApplicativoErogatore());
  8860.                 }
  8861.             }
  8862.            
  8863.             if(configurazione || applicativa) {
  8864.                 if(filtro.getRuoloFruitore()!=null) {
  8865.                     if(bf.length()>0){
  8866.                         bf.append(", ");
  8867.                     }
  8868.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_FRUITORE).append(": ");
  8869.                     bf.append(filtro.getRuoloFruitore());
  8870.                 }
  8871.                 else if( !( (filtro.getTipoFruitore()==null || "".equals(filtro.getTipoFruitore()))
  8872.                         ||
  8873.                         (filtro.getNomeFruitore()==null || "".equals(filtro.getNomeFruitore())) ) ){
  8874.                     if(bf.length()>0){
  8875.                         bf.append(", ");
  8876.                     }
  8877.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_FRUITORE_COMPACT).append(": ");
  8878.                     IDSoggetto idSoggetto = new IDSoggetto(filtro.getTipoFruitore(), filtro.getNomeFruitore());
  8879.                     bf.append(this.getLabelNomeSoggetto(idSoggetto));
  8880.                 }
  8881.                 if(configurazione) {
  8882.                     if( !(filtro.getServizioApplicativoFruitore()==null || "".equals(filtro.getServizioApplicativoFruitore())) ){
  8883.                         if(bf.length()>0){
  8884.                             bf.append(", ");
  8885.                         }
  8886.                         bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE_COMPACT).append(": ");
  8887.                         bf.append(filtro.getServizioApplicativoFruitore());
  8888.                     }
  8889.                 }
  8890.             }
  8891.             else if(delegata) {
  8892.                 if(filtro.getRuoloFruitore()!=null) {
  8893.                     if(bf.length()>0){
  8894.                         bf.append(", ");
  8895.                     }
  8896.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_FRUITORE).append(": ");
  8897.                     bf.append(filtro.getRuoloFruitore());
  8898.                 }
  8899.                 else if( !(filtro.getServizioApplicativoFruitore()==null || "".equals(filtro.getServizioApplicativoFruitore())) ){
  8900.                     if(bf.length()>0){
  8901.                         bf.append(", ");
  8902.                     }
  8903.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE_COMPACT).append(": ");
  8904.                     bf.append(filtro.getServizioApplicativoFruitore());
  8905.                 }
  8906.             }
  8907.            
  8908.             if(filtro.getTokenClaims()!=null){
  8909.                 Properties properties = PropertiesUtilities.convertTextToProperties(filtro.getTokenClaims());
  8910.                 if(properties!=null && properties.size()>0) {
  8911.                     for (Object o : properties.keySet()) {
  8912.                         if(o!=null && o instanceof String) {
  8913.                             String key = (String) o;
  8914.                             String value = properties.getProperty(key);
  8915.                             if(bf.length()>0){
  8916.                                 bf.append(", ");
  8917.                             }
  8918.                             bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TOKEN_CLAIMS_PREFIX).append(key).append(": ");
  8919.                             bf.append(value);          
  8920.                         }
  8921.                     }
  8922.                 }
  8923.             }
  8924.            
  8925.             if(filtro.isInformazioneApplicativaEnabled()){
  8926.                 if(bf.length()>0){
  8927.                     bf.append(", ");
  8928.                 }
  8929.                 bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED_COMPACT).append(": ");
  8930.                 bf.append(filtro.getInformazioneApplicativaTipo());
  8931.             }

  8932.         }
  8933.         else{
  8934.             bf.append(CostantiControlStation.LABEL_STATO_DISABILITATO);
  8935.         }

  8936.         if(bf.length()<=0 && (delegata || applicativa)) {
  8937.             bf.append(CostantiControlStation.LABEL_STATO_DISABILITATO);
  8938.         }
  8939.        
  8940.         return bf.toString();
  8941.     }
  8942.    
  8943.     public String toStringCompactGroupBy(AttivazionePolicyRaggruppamento groupBy, RuoloPolicy ruoloPorta, String nomePorta, ServiceBinding serviceBinding) {
  8944.        
  8945.         boolean delegata = false;
  8946.         boolean applicativa = false;
  8947.         boolean configurazione = false;
  8948.         if(ruoloPorta!=null) {
  8949.             if(RuoloPolicy.DELEGATA.equals(ruoloPorta)) {
  8950.                 delegata = (nomePorta!=null);
  8951.             }
  8952.             else if(RuoloPolicy.APPLICATIVA.equals(ruoloPorta)) {
  8953.                 applicativa = (nomePorta!=null);
  8954.             }
  8955.         }
  8956.         configurazione = !delegata && !applicativa;
  8957.        
  8958.         StringBuilder bf = new StringBuilder("");
  8959.         if(groupBy.isEnabled()){

  8960.             if(configurazione) {
  8961.                 if(groupBy.isRuoloPorta()){
  8962.                     if(bf.length()>0){
  8963.                         bf.append(", ");
  8964.                     }
  8965.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_RUOLO_PDD_LABEL);
  8966.                 }
  8967.             }
  8968.            
  8969.             if(configurazione) {
  8970.                 if(groupBy.isProtocollo()){
  8971.                     if(bf.length()>0){
  8972.                         bf.append(", ");
  8973.                     }
  8974.                     bf.append(CostantiControlStation.LABEL_PARAMETRO_PROTOCOLLO_COMPACT);
  8975.                 }
  8976.             }
  8977.            
  8978.             if(configurazione) {
  8979.                 if(groupBy.isErogatore()){
  8980.                     if(bf.length()>0){
  8981.                         bf.append(", ");
  8982.                     }
  8983.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_EROGATORE_COMPACT);
  8984.                 }
  8985.             }
  8986.            
  8987.             if(configurazione) {
  8988.                 if(groupBy.isServizio()){
  8989.                     if(bf.length()>0){
  8990.                         bf.append(", ");
  8991.                     }
  8992.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SERVIZIO);
  8993.                 }
  8994.             }
  8995.            
  8996.             if(groupBy.isAzione()){
  8997.                 if(bf.length()>0){
  8998.                     bf.append(", ");
  8999.                 }
  9000.                 bf.append(this.getLabelAzione(serviceBinding));
  9001.             }
  9002.            
  9003.             if(configurazione) {
  9004.                 if(groupBy.isServizioApplicativoErogatore()){
  9005.                     if(bf.length()>0){
  9006.                         bf.append(", ");
  9007.                     }
  9008.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SA_EROGATORE);
  9009.                 }
  9010.             }
  9011.            
  9012.             if(configurazione) {
  9013.                 if(groupBy.isFruitore()){
  9014.                     if(bf.length()>0){
  9015.                         bf.append(", ");
  9016.                     }
  9017.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_FRUITORE_COMPACT);
  9018.                 }
  9019.             }
  9020.            
  9021.             if(configurazione) {
  9022.                 if(groupBy.isServizioApplicativoFruitore()){
  9023.                     if(bf.length()>0){
  9024.                         bf.append(", ");
  9025.                     }
  9026.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SA_FRUITORE_COMPACT);
  9027.                 }
  9028.             }
  9029.            
  9030.             if(!configurazione) {
  9031.                 if(groupBy.isServizioApplicativoFruitore() || groupBy.isFruitore() || groupBy.isIdentificativoAutenticato()){
  9032.                     if(bf.length()>0){
  9033.                         bf.append(", ");
  9034.                     }
  9035.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_RICHIEDENTE);
  9036.                 }
  9037.             }
  9038.            
  9039.             if(groupBy.getToken()!=null){
  9040.                 String [] tmp = groupBy.getToken().split(",");
  9041.                 if(tmp!=null && tmp.length>0) {
  9042.                     for (int i = 0; i < tmp.length; i++) {
  9043.                         if(bf.length()>0){
  9044.                             bf.append(", ");
  9045.                         }
  9046.                         bf.append(tmp[i]);  
  9047.                     }
  9048.                 }
  9049.             }
  9050.            
  9051.             if(groupBy.isInformazioneApplicativaEnabled()){
  9052.                 if(bf.length()>0){
  9053.                     bf.append(", ");
  9054.                 }
  9055.                 bf.append("Chiave:");
  9056.                 bf.append(groupBy.getInformazioneApplicativaTipo());
  9057.             }

  9058.         }
  9059.         else{
  9060.             bf.append(CostantiControlStation.LABEL_STATO_DISABILITATO);
  9061.         }

  9062.         return bf.toString();
  9063.     }
  9064.    
  9065.     public String readDatiGeneraliPolicyFromHttpParameters(ConfigurazionePolicy policy, boolean first) throws Exception {
  9066.            
  9067.         StringBuilder sbParsingError = new StringBuilder();
  9068.         // id
  9069.         String id = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID);
  9070.         if(id!=null && !"".equals(id)){
  9071.             try{
  9072.                 long l = Long.parseLong(id);
  9073.                 if(l<=0){
  9074.                     throw new DriverControlStationException("Valore non nell'intervallo");
  9075.                 }
  9076.                 policy.setId(l);
  9077.             }catch(Exception e){
  9078.                 String messaggio = "Il valore ("+id+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID+"' deve essere un numero intero maggiore di 0 e minore di "+Long.MAX_VALUE;
  9079.                 this.logError(messaggio,e);
  9080.                 this.addParsingError(sbParsingError,messaggio);
  9081.             }
  9082.         }
  9083.        
  9084.        
  9085.         // risorsa
  9086.         String valoreDataElementRisorsa = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA);
  9087.         if(valoreDataElementRisorsa!=null && !"".equals(valoreDataElementRisorsa)){
  9088.             try{
  9089.                 TipoRisorsa tipoRisorsa = this.getTipoRisorsa(valoreDataElementRisorsa, this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA_ESITI));
  9090.                 policy.setRisorsa(tipoRisorsa.getValue());
  9091.                 policy.setSimultanee(this.isTipoRisorsaNumeroRichiesteSimultanee(valoreDataElementRisorsa));
  9092.             }catch(Exception e){
  9093.                 String messaggio = "Il valore ("+valoreDataElementRisorsa+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA+"' non è tra i tipi di risorsa gestiti";
  9094.                 this.logError(messaggio,e);
  9095.                 this.addParsingError(sbParsingError,messaggio);
  9096.             }
  9097.         }
  9098.        
  9099.         if(sbParsingError.length() > 0){
  9100.             return sbParsingError.toString();
  9101.         }
  9102.         return null;
  9103.     }
  9104.    
  9105.     public String readValoriSogliaPolicyFromHttpParameters(ConfigurazionePolicy policy, boolean first) throws Exception {
  9106.            
  9107.         StringBuilder sbParsingError = new StringBuilder();
  9108.        
  9109. //      // richiesteSimultanee
  9110. //      String simultanee = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_RICHIESTE_SIMULTANEE);
  9111. //      if(first==false){
  9112. //          if(TipoRisorsa.NUMERO_RICHIESTE.getValue().equals(policy.getRisorsa())){
  9113. //              policy.setSimultanee(ServletUtils.isCheckBoxEnabled(simultanee));
  9114. //          }
  9115. //          else{
  9116. //              policy.setSimultanee(false);
  9117. //          }
  9118. //      }
  9119.        
  9120.        
  9121.         // valore della policy
  9122.         TipoRisorsa tipoRisorsa = null;
  9123.         try{
  9124.             tipoRisorsa = TipoRisorsa.toEnumConstant(policy.getRisorsa(), true);
  9125.         }catch(Exception e){
  9126.             String messaggio = "Il valore ("+policy.getRisorsa()+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA+"' non è tra le risorse gestite";
  9127.             this.logError(messaggio,e);
  9128.             this.addParsingError(sbParsingError,messaggio);
  9129.         }
  9130.        
  9131.         if(TipoRisorsa.OCCUPAZIONE_BANDA.equals(tipoRisorsa)){
  9132.             String tipoBanda = null;
  9133.             try{
  9134.                 tipoBanda = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TIPO_BANDA);
  9135.                 if(tipoBanda!=null && !"".equals(tipoBanda)){
  9136.                     policy.setValoreTipoBanda(TipoBanda.toEnumConstant(tipoBanda, true));
  9137.                 }
  9138.                 else{
  9139.                     if(policy.getValoreTipoBanda()==null){
  9140.                         policy.setValoreTipoBanda(ConfigurazioneCostanti.TIPO_BANDA_DEFAULT);
  9141.                     }
  9142.                 }
  9143.             }catch(Exception e){
  9144.                 String label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TIPO_BANDA;
  9145.                 String messaggio = "Il valore ("+tipoBanda+") indicato in '"+label+"' non rientra tra i tipi conosciuti";
  9146.                 this.logError(messaggio,e);
  9147.                 this.addParsingError(sbParsingError,messaggio);
  9148.             }
  9149.         }
  9150.         else{
  9151.             policy.setValoreTipoBanda(null);
  9152.         }
  9153.        
  9154.         if(TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(tipoRisorsa) || TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(tipoRisorsa)){
  9155.             String tipoLatenza = null;
  9156.             try{
  9157.                 tipoLatenza = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TIPO_LATENZA);
  9158.                 if(tipoLatenza!=null && !"".equals(tipoLatenza)){
  9159.                     policy.setValoreTipoLatenza(TipoLatenza.toEnumConstant(tipoLatenza, true));
  9160.                 }
  9161.                 else{
  9162.                     if(policy.getValoreTipoLatenza()==null){
  9163.                         policy.setValoreTipoLatenza(ConfigurazioneCostanti.TIPO_LATENZA_DEFAULT);
  9164.                     }
  9165.                 }
  9166.             }catch(Exception e){
  9167.                 String label = null;
  9168.                 if(TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(tipoRisorsa)){
  9169.                     label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_TIPO_LATENZA;
  9170.                 }
  9171.                 else{
  9172.                     label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_TIPO_LATENZA;
  9173.                 }
  9174.                 String messaggio = "Il valore ("+tipoLatenza+") indicato in '"+label+"' non rientra tra i tipi conosciuti";
  9175.                 this.logError(messaggio,e);
  9176.                 this.addParsingError(sbParsingError,messaggio);
  9177.             }
  9178.         }
  9179.         else{
  9180.             policy.setValoreTipoLatenza(null);
  9181.         }
  9182.        
  9183.        
  9184.         String valore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE);
  9185.         if(valore!=null && !"".equals(valore)){
  9186.             if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)){
  9187.                 try{
  9188.                     int i = Integer.parseInt(valore);
  9189.                     if(i<=0){
  9190.                         throw new DriverControlStationException("Valore non nell'intervallo");
  9191.                     }
  9192.                     policy.setValore((long)i);
  9193.                 }catch(Exception e){
  9194.                     String label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RISPOSTA_LABEL;
  9195.                     String messaggio = "Il valore ("+valore+") indicato in '"+label+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  9196.                     this.logError(messaggio,e);
  9197.                     this.addParsingError(sbParsingError,messaggio);
  9198.                 }
  9199.             }
  9200.             else {
  9201.                 try{
  9202.                     long l = Long.parseLong(valore);
  9203.                     if(l<=0){
  9204.                         throw new DriverControlStationException("Valore non nell'intervallo");
  9205.                     }
  9206.                     policy.setValore(l);
  9207.                 }catch(Exception e){
  9208.                     String label = null;
  9209.                     if(TipoRisorsa.NUMERO_RICHIESTE.equals(tipoRisorsa)){
  9210.                         label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE;
  9211.                     }
  9212.                     else if(TipoRisorsa.OCCUPAZIONE_BANDA.equals(tipoRisorsa)){
  9213.                         label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_OCCUPAZIONE_DI_BANDA_LABEL;
  9214.                     }
  9215.                     else if(TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(tipoRisorsa)){
  9216.                         label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_LABEL;
  9217.                     }
  9218.                     else{
  9219.                         label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_LABEL;
  9220.                     }
  9221.                     String messaggio = "Il valore ("+valore+") indicato in '"+label+"' deve essere un numero intero maggiore di 0 e minore di "+Long.MAX_VALUE;
  9222.                     this.logError(messaggio,e);
  9223.                     this.addParsingError(sbParsingError,messaggio);
  9224.                 }
  9225.             }
  9226.         }
  9227.         else{
  9228.             if(!first){
  9229.                 policy.setValore(null);
  9230.             }
  9231.             else {
  9232.                 if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa) && policy.getValore()==null){
  9233.                     policy.setValore((long)ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA);
  9234.                 }
  9235.             }
  9236.         }
  9237.        
  9238.        
  9239.         if(policy.isSimultanee()==false && !TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)){
  9240.            
  9241.             // Modalità di Controllo
  9242.             if(TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(policy.getRisorsa())){
  9243.                 // è permesso solo il realtime
  9244.                 policy.setModalitaControllo(TipoControlloPeriodo.REALTIME);
  9245.             }
  9246.             else{
  9247.                 String modalitaControllo = null;
  9248.                 try{
  9249.                     modalitaControllo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_CONTROLLO);
  9250.                     if(modalitaControllo!=null && !"".equals(modalitaControllo)){
  9251.                         policy.setModalitaControllo(TipoControlloPeriodo.toEnumConstant(modalitaControllo, true));
  9252.                     }
  9253.                    
  9254.                 }catch(Exception e){
  9255.                     String messaggio = "Il valore ("+modalitaControllo+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_CONTROLLO+"' non rientra tra le modalità conosciute";
  9256.                     this.logError(messaggio,e);
  9257.                     this.addParsingError(sbParsingError,messaggio);
  9258.                 }
  9259.             }
  9260.            
  9261.             // Intervallo Osservazione
  9262.             if(policy.getModalitaControllo()!=null){
  9263.                
  9264.                 String tipoControlloPeriodo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_PERIODO);
  9265.                 if(tipoControlloPeriodo!=null && !"".equals(tipoControlloPeriodo)){
  9266.                     if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  9267.                         try{
  9268.                             policy.setTipoIntervalloOsservazioneRealtime(TipoPeriodoRealtime.toEnumConstant(tipoControlloPeriodo, true));
  9269.                         }catch(Exception e){
  9270.                             try{
  9271.                                 // Controllo se l'errore fosse dovuto al fatto che è stato cambiato la modalitù di controllo ed il valore presenta era per l'altra modalita
  9272.                                 if(TipoPeriodoStatistico.toEnumConstant(tipoControlloPeriodo, true)!=null){
  9273.                                     policy.setTipoIntervalloOsservazioneRealtime(ConfigurazioneCostanti.TIPO_PERIODO_REALTIME_DEFAULT);
  9274.                                 }
  9275.                             }catch(Exception eInterno){
  9276.                                 // NOTA: Viene registrato volutamente l'errore più esterno
  9277.                                 String messaggio = "Il valore ("+tipoControlloPeriodo+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_PERIODO+"' non rientra tra gli intervalli conosciuti";
  9278.                                 this.logError(messaggio,e);
  9279.                                 this.addParsingError(sbParsingError,messaggio);
  9280.                             }
  9281.                         }
  9282.                     }
  9283.                     else{
  9284.                         try{
  9285.                             policy.setTipoIntervalloOsservazioneStatistico(TipoPeriodoStatistico.toEnumConstant(tipoControlloPeriodo, true));
  9286.                         }catch(Exception e){
  9287.                             try{
  9288.                                 // Controllo se l'errore fosse dovuto al fatto che è stato cambiato la modalitù di controllo ed il valore presenta era per l'altra modalita
  9289.                                 if(TipoPeriodoRealtime.toEnumConstant(tipoControlloPeriodo, true)!=null){
  9290.                                     policy.setTipoIntervalloOsservazioneStatistico(ConfigurazioneCostanti.TIPO_PERIODO_STATISTICO_DEFAULT);
  9291.                                 }
  9292.                             }catch(Exception eInterno){
  9293.                                 // NOTA: Viene registrato volutamente l'errore più esterno
  9294.                                 String messaggio = "Il valore ("+tipoControlloPeriodo+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_PERIODO+"' non rientra tra gli intervalli conosciuti";
  9295.                                 this.logError(messaggio,e);
  9296.                                 this.addParsingError(sbParsingError,messaggio);
  9297.                             }
  9298.                         }
  9299.                     }
  9300.                 }
  9301.                
  9302.                 String periodo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_PERIODO);
  9303.                 if(periodo!=null && !"".equals(periodo)){
  9304.                     try{
  9305.                         int i = Integer.parseInt(periodo);
  9306.                         if(i<=0){
  9307.                             throw new DriverControlStationException("Valore non nell'intervallo");
  9308.                         }
  9309.                         policy.setIntervalloOsservazione(i);
  9310.                     }catch(Exception e){
  9311.                         String labelPeriodo = null;
  9312.                         if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  9313.                             labelPeriodo = this.getLabel(policy.getTipoIntervalloOsservazioneRealtime());
  9314.                         }else{
  9315.                             labelPeriodo = this.getLabel(policy.getTipoIntervalloOsservazioneStatistico());
  9316.                         }
  9317.                         String messaggio = "Il valore ("+periodo+") indicato in '"+labelPeriodo+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  9318.                         this.logError(messaggio,e);
  9319.                         this.addParsingError(sbParsingError,messaggio);
  9320.                     }
  9321.                 }
  9322.                 else{
  9323.                     if(!first){
  9324.                         policy.setIntervalloOsservazione(null);
  9325.                     }
  9326.                 }
  9327.                
  9328.                 String finestraPeriodo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_FINESTRA_PERIODO);
  9329.                 if(finestraPeriodo!=null && !"".equals(finestraPeriodo)){
  9330.                     boolean found = false;
  9331.                     if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  9332.                         for (int i = 0; i < ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_REALTIME.length; i++) {
  9333.                             if(ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_REALTIME[i].equals(finestraPeriodo)){
  9334.                                 found = true;
  9335.                                 break;
  9336.                             }
  9337.                         }
  9338.                     }
  9339.                     else{
  9340.                         for (int i = 0; i < ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_STATISTICO.length; i++) {
  9341.                             if(ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_STATISTICO[i].equals(finestraPeriodo)){
  9342.                                 found = true;
  9343.                                 break;
  9344.                             }
  9345.                         }
  9346.                     }
  9347.                     if(found){
  9348.                         // Controllo se l'errore fosse dovuto al fatto che è stato cambiato la modalitù di controllo ed il valore presenta era per l'altra modalita
  9349.                         try{
  9350.                             policy.setFinestraOsservazione(TipoFinestra.toEnumConstant(finestraPeriodo, true));
  9351.                         }catch(Exception e){
  9352.                             String messaggio = "Il valore ("+finestraPeriodo+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_FINESTRA_PERIODO+"' non rientra tra le finestre conosciute";
  9353.                             this.logError(messaggio,e);
  9354.                             this.addParsingError(sbParsingError,messaggio);
  9355.                         }
  9356.                     }
  9357.                     else{
  9358.                         policy.setFinestraOsservazione(null);
  9359.                     }
  9360.                 }
  9361.                
  9362.                
  9363.                 // Controllo se è stato cambiato il tipo di risorsa. In tal caso forzo il change del tipo di finestra
  9364.                 String postBackElementName = this.getPostBackElementName();
  9365.                 if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA.equals(postBackElementName) ||
  9366.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_CONTROLLO.equals(postBackElementName)){
  9367.                     if(policy.getFinestraOsservazione()!=null){
  9368.                         policy.setFinestraOsservazione(null);
  9369.                     }
  9370.                 }
  9371.             }
  9372.             else{
  9373.                 // reset
  9374.                 policy.setModalitaControllo(ConfigurazioneCostanti.TIPO_CONTROLLO_PERIODO_DEFAULT);
  9375.                 policy.setTipoIntervalloOsservazioneRealtime(ConfigurazioneCostanti.TIPO_PERIODO_REALTIME_DEFAULT);
  9376.                 policy.setTipoIntervalloOsservazioneStatistico(ConfigurazioneCostanti.TIPO_PERIODO_STATISTICO_DEFAULT);
  9377.                 policy.setIntervalloOsservazione(null);
  9378.                 policy.setFinestraOsservazione(null);
  9379.             }
  9380.            
  9381.         }
  9382.         else if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)){
  9383.            
  9384.             // Viene usata questa informazione per la dimensione della richiesta
  9385.             String valore2 = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_2);
  9386.             if(valore2!=null && !"".equals(valore2)){
  9387.                 try{
  9388.                     int i = Integer.parseInt(valore2);
  9389.                     if(i<=0){
  9390.                         throw new DriverControlStationException("Valore non nell'intervallo");
  9391.                     }
  9392.                     policy.setValore2((long)i);
  9393.                 }catch(Exception e){
  9394.                     String label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RICHIESTA_LABEL;
  9395.                     String messaggio = "Il valore ("+valore2+") indicato in '"+label+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  9396.                     this.logError(messaggio,e);
  9397.                     this.addParsingError(sbParsingError,messaggio);
  9398.                 }              
  9399.             }
  9400.             else{
  9401.                 if(!first){
  9402.                     policy.setValore2(null);
  9403.                 }
  9404.                 else {
  9405.                     if(policy.getValore2()==null) {
  9406.                         policy.setValore2(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA);
  9407.                     }
  9408.                 }
  9409.             }
  9410.            
  9411.             // reset
  9412.             policy.setModalitaControllo(ConfigurazioneCostanti.TIPO_CONTROLLO_PERIODO_DEFAULT);
  9413.             policy.setTipoIntervalloOsservazioneRealtime(ConfigurazioneCostanti.TIPO_PERIODO_REALTIME_DEFAULT);
  9414.             policy.setTipoIntervalloOsservazioneStatistico(ConfigurazioneCostanti.TIPO_PERIODO_STATISTICO_DEFAULT);
  9415.             policy.setIntervalloOsservazione(null);
  9416.             policy.setFinestraOsservazione(null);
  9417.         }
  9418.         else{
  9419.             // reset
  9420.             policy.setModalitaControllo(ConfigurazioneCostanti.TIPO_CONTROLLO_PERIODO_DEFAULT);
  9421.             policy.setTipoIntervalloOsservazioneRealtime(ConfigurazioneCostanti.TIPO_PERIODO_REALTIME_DEFAULT);
  9422.             policy.setTipoIntervalloOsservazioneStatistico(ConfigurazioneCostanti.TIPO_PERIODO_STATISTICO_DEFAULT);
  9423.             policy.setIntervalloOsservazione(null);
  9424.             policy.setFinestraOsservazione(null);
  9425.         }
  9426.        

  9427.         if(sbParsingError.length() > 0){
  9428.             return sbParsingError.toString();
  9429.         }
  9430.         return null;
  9431.     }
  9432.    
  9433.     public String readApplicabilitaPolicyFromHttpParameters(ConfigurazionePolicy policy, boolean first) throws Exception {
  9434.            
  9435.         StringBuilder sbParsingError = new StringBuilder();
  9436.        
  9437.         TipoRisorsa tipoRisorsa = TipoRisorsa.toEnumConstant(policy.getRisorsa());
  9438.         if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)){
  9439.             policy.setTipoApplicabilita(TipoApplicabilita.SEMPRE);
  9440.             return null;
  9441.         }
  9442.        
  9443.         // condizionale
  9444.         String condizionale = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_TIPO);
  9445.         if(first==false){
  9446.             if (ServletUtils.isCheckBoxEnabled(condizionale) ){
  9447.                 policy.setTipoApplicabilita(TipoApplicabilita.CONDIZIONALE);
  9448.             }
  9449.             else{
  9450.                 policy.setTipoApplicabilita(TipoApplicabilita.SEMPRE);
  9451.             }
  9452.         }
  9453.         else{
  9454.             if(policy.getTipoApplicabilita()==null)
  9455.                 policy.setTipoApplicabilita(TipoApplicabilita.SEMPRE);
  9456.         }
  9457.        
  9458.        
  9459.         // con congestione in corso
  9460.         String congestioneInCorso = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE);
  9461.         if(first==false){
  9462.             policy.setApplicabilitaConCongestione(ServletUtils.isCheckBoxEnabled(congestioneInCorso));
  9463.         }
  9464.        
  9465.        
  9466.         // con degrado prestazionale
  9467.         String degradoPrestazionale = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE);
  9468.         if(first==false){
  9469.             policy.setApplicabilitaDegradoPrestazionale(ServletUtils.isCheckBoxEnabled(degradoPrestazionale));
  9470.         }
  9471.        
  9472.        
  9473.         // con stato allarme
  9474.         String statoAllarme = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME);
  9475.         if(first==false){
  9476.             policy.setApplicabilitaStatoAllarme(ServletUtils.isCheckBoxEnabled(statoAllarme));
  9477.         }
  9478.        
  9479.        
  9480.         // Degrado Prestazionale
  9481.         String messaggioErroreDegradoPrestazione = readApplicabilitaDegradoPrestazionalePolicyFromHttpParameters(policy, first);
  9482.         if(messaggioErroreDegradoPrestazione != null)
  9483.             this.addParsingError(sbParsingError, messaggioErroreDegradoPrestazione);
  9484.        
  9485.         // StatoAllarmi
  9486.         String messaggioErroreReadApplicabilita = readApplicabilitaStatoAllarmePolicyFromHttpParameters(policy, first);
  9487.         if(messaggioErroreReadApplicabilita != null)
  9488.             this.addParsingError(sbParsingError, messaggioErroreReadApplicabilita);
  9489.        

  9490.         if(sbParsingError.length() > 0){
  9491.             return sbParsingError.toString();
  9492.         }
  9493.         return null;
  9494.     }
  9495.    
  9496.     private String readApplicabilitaDegradoPrestazionalePolicyFromHttpParameters(ConfigurazionePolicy policy, boolean first) throws Exception {

  9497.         StringBuilder sbParsingError = new StringBuilder();
  9498.         // ** Degrado Prestazionale **
  9499.         if(policy.isApplicabilitaDegradoPrestazionale()){
  9500.            
  9501.             // Modalità di Controllo
  9502.             String modalitaControllo = null;
  9503.             try{
  9504.                 modalitaControllo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_CONTROLLO);
  9505.                 if(modalitaControllo!=null && !"".equals(modalitaControllo)){
  9506.                     policy.setDegradoAvgTimeModalitaControllo(TipoControlloPeriodo.toEnumConstant(modalitaControllo, true));
  9507.                 }
  9508.                 else{
  9509.                     if(policy.getDegradoAvgTimeModalitaControllo()==null){
  9510.                         policy.setDegradoAvgTimeModalitaControllo(ConfigurazioneCostanti.TIPO_CONTROLLO_PERIODO_DEFAULT);
  9511.                     }
  9512.                 }
  9513.             }catch(Exception e){
  9514.                 String messaggio = "Il valore ("+modalitaControllo+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_CONTROLLO+"' non rientra tra le modalità conosciute";
  9515.                 this.logError(messaggio,e);
  9516.                 this.addParsingError(sbParsingError,messaggio);
  9517.             }
  9518.                    
  9519.             // Tipo Latenza
  9520.             String tipoLatenza = null;
  9521.             try{
  9522.                 tipoLatenza = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_LATENZA);
  9523.                 if(tipoLatenza!=null && !"".equals(tipoLatenza)){
  9524.                     policy.setDegradoAvgTimeTipoLatenza(TipoLatenza.toEnumConstant(tipoLatenza, true));
  9525.                 }
  9526.                 else{
  9527.                     if(policy.getDegradoAvgTimeTipoLatenza()==null){
  9528.                         policy.setDegradoAvgTimeTipoLatenza(ConfigurazioneCostanti.TIPO_LATENZA_DEFAULT);
  9529.                     }
  9530.                 }
  9531.             }catch(Exception e){
  9532.                 String messaggio = "Il valore ("+tipoLatenza+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_LATENZA+"' non rientra tra i tipi conosciuti";
  9533.                 this.logError(messaggio,e);
  9534.                 this.addParsingError(sbParsingError,messaggio);
  9535.             }

  9536.             // Intervallo Osservazione
  9537.             String tipoControlloPeriodo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_PERIODO);
  9538.             if(tipoControlloPeriodo!=null && !"".equals(tipoControlloPeriodo)){
  9539.                 if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  9540.                     try{
  9541.                         policy.setDegradoAvgTimeTipoIntervalloOsservazioneRealtime(TipoPeriodoRealtime.toEnumConstant(tipoControlloPeriodo, true));
  9542.                     }catch(Exception e){
  9543.                         try{
  9544.                             // Controllo se l'errore fosse dovuto al fatto che è stato cambiato la modalitù di controllo ed il valore presenta era per l'altra modalita
  9545.                             if(TipoPeriodoStatistico.toEnumConstant(tipoControlloPeriodo, true)!=null){
  9546.                                 policy.setDegradoAvgTimeTipoIntervalloOsservazioneRealtime(ConfigurazioneCostanti.TIPO_PERIODO_REALTIME_DEFAULT);
  9547.                             }
  9548.                         }catch(Exception eInterno){
  9549.                             // NOTA: Viene registrato volutamente l'errore più esterno
  9550.                             String messaggio = "Il valore ("+tipoControlloPeriodo+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_PERIODO+"' non rientra tra gli intervalli conosciuti";
  9551.                             this.logError(messaggio,e);
  9552.                             this.addParsingError(sbParsingError,messaggio);
  9553.                         }
  9554.                     }
  9555.                 }
  9556.                 else{
  9557.                     try{
  9558.                         policy.setDegradoAvgTimeTipoIntervalloOsservazioneStatistico(TipoPeriodoStatistico.toEnumConstant(tipoControlloPeriodo, true));
  9559.                     }catch(Exception e){
  9560.                         try{
  9561.                             // Controllo se l'errore fosse dovuto al fatto che è stato cambiato la modalitù di controllo ed il valore presenta era per l'altra modalita
  9562.                             if(TipoPeriodoRealtime.toEnumConstant(tipoControlloPeriodo, true)!=null){
  9563.                                 policy.setDegradoAvgTimeTipoIntervalloOsservazioneStatistico(ConfigurazioneCostanti.TIPO_PERIODO_STATISTICO_DEFAULT);
  9564.                             }
  9565.                         }catch(Exception eInterno){
  9566.                             // NOTA: Viene registrato volutamente l'errore più esterno
  9567.                             String messaggio = "Il valore ("+tipoControlloPeriodo+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_PERIODO+"' non rientra tra gli intervalli conosciuti";
  9568.                             this.logError(messaggio,e);
  9569.                             this.addParsingError(sbParsingError,messaggio);
  9570.                         }
  9571.                     }
  9572.                 }
  9573.             }
  9574.             else{
  9575.                 if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  9576.                     if(policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime()==null){
  9577.                         policy.setDegradoAvgTimeTipoIntervalloOsservazioneRealtime(ConfigurazioneCostanti.TIPO_PERIODO_REALTIME_DEFAULT);
  9578.                     }
  9579.                 }
  9580.                 else{
  9581.                     if(policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico()==null){
  9582.                         policy.setDegradoAvgTimeTipoIntervalloOsservazioneStatistico(ConfigurazioneCostanti.TIPO_PERIODO_STATISTICO_DEFAULT);
  9583.                     }
  9584.                 }
  9585.             }
  9586.            
  9587.             String periodo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_PERIODO);
  9588.             if(periodo!=null && !"".equals(periodo)){
  9589.                 try{
  9590.                     int i = Integer.parseInt(periodo);
  9591.                     if(i<=0){
  9592.                         throw new DriverControlStationException("Valore non nell'intervallo");
  9593.                     }
  9594.                     policy.setDegradoAvgTimeIntervalloOsservazione(i);
  9595.                 }catch(Exception e){
  9596.                     String labelIntervallo = null;
  9597.                     if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  9598.                         labelIntervallo = this.getLabel(policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime());
  9599.                     }
  9600.                     else{
  9601.                         labelIntervallo = this.getLabel(policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico());
  9602.                     }
  9603.                     String messaggio = "Il valore ("+periodo+") indicato in '"+labelIntervallo+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  9604.                     this.logError(messaggio,e);
  9605.                     this.addParsingError(sbParsingError,messaggio);
  9606.                 }
  9607.             }
  9608.             else{
  9609.                 if(!first){
  9610.                     policy.setDegradoAvgTimeIntervalloOsservazione(null);
  9611.                 }
  9612.             }
  9613.            
  9614.             String finestraPeriodo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_FINESTRA_PERIODO);
  9615.             if(finestraPeriodo!=null && !"".equals(finestraPeriodo)){
  9616.                 boolean found = false;
  9617.                 if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  9618.                     for (int i = 0; i < ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_REALTIME.length; i++) {
  9619.                         if(ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_REALTIME[i].equals(finestraPeriodo)){
  9620.                             found = true;
  9621.                             break;
  9622.                         }
  9623.                     }
  9624.                 }
  9625.                 else{
  9626.                     for (int i = 0; i < ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_STATISTICO.length; i++) {
  9627.                         if(ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_STATISTICO[i].equals(finestraPeriodo)){
  9628.                             found = true;
  9629.                             break;
  9630.                         }
  9631.                     }
  9632.                 }
  9633.                 if(found){
  9634.                     // Controllo se l'errore fosse dovuto al fatto che è stato cambiato la modalitù di controllo ed il valore presenta era per l'altra modalita
  9635.                     try{
  9636.                         policy.setDegradoAvgTimeFinestraOsservazione(TipoFinestra.toEnumConstant(finestraPeriodo, true));
  9637.                     }catch(Exception e){
  9638.                         String messaggio = "Il valore ("+finestraPeriodo+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_FINESTRA_PERIODO+"' non rientra tra le finestre conosciute";
  9639.                         this.logError(messaggio,e);
  9640.                         this.addParsingError(sbParsingError,messaggio);
  9641.                     }
  9642.                 }
  9643.                 else{
  9644.                     policy.setDegradoAvgTimeFinestraOsservazione(null);
  9645.                 }
  9646.             }
  9647.            
  9648.             // Controllo se è stato cambiato il tipo di risorsa. In tal caso forzo il change del tipo di finestra
  9649.             String postBackElementName = this.getPostBackElementName();
  9650.             //if(ConfigurazioneCostanti.PARAMETRO_CONTROLLO_CONGESTIONE_POLICY_RISORSA.equals(postBackElementName) ||
  9651.             // La risorsa non impatta sul tipo di finestra di osservazione. Al massimo se viene scelta una risorsa dove non è previsto il controllo sul degrado sparisce tutto il degrado
  9652.             if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_CONTROLLO.equals(postBackElementName)){
  9653.                 if(policy.getDegradoAvgTimeFinestraOsservazione()!=null){
  9654.                     policy.setDegradoAvgTimeFinestraOsservazione(null);
  9655.                 }
  9656.             }
  9657.            
  9658.         }
  9659.         else{
  9660.            
  9661.             policy.setDegradoAvgTimeModalitaControllo(null);
  9662.             policy.setDegradoAvgTimeTipoLatenza(null);
  9663.             policy.setDegradoAvgTimeTipoIntervalloOsservazioneRealtime(null);
  9664.             policy.setDegradoAvgTimeTipoIntervalloOsservazioneStatistico(null);
  9665.             policy.setDegradoAvgTimeIntervalloOsservazione(null);
  9666.             policy.setDegradoAvgTimeFinestraOsservazione(null);
  9667.            
  9668.         }
  9669.    
  9670.         if(sbParsingError.length() > 0){
  9671.             return sbParsingError.toString();
  9672.         }
  9673.         return null;
  9674.     }
  9675.    
  9676.     private String readApplicabilitaStatoAllarmePolicyFromHttpParameters(ConfigurazionePolicy policy, boolean first) throws Exception {
  9677.        
  9678.         StringBuilder sbParsingError = new StringBuilder();
  9679.         // ** Degrado Prestazionale **
  9680.         if(policy.isApplicabilitaStatoAllarme()){
  9681.    
  9682.             // Nome
  9683.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOME);
  9684.             if(nome!=null && !"".equals(nome) && !"-".equals(nome)){
  9685.                 policy.setAllarmeNome(nome);
  9686.             }
  9687.            
  9688.             // Not Stato
  9689.             String statoNotAllarme = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOT_STATO);
  9690.             if(first==false){
  9691.                 policy.setAllarmeNotStato(ServletUtils.isCheckBoxEnabled(statoNotAllarme));
  9692.             }
  9693.            
  9694.             // StatoAllarme
  9695.             String stato = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_STATO);
  9696.             if(stato!=null && !"".equals(stato)){
  9697.                 try{
  9698.                     int i = Integer.parseInt(stato);
  9699.                     if(i<0){
  9700.                         throw new DriverControlStationException("Valore non nell'intervallo");
  9701.                     }
  9702.                     policy.setAllarmeStato(i);
  9703.                 }catch(Exception e){
  9704.                     String messaggio = "Lo stato ("+stato+") selezionato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_STATO+
  9705.                             "' non risulta tra quelli gestiti";
  9706.                     this.logError(messaggio,e);
  9707.                     this.addParsingError(sbParsingError,messaggio);
  9708.                 }
  9709.             }
  9710.             else{
  9711.                 if(policy.getAllarmeStato()==null){
  9712.                     policy.setAllarmeStato(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_DEFAULT);
  9713.                 }
  9714.             }
  9715.            
  9716.         }
  9717.         else{
  9718.            
  9719.             policy.setAllarmeNome(null);
  9720.             policy.setAllarmeNotStato(false);
  9721.             policy.setAllarmeStato(null);
  9722.            
  9723.         }
  9724.         if(sbParsingError.length() > 0){
  9725.             return sbParsingError.toString();
  9726.         }
  9727.         return null;
  9728.     }
  9729.    
  9730.     public String getNomeSuggerito(ConfigurazionePolicy policy){
  9731.        
  9732.         StringBuilder bfSuggerimentoNome = new StringBuilder();
  9733.         bfSuggerimentoNome.append(policy.getRisorsa());
  9734.        
  9735.         TipoRisorsa risorsa = TipoRisorsa.toEnumConstant(policy.getRisorsa());
  9736.        
  9737.         if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(risorsa)) {
  9738.             return bfSuggerimentoNome.toString();
  9739.         }
  9740.        
  9741.         if(policy.isSimultanee()){
  9742.             bfSuggerimentoNome.append("-").append("RichiesteSimultanee");
  9743.         }
  9744.         else{
  9745.             if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  9746.                 bfSuggerimentoNome.append("-ControlloRealtime").
  9747.                     append((policy.getTipoIntervalloOsservazioneRealtime().getValue().charAt(0)+"").toUpperCase()).
  9748.                     append(policy.getTipoIntervalloOsservazioneRealtime().getValue().substring(1));
  9749.             }
  9750.             else{
  9751.                 bfSuggerimentoNome.append("-ControlloStatistico").
  9752.                     append((policy.getTipoIntervalloOsservazioneStatistico().getValue().charAt(0)+"").toUpperCase()).
  9753.                     append(policy.getTipoIntervalloOsservazioneStatistico().getValue().substring(1));
  9754.             }  
  9755.         }
  9756.         if(TipoApplicabilita.CONDIZIONALE.equals(policy.getTipoApplicabilita())){
  9757.             StringBuilder bfInterno = new StringBuilder();
  9758.             bfInterno.append("-Condizionale");
  9759.             if(policy.isApplicabilitaConCongestione()){
  9760.                 bfInterno.append("-CongestioneTraffico");
  9761.             }
  9762.             if(policy.isApplicabilitaDegradoPrestazionale()){
  9763.                 bfInterno.append("-DegradoPrestazionale");
  9764.                 if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  9765.                     bfInterno.append("Realtime").
  9766.                     append((policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime().getValue().charAt(0)+"").toUpperCase()).
  9767.                     append(policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime().getValue().substring(1));
  9768.                 }
  9769.                 else{
  9770.                     bfInterno.append("Statistico").
  9771.                     append((policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico().getValue().charAt(0)+"").toUpperCase()).
  9772.                     append(policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico().getValue().substring(1));
  9773.                 }
  9774.             }
  9775.             if(policy.isApplicabilitaStatoAllarme()){
  9776.                 bfInterno.append("-StatoAllarme");
  9777.             }
  9778.             bfSuggerimentoNome.append(bfInterno.toString());
  9779.         }
  9780.         return bfSuggerimentoNome.toString();
  9781.        
  9782.     }
  9783.    
  9784.     public String getDescrizioneSuggerita(ConfigurazionePolicy policy) {
  9785.        
  9786.         StringBuilder bfSuggerimentoDescrizione = new StringBuilder();
  9787.        
  9788.         TipoRisorsa risorsa = TipoRisorsa.toEnumConstant(policy.getRisorsa());
  9789.        
  9790.         StringBuilder bfIntervallo = new StringBuilder();
  9791.         if(!policy.isSimultanee() && !TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(risorsa)){
  9792.             bfIntervallo.append(" durante l'intervallo di tempo specificato in ");
  9793.             if(policy.getIntervalloOsservazione()!=null)
  9794.                 bfIntervallo.append(policy.getIntervalloOsservazione()).append(" ");
  9795.            
  9796.             TipoFinestra finestra = policy.getFinestraOsservazione();
  9797.             if(finestra==null){
  9798.                 finestra = this.getTipoFinestraDefault(policy.getModalitaControllo(), policy.getRisorsa(), false);
  9799.             }
  9800.             String finestraDescrizione = "";
  9801.             if(finestra!=null){
  9802.                 finestraDescrizione = ", finestra "+finestra.getValue();
  9803.             }
  9804.            
  9805.             String tipoRisorsa = "";
  9806.             if(risorsa!=null && TipoRisorsa.OCCUPAZIONE_BANDA.equals(risorsa)){
  9807.                 TipoBanda banda = policy.getValoreTipoBanda();
  9808.                 if(banda==null){
  9809.                     banda = ConfigurazioneCostanti.TIPO_BANDA_DEFAULT;
  9810.                 }
  9811.                 if(banda!=null){
  9812.                     tipoRisorsa = ", tipo banda "+banda.getValue();
  9813.                 }
  9814.             }
  9815.             else if(risorsa!=null && (TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(risorsa) || TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(risorsa)) ){
  9816.                 TipoLatenza latenza = policy.getValoreTipoLatenza();
  9817.                 if(latenza==null){
  9818.                     latenza = ConfigurazioneCostanti.TIPO_LATENZA_DEFAULT;
  9819.                 }
  9820.                 if(latenza!=null){
  9821.                     tipoRisorsa = ", tipo latenza "+latenza.getValue();
  9822.                 }
  9823.             }
  9824.            
  9825.             if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  9826.                 switch (policy.getTipoIntervalloOsservazioneRealtime()) {
  9827.                 case SECONDI:
  9828.                     bfIntervallo.append("secondi");
  9829.                     break;
  9830.                 case MINUTI:
  9831.                     bfIntervallo.append("minuti");
  9832.                     break;
  9833.                 case ORARIO:
  9834.                     bfIntervallo.append("ore");
  9835.                     break;
  9836.                 case GIORNALIERO:
  9837.                     bfIntervallo.append("giorni");
  9838.                     break;
  9839.                 }
  9840.                 bfIntervallo.append(" (campionamento real-time").
  9841.                     append(finestraDescrizione).
  9842.                     append(tipoRisorsa).
  9843.                     append(").");
  9844.             }
  9845.             else{
  9846.                 switch (policy.getTipoIntervalloOsservazioneStatistico()) {
  9847.                 case ORARIO:
  9848.                     bfIntervallo.append("ore");
  9849.                     break;
  9850.                 case GIORNALIERO:
  9851.                     bfIntervallo.append("giorni");
  9852.                     break;
  9853.                 case SETTIMANALE:
  9854.                     bfIntervallo.append("settimane");
  9855.                     break;
  9856.                 case MENSILE:
  9857.                     bfIntervallo.append("mesi");
  9858.                     break;
  9859.                 }
  9860.                 bfIntervallo.append(" (campionamento statistico").
  9861.                     append(finestraDescrizione).
  9862.                     append(tipoRisorsa).
  9863.                     append(").");
  9864.             }  
  9865.         }
  9866.        
  9867.         if(risorsa!=null){
  9868.             switch (risorsa) {
  9869.             case NUMERO_RICHIESTE:
  9870.                 bfSuggerimentoDescrizione.append("La policy limita il numero totale massimo di richieste ");
  9871.                 if(policy.isSimultanee()){
  9872.                     bfSuggerimentoDescrizione.append("simultanee ");
  9873.                 }
  9874.                 bfSuggerimentoDescrizione.append("consentite");
  9875.                 if(policy.isSimultanee()){
  9876.                     bfSuggerimentoDescrizione.append(".");
  9877.                 }
  9878.                 break;
  9879.             case DIMENSIONE_MASSIMA_MESSAGGIO:
  9880.                 bfSuggerimentoDescrizione.append("La policy limita la dimensione massima, in KB, consentita per una richiesta e/o per una risposta");
  9881.                 break;
  9882.             case OCCUPAZIONE_BANDA:
  9883.                 bfSuggerimentoDescrizione.append("La policy limita il numero totale massimo di KB consentiti");
  9884.                 break;
  9885.             case TEMPO_MEDIO_RISPOSTA:
  9886.                 bfSuggerimentoDescrizione.append("La policy blocca ogni successiva richiesta se viene rilevato un tempo medio di risposta elevato");
  9887.                 break;
  9888.             case TEMPO_COMPLESSIVO_RISPOSTA:
  9889.                 bfSuggerimentoDescrizione.append("La policy limita il numero totale massimo di secondi consentiti");
  9890.                 break;
  9891.             case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO:
  9892.                 bfSuggerimentoDescrizione.append("La policy conteggia il numero di richieste completate con successo; raggiunto il limite, ogni successiva richiesta viene bloccata");
  9893.                 break;
  9894.             case NUMERO_RICHIESTE_FALLITE:
  9895.                 bfSuggerimentoDescrizione.append("La policy conteggia il numero di richieste fallite; raggiunto il limite, ogni successiva richiesta viene bloccata");
  9896.                 break;
  9897.             case NUMERO_FAULT_APPLICATIVI:
  9898.                 bfSuggerimentoDescrizione.append("La policy conteggia il numero di richieste che veicolano un fault applicativo; raggiunto il limite, ogni successiva richiesta viene bloccata");
  9899.                 break;
  9900.             case NUMERO_RICHIESTE_FALLITE_OFAULT_APPLICATIVI:
  9901.                 bfSuggerimentoDescrizione.append("La policy conteggia il numero di richieste fallite o che veicolano un fault applicativo; raggiunto il limite, ogni successiva richiesta viene bloccata");
  9902.                 break;
  9903.             case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_OFAULT_APPLICATIVI:
  9904.                 bfSuggerimentoDescrizione.append("La policy conteggia il numero di richieste completate con successo o che veicolano un fault applicativo; raggiunto il limite, ogni successiva richiesta viene bloccata");
  9905.                 break;
  9906.             }
  9907.         }
  9908.        
  9909.         if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(risorsa)) {
  9910.             return bfSuggerimentoDescrizione.toString();
  9911.         }
  9912.        
  9913.        
  9914.         bfSuggerimentoDescrizione.append(bfIntervallo.toString());
  9915.        
  9916.        
  9917.         if(policy.isApplicabilitaConCongestione() || policy.isApplicabilitaDegradoPrestazionale() || policy.isApplicabilitaStatoAllarme()){
  9918.             bfSuggerimentoDescrizione.append("\nLa policy viene applicata solamente se ");
  9919.             StringBuilder bfApplicabilita = new StringBuilder();
  9920.             if(policy.isApplicabilitaConCongestione()){
  9921.                 bfApplicabilita.append("il Gateway risulta Congestionato dalle richieste");
  9922.             }
  9923.             if(policy.isApplicabilitaDegradoPrestazionale()){
  9924.                 if(bfApplicabilita.length()>0){
  9925.                     bfApplicabilita.append(" ed ");
  9926.                 }
  9927.                
  9928.                 TipoFinestra finestra = policy.getDegradoAvgTimeFinestraOsservazione();
  9929.                 if(finestra==null){
  9930.                     finestra = this.getTipoFinestraDefault(policy.getDegradoAvgTimeModalitaControllo(), policy.getRisorsa(), true);
  9931.                 }
  9932.                 String finestraDescrizione = "";
  9933.                 if(finestra!=null){
  9934.                     finestraDescrizione = ", finestra "+finestra.getValue();
  9935.                 }
  9936.                
  9937.                 String tipoRisorsa = "";
  9938.                 TipoLatenza latenza = policy.getDegradoAvgTimeTipoLatenza();
  9939.                 if(latenza==null){
  9940.                     latenza = ConfigurazioneCostanti.TIPO_LATENZA_DEFAULT;
  9941.                 }
  9942.                 if(latenza!=null){
  9943.                     tipoRisorsa = ", tipo latenza "+latenza.getValue();
  9944.                 }
  9945.                
  9946.                 String intervalloDescrizione = "";
  9947.                 if(policy.getDegradoAvgTimeModalitaControllo()!=null){
  9948.                     intervalloDescrizione =  ", intervallo di tempo specificato in ";
  9949.                     if(policy.getDegradoAvgTimeIntervalloOsservazione()!=null){
  9950.                         intervalloDescrizione+=policy.getDegradoAvgTimeIntervalloOsservazione();
  9951.                         intervalloDescrizione+=" ";
  9952.                     }
  9953.                    
  9954.                     if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  9955.                         switch (policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime()) {
  9956.                         case SECONDI:
  9957.                             intervalloDescrizione+="secondi";
  9958.                             break;
  9959.                         case MINUTI:
  9960.                             intervalloDescrizione+="minuti";
  9961.                             break;
  9962.                         case ORARIO:
  9963.                             intervalloDescrizione+="ore";
  9964.                             break;
  9965.                         case GIORNALIERO:
  9966.                             intervalloDescrizione+="giorni";
  9967.                             break;
  9968.                         }
  9969.                     }
  9970.                     else{
  9971.                         switch (policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico()) {
  9972.                         case ORARIO:
  9973.                             intervalloDescrizione+="ore";
  9974.                             break;
  9975.                         case GIORNALIERO:
  9976.                             intervalloDescrizione+="giorni";
  9977.                             break;
  9978.                         case SETTIMANALE:
  9979.                             intervalloDescrizione+="settimane";
  9980.                             break;
  9981.                         case MENSILE:
  9982.                             intervalloDescrizione+="mesi";
  9983.                             break;
  9984.                         }
  9985.                     }  
  9986.                 }
  9987.                
  9988.                 String tipoCampionamento = null;
  9989.                 if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  9990.                     tipoCampionamento = "(campionamento realtime"+intervalloDescrizione+finestraDescrizione+tipoRisorsa+")";
  9991.                 }
  9992.                 else{
  9993.                     tipoCampionamento = "(campionamento statistico"+intervalloDescrizione+finestraDescrizione+tipoRisorsa+")";
  9994.                 }
  9995.                 bfApplicabilita.append("il tempo medio di risposta del servizio "+tipoCampionamento+" risulta superiore ai livelli di soglia impostati");
  9996.             }
  9997.             if(policy.isApplicabilitaStatoAllarme()){
  9998.                 if(bfApplicabilita.length()>0){
  9999.                     bfApplicabilita.append(" e ");
  10000.                 }
  10001.                 bfApplicabilita.append("l'allarme selezionato soddisfa lo stato indicato");
  10002.             }
  10003.             bfApplicabilita.append(".");
  10004.             bfSuggerimentoDescrizione.append(bfApplicabilita.toString());
  10005.         }
  10006.         return bfSuggerimentoDescrizione.toString();
  10007.        
  10008.     }
  10009.    
  10010.     public TipoFinestra getTipoFinestraDefault(TipoControlloPeriodo modalitaControllo,String risorsa, boolean degrado){
  10011.         if(modalitaControllo!=null){
  10012.             if(TipoControlloPeriodo.REALTIME.equals(modalitaControllo)){
  10013.                 if(degrado){
  10014.                     return TipoFinestra.PRECEDENTE;
  10015.                 }
  10016.                 else if(risorsa!=null){
  10017.                     TipoRisorsa tipo = TipoRisorsa.toEnumConstant(risorsa);
  10018.                     if(tipo!=null){
  10019.                         switch (tipo) {
  10020.                         case NUMERO_RICHIESTE:
  10021.                         case DIMENSIONE_MASSIMA_MESSAGGIO:
  10022.                         case OCCUPAZIONE_BANDA:
  10023.                         case TEMPO_COMPLESSIVO_RISPOSTA:
  10024.                         case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO:
  10025.                         case NUMERO_RICHIESTE_FALLITE:
  10026.                         case NUMERO_FAULT_APPLICATIVI:
  10027.                         case NUMERO_RICHIESTE_FALLITE_OFAULT_APPLICATIVI:
  10028.                         case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_OFAULT_APPLICATIVI:
  10029.                             return TipoFinestra.CORRENTE;
  10030.                         case TEMPO_MEDIO_RISPOSTA:
  10031.                             return TipoFinestra.PRECEDENTE;
  10032.                         }
  10033.                     }
  10034.                 }
  10035.             }
  10036.             else{
  10037.                 if(degrado){
  10038.                     return TipoFinestra.SCORREVOLE;
  10039.                 }
  10040.                 else if(risorsa!=null){
  10041.                     TipoRisorsa tipo = TipoRisorsa.toEnumConstant(risorsa);
  10042.                     if(tipo!=null){
  10043.                         switch (tipo) {
  10044.                         case NUMERO_RICHIESTE:
  10045.                         case DIMENSIONE_MASSIMA_MESSAGGIO:
  10046.                         case OCCUPAZIONE_BANDA:
  10047.                         case TEMPO_COMPLESSIVO_RISPOSTA:
  10048.                         case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO:
  10049.                         case NUMERO_RICHIESTE_FALLITE:
  10050.                         case NUMERO_FAULT_APPLICATIVI:
  10051.                         case NUMERO_RICHIESTE_FALLITE_OFAULT_APPLICATIVI:
  10052.                         case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_OFAULT_APPLICATIVI:
  10053.                             return TipoFinestra.CORRENTE;
  10054.                         case TEMPO_MEDIO_RISPOSTA:
  10055.                             return TipoFinestra.SCORREVOLE;
  10056.                         }
  10057.                     }
  10058.                 }
  10059.             }
  10060.         }
  10061.         return null;
  10062.     }
  10063.    
  10064.     public void addConfigurazionePolicyToDati(List<DataElement> dati, TipoOperazione tipoOperazione, ConfigurazionePolicy policy, boolean editMode, long numeroPolicyIstanziate,
  10065.             String oldNomeSuggeritoPolicy,  String oldDDescrizioneSuggeritaPolicy, String oldPolicyId) throws Exception {
  10066.        
  10067.         DataElement de = new DataElement();
  10068.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_POLICY);
  10069.         de.setType(DataElementType.TITLE);
  10070.         dati.add(de);
  10071.        
  10072.         if(policy.getId()!=null && policy.getId()>0){
  10073.             // id
  10074.             de = new DataElement();
  10075.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID);
  10076.             de.setValue(policy.getId()+"");
  10077.             de.setType(DataElementType.HIDDEN);
  10078.             dati.add(de);
  10079.         }
  10080.        
  10081.         if(oldNomeSuggeritoPolicy !=null){
  10082.             // oldNomeSuggerito
  10083.             de = new DataElement();
  10084.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_OLD_NOME_SUGGERITO);
  10085.             de.setValue(oldNomeSuggeritoPolicy);
  10086.             de.setType(DataElementType.HIDDEN);
  10087.             dati.add(de);
  10088.         }
  10089.        
  10090.         if(oldDDescrizioneSuggeritaPolicy !=null){
  10091.             // oldNomeSuggerito
  10092.             de = new DataElement();
  10093.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_OLD_DESCRIZIONE_SUGGERITA);
  10094.             de.setValue(oldDDescrizioneSuggeritaPolicy);
  10095.             de.setType(DataElementType.HIDDEN);
  10096.             dati.add(de);
  10097.         }
  10098.        
  10099.         if(oldPolicyId !=null){
  10100.             // oldId
  10101.             de = new DataElement();
  10102.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_OLD_ID);
  10103.             de.setValue(oldPolicyId);
  10104.             de.setType(DataElementType.HIDDEN);
  10105.             dati.add(de);
  10106.         }
  10107.        
  10108.         /* Servono per le bradcump */
  10109.        
  10110.         // name
  10111.         de = new DataElement();
  10112.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NOME);
  10113.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NOME);
  10114.         de.setValue(policy.getIdPolicy());
  10115.         if(editMode) {
  10116.             de.setType(DataElementType.TEXT_EDIT);
  10117.             de.setRequired(true);
  10118.         }
  10119.         else {
  10120.             de.setType(DataElementType.TEXT);
  10121.         }
  10122.         //de.setSize(consoleHelper.getSize());
  10123.         de.setSize(70);
  10124.         dati.add(de);
  10125.        
  10126.         // descrizione
  10127.         de = new DataElement();
  10128.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_DESCRIZIONE);
  10129.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_DESCRIZIONE);
  10130.         de.setValue(StringEscapeUtils.escapeHtml(policy.getDescrizione()));
  10131.         if(editMode) {
  10132.             de.setType(DataElementType.TEXT_AREA);
  10133.             de.setLabelAffiancata(true);
  10134.             de.setRequired(true);
  10135.         }
  10136.         else {
  10137.             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  10138.         }
  10139.         de.setRows(6);
  10140.         de.setCols(55);
  10141.         //de.setCols(80);
  10142.         dati.add(de);
  10143.        
  10144.         // risorsa  
  10145.         addDataElementRisorsa(dati,
  10146.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA, getDataElementValueRisorsa(policy.getRisorsa(), policy.isSimultanee()),
  10147.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA_ESITI, getDataElementValueRisorsaEsiti(policy.getRisorsa()),
  10148.                 editMode);
  10149.        
  10150.         // Descrizione sul numero di policy attive
  10151.         if(!editMode && numeroPolicyIstanziate>0) {
  10152.             de = new DataElement();
  10153.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ISTANZIATA);
  10154.             String name = ( numeroPolicyIstanziate+" istanza");
  10155.             if(numeroPolicyIstanziate>1) {
  10156.                 name = ( numeroPolicyIstanziate+" istanze");
  10157.             }
  10158.             de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ISTANZIATA_VALUE.
  10159.                     replace(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ISTANZIATA_TEMPLATE,name));
  10160.             de.setType(DataElementType.TEXT);
  10161.             dati.add(de);
  10162.         }
  10163.     }
  10164.    
  10165.     public void addConfigurazionePolicyValoriSoglia(List<DataElement> dati, TipoOperazione tipoOperazione, ConfigurazionePolicy policy, boolean editMode, boolean editOnlyValueMode) throws Exception {
  10166.        
  10167.         DataElement de = new DataElement();
  10168.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_VALORI_SOGLIA);
  10169.         de.setType(DataElementType.TITLE);
  10170.         dati.add(de);
  10171.        
  10172.        
  10173. //      // simultanee
  10174. //      de = new DataElement();
  10175. //      de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_RICHIESTE_SIMULTANEE);
  10176. //      de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_RICHIESTE_SIMULTANEE);
  10177. //      if(TipoRisorsa.NUMERO_RICHIESTE.getValue().equals(policy.getRisorsa())){
  10178. //          if(editMode) {
  10179. //              de.setType(DataElementType.CHECKBOX);
  10180. //          }
  10181. //          else {
  10182. //              de.setType(DataElementType.HIDDEN);
  10183. //          }
  10184. //      }
  10185. //      else{
  10186. //          de.setType(DataElementType.HIDDEN);
  10187. //          policy.setSimultanee(false);
  10188. //      }
  10189. //      de.setSelected(policy.isSimultanee());
  10190. //      de.setValue(policy.isSimultanee()+"");
  10191. //      de.setPostBack_viaPOST(true);
  10192. //      dati.add(de);
  10193. //      
  10194. //      if(TipoRisorsa.NUMERO_RICHIESTE.getValue().equals(policy.getRisorsa()) && !editMode){
  10195. //          // Il valore del parametor originale viene passato come hidden
  10196. //          // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  10197. //          de = new DataElement();
  10198. //          de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_RICHIESTE_SIMULTANEE+
  10199. //                  ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10200. //          de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_RICHIESTE_SIMULTANEE);
  10201. //          if(policy.isSimultanee()) {
  10202. //              de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  10203. //          }
  10204. //          else {
  10205. //              de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  10206. //          }
  10207. //          de.setType(DataElementType.TEXT);
  10208. //          dati.add(de);
  10209. //      }
  10210.        
  10211.        
  10212.        
  10213.         if(policy.isSimultanee()==false && !TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(policy.getRisorsa())){
  10214.            
  10215.             // Modalità di Controllo
  10216.             de = new DataElement();
  10217.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_CONTROLLO);
  10218.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_CONTROLLO);
  10219.             if(TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(policy.getRisorsa())){
  10220.                 de.setType(DataElementType.TEXT);
  10221.                 policy.setModalitaControllo(TipoControlloPeriodo.REALTIME); // obbligatorio il realtime
  10222.                 de.setValue(policy.getModalitaControllo().getValue());
  10223.             }else{
  10224.                 de.setType(DataElementType.SELECT);
  10225.                 de.setValues(ConfigurazioneCostanti.TIPI_CONTROLLO);
  10226.                 de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_CONTROLLO);
  10227.                 if(policy.getModalitaControllo()!=null){
  10228.                     de.setSelected(policy.getModalitaControllo().getValue());
  10229.                     de.setValue(policy.getModalitaControllo().getValue());
  10230.                 }
  10231.             }
  10232.             de.setPostBack_viaPOST(true);
  10233.             if(!editMode) {
  10234.                 de.setType(DataElementType.HIDDEN);
  10235.             }
  10236.             dati.add(de);
  10237.            
  10238.             if(!editMode) {
  10239.                 // Il valore del parametor originale viene passato come hidden
  10240.                 // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  10241.                 de = new DataElement();
  10242.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_CONTROLLO+
  10243.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10244.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_CONTROLLO);
  10245.                 if(TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(policy.getRisorsa())){
  10246.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MODALITA_CONTROLLO_REALTIME);
  10247.                 }
  10248.                 else {
  10249.                     if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  10250.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MODALITA_CONTROLLO_REALTIME);
  10251.                     }
  10252.                     else {
  10253.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MODALITA_CONTROLLO_STATISTICA);
  10254.                     }
  10255.                 }
  10256.                 de.setType(DataElementType.TEXT);
  10257.                 dati.add(de);
  10258.             }
  10259.            
  10260.         }
  10261.        
  10262.         // valore della policy
  10263.         addToDatiPolicyValue(dati, policy, editMode, editOnlyValueMode);
  10264.        
  10265.        
  10266.         if(policy.isSimultanee()==false && !TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(policy.getRisorsa())){
  10267.        
  10268.            
  10269.             // Intervallo Osservazione
  10270.            
  10271.             de = new DataElement();
  10272.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_INTERVALLO_OSSERVAZIONE);
  10273.             de.setType(DataElementType.SUBTITLE);
  10274.             dati.add(de);
  10275.            
  10276.             de = new DataElement();
  10277.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_PERIODO);
  10278.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_PERIODO);
  10279.             if(editMode) {
  10280.                 de.setType(DataElementType.SELECT);
  10281.             }
  10282.             else {
  10283.                 de.setType(DataElementType.HIDDEN);
  10284.             }
  10285.             if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  10286.                 de.setValues(ConfigurazioneCostanti.TIPI_INTERVALLO_OSSERVAZIONE_REALTIME);
  10287.                 de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_INTERVALLO_OSSERVAZIONE_REALTIME);
  10288.                 if(policy.getTipoIntervalloOsservazioneRealtime()!=null){
  10289.                     de.setSelected(policy.getTipoIntervalloOsservazioneRealtime().getValue());
  10290.                     de.setValue(policy.getTipoIntervalloOsservazioneRealtime().getValue());
  10291.                 }
  10292.             }
  10293.             else{
  10294.                 de.setValues(ConfigurazioneCostanti.TIPI_INTERVALLO_OSSERVAZIONE_STATISTICO);
  10295.                 de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_INTERVALLO_OSSERVAZIONE_STATISTICO);
  10296.                 if(policy.getTipoIntervalloOsservazioneStatistico()!=null){
  10297.                     de.setSelected(policy.getTipoIntervalloOsservazioneStatistico().getValue());
  10298.                     de.setValue(policy.getTipoIntervalloOsservazioneStatistico().getValue());
  10299.                 }
  10300.             }
  10301.             de.setPostBack_viaPOST(true);
  10302.             dati.add(de);
  10303.            
  10304.             if(!editMode) {
  10305.                 // Il valore del parametor originale viene passato come hidden
  10306.                 // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  10307.                 de = new DataElement();
  10308.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_PERIODO+
  10309.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10310.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_TIPO_PERIODO);
  10311.                 if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  10312.                     switch (policy.getTipoIntervalloOsservazioneRealtime()) {
  10313.                     case GIORNALIERO:
  10314.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_GIORNALIERO);
  10315.                         break;
  10316.                     case ORARIO:
  10317.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_ORARIO);
  10318.                         break;
  10319.                     case MINUTI:
  10320.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_MINUTI);
  10321.                         break;
  10322.                     case SECONDI:
  10323.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_SECONDI);
  10324.                         break;
  10325.                     }  
  10326.                 }
  10327.                 else {
  10328.                     switch (policy.getTipoIntervalloOsservazioneStatistico()) {
  10329.                     case MENSILE:
  10330.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_MENSILE);
  10331.                         break;
  10332.                     case SETTIMANALE:
  10333.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_SETTIMANALE);
  10334.                         break;
  10335.                     case GIORNALIERO:
  10336.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_GIORNALIERO);
  10337.                         break;
  10338.                     case ORARIO:
  10339.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_ORARIO);
  10340.                         break;
  10341.                     }
  10342.                 }
  10343.                 de.setType(DataElementType.TEXT);
  10344.                 dati.add(de);
  10345.             }
  10346.    
  10347.            
  10348.            
  10349.             // Intervallo Osservazione (Soglia)
  10350.    
  10351.             String labelPeriodo = null;
  10352.             if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  10353.                 labelPeriodo = this.getLabel(policy.getTipoIntervalloOsservazioneRealtime());
  10354.             }else{
  10355.                 labelPeriodo = this.getLabel(policy.getTipoIntervalloOsservazioneStatistico());
  10356.             }
  10357.             de = new DataElement();
  10358.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_PERIODO);
  10359.             de.setLabel(labelPeriodo);
  10360.             if(editMode) {
  10361.                 de.setType(DataElementType.TEXT_EDIT);
  10362.             }else {
  10363.                 de.setType(DataElementType.TEXT);
  10364.             }
  10365.             if(policy.getIntervalloOsservazione()!=null)
  10366.                 de.setValue(policy.getIntervalloOsservazione()+"");
  10367.             if(editMode) {
  10368.                 de.setRequired(true);
  10369.             }
  10370.             //de.setSize(consoleHelper.getSize());
  10371.             dati.add(de);
  10372.            
  10373.            
  10374.            
  10375.             // Intervallo Osservazione (Finestra)
  10376.            
  10377.             DataElement deNoEditMode = null;
  10378.             if(editMode==false) {
  10379.                 deNoEditMode = new DataElement();
  10380.                 deNoEditMode.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_FINESTRA_PERIODO+
  10381.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10382.                 deNoEditMode.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_FINESTRA_PERIODO);
  10383.                 deNoEditMode.setType(DataElementType.TEXT);
  10384.             }
  10385.            
  10386.             de = new DataElement();
  10387.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_FINESTRA_PERIODO);
  10388.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_FINESTRA_PERIODO);
  10389.             if(editMode) {
  10390.                 de.setType(DataElementType.SELECT);
  10391.             }
  10392.             else {
  10393.                 de.setType(DataElementType.HIDDEN);
  10394.             }
  10395.             setValueFinestra(de, deNoEditMode, policy.getModalitaControllo(), policy.getFinestraOsservazione(), policy.getRisorsa(), false);
  10396.             if(!editMode) {
  10397.                 de.setRequired(false);
  10398.             }
  10399.             de.setPostBack_viaPOST(true);          
  10400.             dati.add(de);
  10401.            
  10402.             if(editMode==false) {
  10403.                 dati.add(deNoEditMode);
  10404.             }
  10405.         }
  10406.     }
  10407.    
  10408.     private void setValueFinestra(DataElement de,DataElement deNoEditMode, TipoControlloPeriodo modalitaControllo, TipoFinestra finestra, String risorsa, boolean degrado){
  10409.         boolean found = false;
  10410.         if(TipoControlloPeriodo.REALTIME.equals(modalitaControllo)){
  10411.             de.setValues(ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_REALTIME);
  10412.             de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_FINESTRA_OSSERVAZIONE_REALTIME);
  10413.             if(finestra!=null){
  10414.                 for (int i = 0; i < ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_REALTIME.length; i++) {
  10415.                     if(ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_REALTIME[i].equals(finestra.getValue())){
  10416.                         found = true;
  10417.                         break;
  10418.                     }
  10419.                 }
  10420.             }
  10421.         }
  10422.         else{
  10423.             de.setValues(ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_STATISTICO);
  10424.             de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_FINESTRA_OSSERVAZIONE_STATISTICO);
  10425.             if(finestra!=null){
  10426.                 for (int i = 0; i < ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_STATISTICO.length; i++) {
  10427.                     if(ConfigurazioneCostanti.TIPI_FINESTRA_OSSERVAZIONE_STATISTICO[i].equals(finestra.getValue())){
  10428.                         found = true;
  10429.                         break;
  10430.                     }
  10431.                 }
  10432.             }
  10433.         }
  10434.         if(found){
  10435.             de.setSelected(finestra.getValue());
  10436.             de.setValue(finestra.getValue());
  10437.             if(deNoEditMode!=null) {
  10438.                 switch (finestra) {
  10439.                 case CORRENTE:
  10440.                     deNoEditMode.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FINESTRA_OSSERVAZIONE_CORRENTE);
  10441.                     break;
  10442.                 case PRECEDENTE:
  10443.                     deNoEditMode.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FINESTRA_OSSERVAZIONE_PRECEDENTE);
  10444.                     break;
  10445.                 case SCORREVOLE:
  10446.                     deNoEditMode.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FINESTRA_OSSERVAZIONE_SCORREVOLE);
  10447.                     break;
  10448.                 }
  10449.             }
  10450.         }
  10451.         else{
  10452.             TipoFinestra tipoFinestraDefault = this.getTipoFinestraDefault(modalitaControllo, risorsa, degrado);
  10453.             if(tipoFinestraDefault!=null){
  10454.                 de.setSelected(tipoFinestraDefault.getValue());
  10455.                 de.setValue(tipoFinestraDefault.getValue());
  10456.                 if(deNoEditMode!=null) {
  10457.                     switch (tipoFinestraDefault) {
  10458.                     case CORRENTE:
  10459.                         deNoEditMode.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FINESTRA_OSSERVAZIONE_CORRENTE);
  10460.                         break;
  10461.                     case PRECEDENTE:
  10462.                         deNoEditMode.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FINESTRA_OSSERVAZIONE_PRECEDENTE);
  10463.                         break;
  10464.                     case SCORREVOLE:
  10465.                         deNoEditMode.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FINESTRA_OSSERVAZIONE_SCORREVOLE);
  10466.                         break;
  10467.                     }
  10468.                 }
  10469.             }
  10470.             else{
  10471.                 de.setSelectedAsNull();
  10472.                 de.setValue(null);
  10473.             }
  10474.         }
  10475.     }
  10476.    
  10477.     private void addToDatiPolicyValue(List<DataElement> dati, ConfigurazionePolicy policy, boolean editMode, boolean editOnlyValueMode) throws Exception{
  10478.        
  10479.         TipoRisorsa tipoRisorsa = TipoRisorsa.toEnumConstant(policy.getRisorsa(), true);
  10480.    
  10481.         if(TipoRisorsa.OCCUPAZIONE_BANDA.equals(tipoRisorsa) ){
  10482.            
  10483.             DataElement de = new DataElement();
  10484.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TIPO_BANDA);
  10485.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TIPO_BANDA);
  10486.             if(editMode) {
  10487.                 de.setType(DataElementType.SELECT);
  10488.             }
  10489.             else {
  10490.                 de.setType(DataElementType.HIDDEN);
  10491.             }
  10492.             de.setValues(ConfigurazioneCostanti.TIPI_BANDA);
  10493.             de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_BANDA);
  10494.             if(policy.getValoreTipoBanda()!=null){
  10495.                 de.setSelected(policy.getValoreTipoBanda().getValue());
  10496.                 de.setValue(policy.getValoreTipoBanda().getValue());
  10497.             }
  10498.             de.setPostBack_viaPOST(true);
  10499.             dati.add(de);
  10500.            
  10501.             if(!editMode) {
  10502.                 // Il valore del parametor originale viene passato come hidden
  10503.                 // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  10504.                 de = new DataElement();
  10505.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TIPO_BANDA+
  10506.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10507.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TIPO_BANDA);
  10508.                 switch (policy.getValoreTipoBanda()) {
  10509.                 case COMPLESSIVA:
  10510.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_BANDA_COMPLESSIVA);
  10511.                     break;
  10512.                 case INTERNA:
  10513.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_BANDA_INTERNA);
  10514.                     break;
  10515.                 case ESTERNA:
  10516.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_BANDA_ESTERNA);
  10517.                     break;
  10518.                 }
  10519.                 de.setType(DataElementType.TEXT);
  10520.                 dati.add(de);
  10521.             }
  10522.            
  10523.         }
  10524.        
  10525.         if(TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(tipoRisorsa) || TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(tipoRisorsa)){
  10526.            
  10527.             DataElement de = new DataElement();
  10528.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TIPO_LATENZA);
  10529.             if(TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(tipoRisorsa)){
  10530.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_TIPO_LATENZA);
  10531.             }
  10532.             else{
  10533.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_TIPO_LATENZA);
  10534.             }
  10535.             if(editMode) {
  10536.                 de.setType(DataElementType.SELECT);
  10537.             }
  10538.             else {
  10539.                 de.setType(DataElementType.HIDDEN);
  10540.             }
  10541.             de.setValues(ConfigurazioneCostanti.TIPI_LATENZA);
  10542.             de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_LATENZA);
  10543.             if(policy.getValoreTipoLatenza()!=null){
  10544.                 de.setSelected(policy.getValoreTipoLatenza().getValue());
  10545.                 de.setValue(policy.getValoreTipoLatenza().getValue());
  10546.             }
  10547.             de.setPostBack_viaPOST(true);
  10548.             dati.add(de);
  10549.            
  10550.             if(!editMode) {
  10551.                 // Il valore del parametor originale viene passato come hidden
  10552.                 // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  10553.                 de = new DataElement();
  10554.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TIPO_LATENZA+
  10555.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10556.                 if(TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(tipoRisorsa)){
  10557.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_TIPO_LATENZA);
  10558.                 }
  10559.                 else{
  10560.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_TIPO_LATENZA);
  10561.                 }
  10562.                 switch (policy.getValoreTipoLatenza()) {
  10563.                 case TOTALE:
  10564.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_LATENZA_TOTALE);
  10565.                     break;
  10566.                     // Porta non usato
  10567. //                  case PORTA:
  10568. //                      de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_LATENZA_PORTA);
  10569. //                      break;
  10570.                 case SERVIZIO:
  10571.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_LATENZA_SERVIZIO);
  10572.                     break;
  10573.                 case PORTA:
  10574.                     break;
  10575.                 }
  10576.                 de.setType(DataElementType.TEXT);
  10577.                 dati.add(de);
  10578.             }
  10579.            
  10580.         }
  10581.        
  10582.         if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa) ){
  10583.             DataElement de = new DataElement();
  10584.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_2);
  10585.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RICHIESTA_LABEL);
  10586.             if(editMode || editOnlyValueMode) {
  10587.                 de.setType(DataElementType.TEXT_EDIT);
  10588.                 de.setRequired(true);
  10589.             }
  10590.             else {
  10591.                 de.setType(DataElementType.TEXT);
  10592.             }
  10593.             if(policy.getValore2()!=null){
  10594.                 de.setValue(policy.getValore2()+"");
  10595.             }
  10596.             //de.setSize(consoleHelper.getSize());
  10597.             dati.add(de);          
  10598.         }
  10599.            
  10600.         DataElement de = new DataElement();
  10601.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE);
  10602.         switch (tipoRisorsa) {
  10603.         case NUMERO_RICHIESTE:
  10604.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  10605.             break;
  10606.         case DIMENSIONE_MASSIMA_MESSAGGIO:
  10607.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RISPOSTA_LABEL);
  10608.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_NOTE);
  10609.             break;
  10610.         case OCCUPAZIONE_BANDA:
  10611.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_OCCUPAZIONE_DI_BANDA_LABEL);
  10612.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_OCCUPAZIONE_DI_BANDA_NOTE);
  10613.             break;
  10614.         case TEMPO_MEDIO_RISPOSTA:
  10615.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_LABEL);
  10616.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_NOTE);
  10617.             break;
  10618.         case TEMPO_COMPLESSIVO_RISPOSTA:
  10619.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_LABEL);
  10620.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_NOTE);
  10621.             break;
  10622.         case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO:
  10623.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  10624.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_NOTE);
  10625.             break;
  10626.         case NUMERO_RICHIESTE_FALLITE:
  10627.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  10628.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE_FALLITE_NOTE);
  10629.             break;
  10630.         case NUMERO_FAULT_APPLICATIVI:
  10631.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  10632.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_FAULT_APPLICATIVI_NOTE);
  10633.             break;
  10634.         case NUMERO_RICHIESTE_FALLITE_OFAULT_APPLICATIVI:
  10635.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  10636.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE_FALLITE_O_FAULT_APPLICATIVI_NOTE);
  10637.             break;
  10638.         case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_OFAULT_APPLICATIVI:
  10639.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  10640.             de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_O_FAULT_APPLICATIVI_NOTE);
  10641.             break;
  10642.         }
  10643.         if(editMode || editOnlyValueMode) {
  10644.             de.setType(DataElementType.TEXT_EDIT);
  10645.             de.setRequired(true);
  10646.         }
  10647.         else {
  10648.             de.setType(DataElementType.TEXT);
  10649.         }
  10650.         if(policy.getValore()!=null){
  10651.             de.setValue(policy.getValore()+"");
  10652.         }
  10653.         //de.setSize(consoleHelper.getSize());
  10654.         dati.add(de);
  10655.        
  10656.         if(!editMode) {
  10657.            
  10658.             if(editOnlyValueMode) {
  10659.                
  10660.                 de = new DataElement();
  10661.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_MODIFICATO_CON_ISTANZE_ATTIVE_MODIFICA_EFFETTIVA);
  10662.                 de.setType(DataElementType.HIDDEN);
  10663.                 de.setValue(Costanti.CHECK_BOX_ENABLED);
  10664.                 dati.add(de);
  10665.                
  10666.             }
  10667.             else {
  10668.                            
  10669.                 // Link modifica
  10670.                 de = new DataElement();
  10671.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_MODIFICATO_CON_ISTANZE_ATTIVE_RICHIESTA_MODIFICA);
  10672.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_MODIFICATO_CON_ISTANZE_ATTIVE_RICHIESTA_MODIFICA);
  10673.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_MODIFICATO_CON_ISTANZE_ATTIVE_RICHIESTA_MODIFICA);
  10674.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_CONFIGURAZIONE_POLICY_CHANGE,
  10675.                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID,policy.getId()+""),
  10676.                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_MODIFICATO_CON_ISTANZE_ATTIVE_RICHIESTA_MODIFICA,Costanti.CHECK_BOX_ENABLED));
  10677.                 de.setType(DataElementType.LINK);
  10678.                 dati.add(de);
  10679.                
  10680.             }
  10681.         }
  10682.     }
  10683.    
  10684.     public void addConfigurazionePolicyApplicabilitaToDati(List<DataElement> dati, TipoOperazione tipoOperazione,  ConfigurazionePolicy policy, ConfigurazioneControlloTraffico controlloTraffico, boolean editMode) throws Exception {
  10685.        
  10686.         if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(policy.getRisorsa())){
  10687.             return;
  10688.         }
  10689.        
  10690.         DataElement de = new DataElement();
  10691.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_APPLICABILITA);
  10692.         de.setType(DataElementType.TITLE);
  10693.         dati.add(de);
  10694.        
  10695.        
  10696.         // condizionale
  10697.         de = new DataElement();
  10698.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_TIPO);
  10699.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_TIPO);
  10700.         boolean condizionata = TipoApplicabilita.CONDIZIONALE.equals(policy.getTipoApplicabilita());
  10701.         if(editMode) {
  10702.             de.setType(DataElementType.CHECKBOX);
  10703.         }
  10704.         else {
  10705.             de.setType(DataElementType.HIDDEN);
  10706.         }
  10707.         de.setSelected(condizionata);
  10708.         de.setValue(condizionata+"");
  10709.         de.setPostBack_viaPOST(true);
  10710.         dati.add(de);
  10711.        
  10712.         if(!editMode){
  10713.             // Il valore del parametor originale viene passato come hidden
  10714.             // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  10715.             de = new DataElement();
  10716.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_TIPO+
  10717.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10718.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_TIPO);
  10719.             if(condizionata) {
  10720.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  10721.             }
  10722.             else {
  10723.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  10724.             }
  10725.             de.setType(DataElementType.TEXT);
  10726.             dati.add(de);
  10727.         }
  10728.        
  10729.         // con congestione in corso
  10730.         de = new DataElement();
  10731.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE);
  10732.         //de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_LABEL);
  10733.         //de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_NOTE);
  10734.         de.setLabelRight(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_NOTE);
  10735.         if(condizionata){
  10736.             if(editMode) {
  10737.                 de.setType(DataElementType.CHECKBOX);
  10738.                
  10739.                 DataElementInfo dInfoDescrizioneCongestione = new DataElementInfo(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_LABEL);
  10740.                 dInfoDescrizioneCongestione.setHeaderBody(replaceToHtmlSeparator(this.getApplicabilitaConCongestione(controlloTraffico)));
  10741.                 de.setInfo(dInfoDescrizioneCongestione);
  10742.             }
  10743.             else {
  10744.                 de.setType(DataElementType.HIDDEN);
  10745.             }
  10746.             de.setPostBack_viaPOST(true);
  10747.         }
  10748.         else{
  10749.             de.setType(DataElementType.HIDDEN);
  10750.             policy.setApplicabilitaConCongestione(false);
  10751.         }
  10752.         de.setSelected(policy.isApplicabilitaConCongestione());
  10753.         de.setValue(policy.isApplicabilitaConCongestione()+"");
  10754.         dati.add(de);
  10755.        
  10756.         if(!editMode && condizionata){
  10757.             // Il valore del parametor originale viene passato come hidden
  10758.             // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  10759.             if(policy.isApplicabilitaConCongestione()) {
  10760.                 de = new DataElement();
  10761.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE+
  10762.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10763.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_NOTE);
  10764.                 de.setType(DataElementType.TEXT);
  10765.                 dati.add(de);
  10766.             }
  10767.         }
  10768.        
  10769.         // con degrado prestazionale
  10770.         de = new DataElement();
  10771.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE);
  10772.         //de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_LABEL);
  10773.         //de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_NOTE);
  10774.         de.setLabelRight(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_NOTE);
  10775.         if(condizionata &&
  10776.                 !TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(policy.getRisorsa()) &&
  10777.                 !TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(policy.getRisorsa())
  10778.             ){
  10779.             if(editMode) {
  10780.                 de.setType(DataElementType.CHECKBOX);
  10781.                 DataElementInfo dInfoDescrizioneDegrado = new DataElementInfo(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_LABEL);
  10782.                 dInfoDescrizioneDegrado.setHeaderBody(replaceToHtmlSeparator(this.getApplicabilitaDegradoPrestazionale()));
  10783.                 de.setInfo(dInfoDescrizioneDegrado);
  10784.             }
  10785.             else {
  10786.                 de.setType(DataElementType.HIDDEN);
  10787.             }
  10788.             de.setPostBack_viaPOST(true);
  10789.         }
  10790.         else{
  10791.             de.setType(DataElementType.HIDDEN);
  10792.             policy.setApplicabilitaDegradoPrestazionale(false);
  10793.         }
  10794.         de.setSelected(policy.isApplicabilitaDegradoPrestazionale());
  10795.         de.setValue(policy.isApplicabilitaDegradoPrestazionale()+"");
  10796.         dati.add(de);
  10797.        
  10798.         if(!editMode && condizionata &&
  10799.                 !TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(policy.getRisorsa()) &&
  10800.                 !TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(policy.getRisorsa()) ) {
  10801.             // Il valore del parametor originale viene passato come hidden
  10802.             // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  10803.             if(policy.isApplicabilitaDegradoPrestazionale()) {
  10804.                 de = new DataElement();
  10805.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE+
  10806.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10807.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_NOTE);
  10808.                 de.setType(DataElementType.TEXT);
  10809.                 dati.add(de);
  10810.             }
  10811.         }
  10812.        
  10813.         // con stato allarme
  10814.         de = new DataElement();
  10815.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME);
  10816.         //de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_LABEL);
  10817.         //de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOTE);
  10818.         de.setLabelRight(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOTE);
  10819.         if(condizionata && this.confCore.isConfigurazioneAllarmiEnabled()){
  10820.             if(editMode) {
  10821.                 de.setType(DataElementType.CHECKBOX);
  10822.                
  10823.                 DataElementInfo dInfoDescrizioneAllarmi = new DataElementInfo(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_LABEL);
  10824.                 dInfoDescrizioneAllarmi.setHeaderBody(replaceToHtmlSeparator(this.getApplicabilitaAllarmi()));
  10825.                 de.setInfo(dInfoDescrizioneAllarmi);
  10826.             }
  10827.             else {
  10828.                 de.setType(DataElementType.HIDDEN);
  10829.             }
  10830.             de.setPostBack_viaPOST(true);
  10831.         }
  10832.         else{
  10833.             de.setType(DataElementType.HIDDEN);
  10834.             policy.setApplicabilitaStatoAllarme(false);
  10835.         }
  10836.         de.setSelected(policy.isApplicabilitaStatoAllarme());
  10837.         de.setValue(policy.isApplicabilitaStatoAllarme()+"");
  10838.         dati.add(de);
  10839.        
  10840.         if(!editMode && condizionata && this.confCore.isConfigurazioneAllarmiEnabled()){
  10841.             // Il valore del parametor originale viene passato come hidden
  10842.             // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  10843.             if(policy.isApplicabilitaStatoAllarme()) {
  10844.                 de = new DataElement();
  10845.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME+
  10846.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10847.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOTE);
  10848.                 de.setType(DataElementType.TEXT);
  10849.                 dati.add(de);
  10850.             }
  10851.         }
  10852.        
  10853.         // ConCongestione
  10854.         //addToApplicabilitaConCongestione(dati, tipoOperazione, policy, controlloTraffico, editMode);
  10855.        
  10856.         // Degrado Prestazionale
  10857.         addToApplicabilitaDegradoPrestazionale(dati, tipoOperazione, policy , editMode);
  10858.        
  10859.         // StatoAllarme
  10860.         addToApplicabilitaStatoAllarme(dati, tipoOperazione, policy , editMode);
  10861.     }
  10862.    
  10863.     // Metodo soppiantato dall'info
  10864.     @SuppressWarnings("unused")
  10865.     private void addToApplicabilitaConCongestione(List<DataElement> dati, TipoOperazione tipoOperazione, ConfigurazionePolicy policy, ConfigurazioneControlloTraffico controlloTraffico, boolean editMode) throws Exception {
  10866.        
  10867.         if(policy.isApplicabilitaConCongestione()){
  10868.             DataElement de = new DataElement();
  10869.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONGESTIONE);
  10870.             de.setType(DataElementType.TITLE);
  10871.             dati.add(de);
  10872.            
  10873.             // Note
  10874.             de = new DataElement();
  10875.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_NOTE);
  10876.             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  10877.             de.setRows(4);
  10878.             de.setCols(55);
  10879.             de.setValue(this.getApplicabilitaConCongestione(controlloTraffico));
  10880.             dati.add(de);
  10881.         }
  10882.        
  10883.     }
  10884.    
  10885.     private String getApplicabilitaConCongestione(ConfigurazioneControlloTraffico controlloTraffico) {
  10886.        
  10887.         String result = null;
  10888.        
  10889.         if(controlloTraffico.isControlloCongestioneEnabled()){
  10890.            
  10891.             Integer soglia = controlloTraffico.getControlloCongestioneThreshold();
  10892.             Long numeroThreadCongestionamento = null;
  10893.             Long numeroThreadComplessivi = controlloTraffico.getControlloMaxThreadsSoglia();
  10894.            
  10895.             double numD = numeroThreadComplessivi.doubleValue();
  10896.             double totale = 100d;
  10897.             double sogliaD = soglia.doubleValue();
  10898.             Double numeroThreadCongestionamentoD = (numD / totale) *  sogliaD;
  10899.             numeroThreadCongestionamento = numeroThreadCongestionamentoD.longValue();
  10900.        
  10901.             result = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_NOTE_CONGESTION_ACTIVE_AS_TEXT.
  10902.                     replace(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_NOTE_NUMERO, numeroThreadCongestionamento+"");
  10903.         }
  10904.         else{
  10905.            
  10906.             result = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_NOTE_CONGESTION_NOT_ACTIVE_AS_TEXT;
  10907.            
  10908.         }
  10909.        
  10910.         return result;
  10911.     }
  10912.    
  10913.     @SuppressWarnings("incomplete-switch")
  10914.     private void addToApplicabilitaDegradoPrestazionale(List<DataElement> dati, TipoOperazione tipoOperazione, ConfigurazionePolicy policy, boolean editMode) throws Exception {
  10915.        
  10916.         if(policy.isApplicabilitaDegradoPrestazionale()){
  10917.             DataElement de = new DataElement();
  10918.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DEGRADO_PRESTAZIONALE);
  10919.             de.setType(DataElementType.TITLE);
  10920.             dati.add(de);
  10921.            
  10922.             // Spostato nell'info
  10923. //          // Note
  10924. //          de = new DataElement();
  10925. //          de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_NOTE);
  10926. //          de.setValue(this.getApplicabilitaDegradoPrestazionale());
  10927. //          de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  10928. //          de.setRows(6);
  10929. //          de.setCols(55);
  10930. //          dati.add(de);
  10931.         }
  10932.        
  10933.         // Modalità di Controllo
  10934.         DataElement de = new DataElement();
  10935.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_CONTROLLO);
  10936.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_CONTROLLO);
  10937.         if(policy.isApplicabilitaDegradoPrestazionale()){
  10938.             de.setType(DataElementType.SELECT);
  10939.             de.setValues(ConfigurazioneCostanti.TIPI_CONTROLLO);
  10940.             de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_CONTROLLO);
  10941.             if(policy.getDegradoAvgTimeModalitaControllo()==null){
  10942.                 policy.setDegradoAvgTimeModalitaControllo(ConfigurazioneCostanti.TIPO_CONTROLLO_PERIODO_DEFAULT);
  10943.             }
  10944.             de.setSelected(policy.getDegradoAvgTimeModalitaControllo().getValue());
  10945.             de.setPostBack_viaPOST(true);
  10946.         }
  10947.         else{
  10948.             de.setType(DataElementType.HIDDEN);
  10949.             policy.setDegradoAvgTimeModalitaControllo(null);
  10950.         }
  10951.         if(policy.getDegradoAvgTimeModalitaControllo()!=null){
  10952.             de.setValue(policy.getDegradoAvgTimeModalitaControllo().getValue());
  10953.         }
  10954.         else{
  10955.             de.setValue(null);
  10956.         }
  10957.         if(!editMode) {
  10958.             de.setType(DataElementType.HIDDEN);
  10959.         }
  10960.         dati.add(de);
  10961.        
  10962.         if(!editMode && policy.isApplicabilitaDegradoPrestazionale()){
  10963.             // Il valore del parametor originale viene passato come hidden
  10964.             // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  10965.             de = new DataElement();
  10966.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_CONTROLLO+
  10967.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  10968.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_CONTROLLO);
  10969.             switch (policy.getDegradoAvgTimeModalitaControllo()) {
  10970.             case REALTIME:
  10971.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MODALITA_CONTROLLO_REALTIME);
  10972.                 break;
  10973.             case STATISTIC:
  10974.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MODALITA_CONTROLLO_STATISTICA);
  10975.                 break;
  10976.             }
  10977.             de.setType(DataElementType.TEXT);
  10978.             dati.add(de);
  10979.         }
  10980.        
  10981.        
  10982.         // Tipo Latenza
  10983.         de = new DataElement();
  10984.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_LATENZA);
  10985.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_LATENZA);
  10986.         if(policy.isApplicabilitaDegradoPrestazionale()){
  10987.             de.setType(DataElementType.SELECT);
  10988.             de.setValues(ConfigurazioneCostanti.TIPI_LATENZA);
  10989.             de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_LATENZA);
  10990.             if(policy.getDegradoAvgTimeTipoLatenza()==null){
  10991.                 policy.setDegradoAvgTimeTipoLatenza(ConfigurazioneCostanti.TIPO_LATENZA_DEFAULT);
  10992.             }
  10993.             de.setSelected(policy.getDegradoAvgTimeTipoLatenza().getValue());
  10994.             de.setPostBack_viaPOST(true);
  10995.         }
  10996.         else{
  10997.             de.setType(DataElementType.HIDDEN);
  10998.             policy.setDegradoAvgTimeTipoLatenza(null);
  10999.         }
  11000.         if(policy.getDegradoAvgTimeTipoLatenza()!=null){
  11001.             de.setValue(policy.getDegradoAvgTimeTipoLatenza().getValue());
  11002.         }
  11003.         else{
  11004.             de.setValue(null);
  11005.         }
  11006.         if(!editMode) {
  11007.             de.setType(DataElementType.HIDDEN);
  11008.         }
  11009.         dati.add(de);
  11010.        
  11011.         if(!editMode && policy.isApplicabilitaDegradoPrestazionale()){
  11012.             // Il valore del parametor originale viene passato come hidden
  11013.             // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  11014.             de = new DataElement();
  11015.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_LATENZA+
  11016.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  11017.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_LATENZA);
  11018.             switch (policy.getDegradoAvgTimeTipoLatenza()) {
  11019.             case TOTALE:
  11020.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_LATENZA_TOTALE);
  11021.                 break;
  11022.                 // Non supportato
  11023. //          case PORTA:
  11024. //              de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_LATENZA_PORTA);
  11025. //              break;
  11026.             case SERVIZIO:
  11027.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_LATENZA_SERVIZIO);
  11028.                 break;
  11029.             }
  11030.             de.setType(DataElementType.TEXT);
  11031.             dati.add(de);
  11032.         }
  11033.        
  11034.                
  11035.         // Intervallo Osservazione
  11036.        
  11037.         if(policy.isApplicabilitaDegradoPrestazionale()){
  11038.             de = new DataElement();
  11039.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_INTERVALLO_OSSERVAZIONE);
  11040.             de.setType(DataElementType.SUBTITLE);
  11041.             dati.add(de);
  11042.         }
  11043.        
  11044.         de = new DataElement();
  11045.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_PERIODO);
  11046.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_PERIODO);
  11047.         if(policy.isApplicabilitaDegradoPrestazionale()){
  11048.             de.setType(DataElementType.SELECT);
  11049.             if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  11050.                 de.setValues(ConfigurazioneCostanti.TIPI_INTERVALLO_OSSERVAZIONE_REALTIME);
  11051.                 de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_INTERVALLO_OSSERVAZIONE_REALTIME);
  11052.                 if(policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime()==null){
  11053.                     policy.setDegradoAvgTimeTipoIntervalloOsservazioneRealtime(ConfigurazioneCostanti.TIPO_PERIODO_REALTIME_DEFAULT);
  11054.                 }
  11055.                 de.setSelected(policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime().getValue());
  11056.             }
  11057.             else{
  11058.                 de.setValues(ConfigurazioneCostanti.TIPI_INTERVALLO_OSSERVAZIONE_STATISTICO);
  11059.                 de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPI_INTERVALLO_OSSERVAZIONE_STATISTICO);
  11060.                 if(policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico()==null){
  11061.                     policy.setDegradoAvgTimeTipoIntervalloOsservazioneStatistico(ConfigurazioneCostanti.TIPO_PERIODO_STATISTICO_DEFAULT);
  11062.                 }
  11063.                 de.setSelected(policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico().getValue());
  11064.             }
  11065.             de.setPostBack_viaPOST(true);
  11066.         }
  11067.         else{
  11068.             de.setType(DataElementType.HIDDEN);
  11069.             policy.setDegradoAvgTimeTipoIntervalloOsservazioneRealtime(null);
  11070.             policy.setDegradoAvgTimeTipoIntervalloOsservazioneStatistico(null);
  11071.         }
  11072.         if(policy.getDegradoAvgTimeModalitaControllo()!=null){
  11073.             if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  11074.                 if(policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime()!=null){
  11075.                     de.setValue(policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime().getValue());
  11076.                 }
  11077.                 else{
  11078.                     de.setValue(null);
  11079.                 }
  11080.             }
  11081.             else{
  11082.                 if(policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico()!=null){
  11083.                     de.setValue(policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico().getValue());
  11084.                 }
  11085.                 else{
  11086.                     de.setValue(null);
  11087.                 }
  11088.             }
  11089.         }
  11090.         else{
  11091.             de.setValue(null);
  11092.         }
  11093.         if(!editMode) {
  11094.             de.setType(DataElementType.HIDDEN);
  11095.         }
  11096.         dati.add(de);
  11097.        
  11098.         if(!editMode && policy.isApplicabilitaDegradoPrestazionale()){
  11099.             // Il valore del parametor originale viene passato come hidden
  11100.             // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  11101.             de = new DataElement();
  11102.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_PERIODO+
  11103.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  11104.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_TIPO_PERIODO);
  11105.             if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  11106.                 switch (policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime()) {
  11107.                 case GIORNALIERO:
  11108.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_GIORNALIERO);
  11109.                     break;
  11110.                 case ORARIO:
  11111.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_ORARIO);
  11112.                     break;
  11113.                 case MINUTI:
  11114.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_MINUTI);
  11115.                     break;
  11116.                 case SECONDI:
  11117.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_SECONDI);
  11118.                     break;
  11119.                 }  
  11120.             }
  11121.             else {
  11122.                 switch (policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico()) {
  11123.                 case MENSILE:
  11124.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_MENSILE);
  11125.                     break;
  11126.                 case SETTIMANALE:
  11127.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_SETTIMANALE);
  11128.                     break;
  11129.                 case GIORNALIERO:
  11130.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_GIORNALIERO);
  11131.                     break;
  11132.                 case ORARIO:
  11133.                     de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TIPO_PERIODO_ORARIO);
  11134.                     break;
  11135.                 }
  11136.             }
  11137.             de.setType(DataElementType.TEXT);
  11138.             dati.add(de);
  11139.         }
  11140.        
  11141.        
  11142.         // Intervallo Osservazione (Soglia)

  11143.         String labelIntervallo = null;
  11144.         if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  11145.             labelIntervallo = this.getLabel(policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime());
  11146.         }
  11147.         else{
  11148.             labelIntervallo = this.getLabel(policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico());
  11149.         }
  11150.         de = new DataElement();
  11151.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_PERIODO);
  11152.         de.setLabel(labelIntervallo);
  11153.         if(policy.isApplicabilitaDegradoPrestazionale()){
  11154.             if(editMode) {
  11155.                 de.setType(DataElementType.TEXT_EDIT);
  11156.                 de.setRequired(true);
  11157.             }else {
  11158.                 de.setType(DataElementType.TEXT);
  11159.             }
  11160.         }
  11161.         else{
  11162.             de.setType(DataElementType.HIDDEN);
  11163.             policy.setDegradoAvgTimeIntervalloOsservazione(null);
  11164.         }
  11165.         if(policy.getDegradoAvgTimeIntervalloOsservazione()!=null){
  11166.             de.setValue(policy.getDegradoAvgTimeIntervalloOsservazione()+"");
  11167.         }
  11168.         //de.setSize(consoleHelper.getSize());
  11169.         dati.add(de);
  11170.        
  11171.        
  11172.        
  11173.         // Intervallo Osservazione (Finestra)
  11174.        
  11175.         DataElement deNoEditMode = null;
  11176.         if(editMode==false) {
  11177.             deNoEditMode = new DataElement();
  11178.             deNoEditMode.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_FINESTRA_PERIODO+
  11179.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  11180.             deNoEditMode.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_FINESTRA_PERIODO);
  11181.             deNoEditMode.setType(DataElementType.TEXT);
  11182.         }
  11183.        
  11184.         de = new DataElement();
  11185.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_FINESTRA_PERIODO);
  11186.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_FINESTRA_PERIODO);
  11187.         if(editMode) {
  11188.             de.setType(DataElementType.SELECT);
  11189.         }
  11190.         else {
  11191.             de.setType(DataElementType.HIDDEN);
  11192.         }
  11193.         setValueFinestra(de, deNoEditMode, policy.getDegradoAvgTimeModalitaControllo(), policy.getDegradoAvgTimeFinestraOsservazione(), policy.getRisorsa(), true);
  11194.         if(!editMode) {
  11195.             de.setRequired(false);
  11196.         }
  11197.         if(policy.isApplicabilitaDegradoPrestazionale()==false){
  11198.             de.setType(DataElementType.HIDDEN);
  11199.         }
  11200.         else{
  11201.             de.setPostBack_viaPOST(true);
  11202.         }
  11203.         dati.add(de);
  11204.        
  11205.         if(editMode==false && policy.isApplicabilitaDegradoPrestazionale()) {
  11206.             dati.add(deNoEditMode);
  11207.         }
  11208.        
  11209.        
  11210.     }
  11211.    
  11212.     private String getApplicabilitaDegradoPrestazionale() {
  11213.        
  11214.         String result = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_NOTE_AS_TEXT;
  11215.         return result;
  11216.        
  11217.     }
  11218.    
  11219.     private void addToApplicabilitaStatoAllarme(List<DataElement> dati, TipoOperazione tipoOperazione, ConfigurazionePolicy policy, boolean editMode) throws Exception {
  11220.        
  11221.         if(policy.isApplicabilitaStatoAllarme()){
  11222.             DataElement de = new DataElement();
  11223.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ALLARME);
  11224.             de.setType(DataElementType.TITLE);
  11225.             dati.add(de);
  11226.            
  11227. //          // Note
  11228. //          de = new DataElement();
  11229. //          de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOTE);
  11230. //          de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOTE_AS_TEXT);
  11231. //          de.setType(DataElementType.TEXT);
  11232. ////            de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  11233. ////            de.setRows(6);
  11234. ////            de.setCols(80);
  11235. //          dati.add(de);
  11236.         }
  11237.        
  11238.         List<String> allarmi_id = null;
  11239.         List<String> allarmi_alias = null;
  11240.         if(policy.isApplicabilitaStatoAllarme()){
  11241.             try{
  11242.                 // Permetto di creare policy legate solamente a allarmi globali
  11243.                 List<Allarme> listAllarmiGlobali = this.confCore.allarmiSenzaPluginList(new ConsoleSearch(true), null, null);
  11244.                 if(listAllarmiGlobali!=null && !listAllarmiGlobali.isEmpty()) {
  11245.                     allarmi_id = new ArrayList<>();
  11246.                     allarmi_alias = new ArrayList<>();
  11247.                     for (Allarme allarme : listAllarmiGlobali) {
  11248.                         allarmi_id.add(allarme.getNome());
  11249.                         allarmi_alias.add(allarme.getAlias());
  11250.                     }
  11251.                 }
  11252.             }catch(Exception eError){
  11253.                 this.logError(eError.getMessage(),eError);
  11254.             }
  11255.         }
  11256.         if(allarmi_id==null){
  11257.             allarmi_id = new ArrayList<>();
  11258.         }
  11259.        
  11260.         if(policy.isApplicabilitaStatoAllarme() && allarmi_id.size()<=0){
  11261.             DataElement de = new DataElement();
  11262.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_NON_ESISTENTI);
  11263.             de.setType(DataElementType.NOTE);
  11264.             dati.add(de);
  11265.         }
  11266.        
  11267.         // Nome
  11268.         DataElement de = new DataElement();
  11269.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOME);
  11270.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOME);
  11271.         if(policy.isApplicabilitaStatoAllarme() && allarmi_id.size()>0){
  11272.             String [] values = null;
  11273.             String [] labels = null;
  11274.             int index = 0;
  11275.             if(TipoOperazione.CHANGE.equals(tipoOperazione)){
  11276.                 values = new String[allarmi_id.size()];
  11277.                 labels = new String[allarmi_alias.size()];
  11278.             }
  11279.             else{
  11280.                 values = new String[allarmi_id.size() + 1];
  11281.                 labels = new String[allarmi_alias.size() + 1];
  11282.                 values[0] = "-";
  11283.                 labels[0] = "-";
  11284.                 index = 1;
  11285.             }

  11286.             for (int i = 0; i < allarmi_id.size(); i++) {
  11287.                 values[index] = allarmi_id.get(i);
  11288.                 labels[index++] = allarmi_alias.get(i);
  11289.             }
  11290.             de.setType(DataElementType.SELECT);
  11291.             de.setValues(values);
  11292.             de.setLabels(labels);
  11293.             if(policy.getAllarmeNome()!=null){
  11294.                 de.setSelected(policy.getAllarmeNome());
  11295.             }
  11296.             else{
  11297.                 de.setSelected("-");
  11298.             }
  11299.             de.setRequired(true);
  11300.         }
  11301.         else{
  11302.             de.setType(DataElementType.HIDDEN);
  11303.             policy.setAllarmeNome(null);
  11304.         }
  11305.         de.setValue(policy.getAllarmeNome());
  11306.         if(!editMode) {
  11307.             de.setType(DataElementType.HIDDEN);
  11308.         }
  11309.         dati.add(de);
  11310.        
  11311.         if(!editMode && policy.isApplicabilitaStatoAllarme() && allarmi_id.size()>0){
  11312.             // Il valore del parametor originale viene passato come hidden
  11313.             // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  11314.             de = new DataElement();
  11315.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOME+
  11316.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  11317.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOME);
  11318.             de.setValue(policy.getAllarmeNome());
  11319.             de.setType(DataElementType.TEXT);
  11320.             dati.add(de);
  11321.         }
  11322.        
  11323.        
  11324.         // NotStato
  11325.         de = new DataElement();
  11326.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOT_STATO);
  11327.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOT_STATO);
  11328.         if(policy.isApplicabilitaStatoAllarme() && allarmi_id.size()>0){
  11329.             if(editMode) {
  11330.                 de.setType(DataElementType.CHECKBOX);
  11331.             }
  11332.             else {
  11333.                 de.setType(DataElementType.HIDDEN);
  11334.             }
  11335.         }
  11336.         else{
  11337.             de.setType(DataElementType.HIDDEN);
  11338.             policy.setAllarmeNotStato(false);
  11339.         }
  11340.         de.setSelected(policy.isAllarmeNotStato());
  11341.         de.setValue(policy.isAllarmeNotStato()+"");
  11342.         dati.add(de);
  11343.        
  11344.         if(!editMode && policy.isApplicabilitaStatoAllarme() && allarmi_id.size()>0){
  11345.             // Il valore del parametor originale viene passato come hidden
  11346.             // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  11347.             de = new DataElement();
  11348.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOT_STATO+
  11349.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  11350.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOT_STATO);
  11351.             if(policy.isAllarmeNotStato()) {
  11352.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  11353.             }
  11354.             else {
  11355.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  11356.             }
  11357.             de.setType(DataElementType.TEXT);
  11358.             dati.add(de);
  11359.         }
  11360.        
  11361.        
  11362.         // Stato
  11363.         de = new DataElement();
  11364.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_STATO);
  11365.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_STATO);
  11366.         if(policy.isApplicabilitaStatoAllarme() && allarmi_id.size()>0){
  11367.             de.setType(DataElementType.SELECT);
  11368.             de.setValues(ConfigurazioneCostanti.CONFIGURAZIONE_STATI_ALLARMI);
  11369.             de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATI_ALLARMI);
  11370.             if(policy.getAllarmeStato()==null){
  11371.                 policy.setAllarmeStato(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_DEFAULT);
  11372.             }
  11373.             de.setSelected(policy.getAllarmeStato()+"");
  11374.         }
  11375.         else{
  11376.             de.setType(DataElementType.HIDDEN);
  11377.             policy.setAllarmeStato(null);
  11378.         }
  11379.         if(policy.getAllarmeStato()!=null){
  11380.             de.setSelected(policy.getAllarmeStato()+"");
  11381.         }
  11382.         else{
  11383.             de.setValue(null);
  11384.         }
  11385.         if(!editMode) {
  11386.             de.setType(DataElementType.HIDDEN);
  11387.         }
  11388.         dati.add(de);
  11389.        
  11390.         if(!editMode && policy.isApplicabilitaStatoAllarme() && allarmi_id.size()>0){
  11391.             // Il valore del parametor originale viene passato come hidden
  11392.             // L'elemento seguente serve solo come presentation, infatti il nome del parametro termina con un suffisso noEdit
  11393.             de = new DataElement();
  11394.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_STATO+
  11395.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NO_EDIT_SUFFIX);
  11396.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_STATO);
  11397.             if(policy.getAllarmeStato()!=null) {
  11398.                 if(policy.getAllarmeStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_OK) {
  11399.                     de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_OK);      
  11400.                 }
  11401.                 else if(policy.getAllarmeStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_WARNING) {
  11402.                     de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_WARNING);    
  11403.                 }
  11404.                 else {
  11405.                     de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_ERROR);      
  11406.                 }
  11407.             }
  11408.             de.setType(DataElementType.TEXT);
  11409.             dati.add(de);
  11410.         }

  11411.     }
  11412.    
  11413.     private String getApplicabilitaAllarmi() {
  11414.        
  11415.         String result = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOTE_AS_TEXT;
  11416.         return result;
  11417.        
  11418.     }
  11419.    
  11420.     public String getLabel(TipoPeriodoRealtime tipo){
  11421.         if(tipo==null){
  11422.             return "Valore";
  11423.         }
  11424.         switch (tipo) {
  11425.         case SECONDI:
  11426.             return "Secondi";
  11427.         case MINUTI:
  11428.             return "Minuti";
  11429.         case ORARIO:
  11430.             return "Ore";
  11431.         case GIORNALIERO:
  11432.             return "Giorni";
  11433.         default:
  11434.             return "Valore";
  11435.         }
  11436.     }
  11437.     public String getLabel(TipoPeriodoStatistico tipo){
  11438.         if(tipo==null){
  11439.             return "Valore";
  11440.         }
  11441.         switch (tipo) {
  11442.         case ORARIO:
  11443.             return "Ore";
  11444.         case GIORNALIERO:
  11445.             return "Giorni";
  11446.         case SETTIMANALE:
  11447.             return "Settimane";
  11448.         case MENSILE:
  11449.             return "Mesi";
  11450.         default:
  11451.             return "Valore";
  11452.         }
  11453.     }
  11454.    
  11455.     public boolean configurazionePolicyCheckData(StringBuilder sbParsingError, TipoOperazione tipoOperazione, org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale configurazioneControlloTraffico, ConfigurazionePolicy policyToCheck,
  11456.             String oldNomeSuggeritoPolicy,  String oldDescrizioneSuggeritaPolicy, String oldPolicyId,   List<AttivazionePolicy> listPolicyAttiveConStatoDisabilitato,
  11457.     boolean updateValueInSeguitoModificaSogliaPolicy) throws Exception{
  11458.        
  11459.         // errori di parsing letti durante la read della richiesta
  11460.         if(sbParsingError.length() >0){
  11461.             this.pd.setMessage(sbParsingError.toString());
  11462.             return false;
  11463.         }
  11464.        
  11465.         if(TipoOperazione.CHANGE.equals(tipoOperazione)){
  11466.            
  11467.             long count = 0;
  11468.             String id = null;
  11469.             if(oldPolicyId!=null){
  11470.                 id = oldPolicyId;
  11471.             }
  11472.             else{
  11473.                 id = policyToCheck.getIdPolicy();
  11474.             }
  11475.             count = this.confCore.countInUseAttivazioni(id);
  11476.             if(count>0){
  11477.                 String messaggio = "Non è possibile modificare la policy '"+id+"' essendo utilizzata in "+count+" istanze di "+ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING;
  11478.                 boolean modificaVolutaUtente = listPolicyAttiveConStatoDisabilitato != null && !listPolicyAttiveConStatoDisabilitato.isEmpty();
  11479.                 long countPolicyNonDisabilitate = this.confCore.countInUseAttivazioni(id, true);
  11480.                 if(countPolicyNonDisabilitate>0 && !modificaVolutaUtente ) {
  11481.                     this.pd.setMessage(messaggio);
  11482.                     return false;
  11483.                 }
  11484.             }
  11485.                
  11486.         }
  11487.        
  11488.         ConfigurazionePolicy p = null;
  11489.         try{
  11490.             p = this.confCore.getConfigurazionePolicy(policyToCheck.getIdPolicy());
  11491.         }catch(DriverControlStationNotFound e) {
  11492.             // ignore
  11493.         }catch(Exception e){
  11494.             throw e;
  11495.         }
  11496.        
  11497.         if(p!=null){
  11498.            
  11499.             if(TipoOperazione.ADD.equals(tipoOperazione) || (p.getId()!=null && policyToCheck.getId()!=null && p.getId().longValue()!=policyToCheck.getId().longValue())){
  11500.                 String messaggio = "Esiste già una policy con nome '"+policyToCheck.getIdPolicy()+"'";
  11501.                 this.pd.setMessage(messaggio);
  11502.                 return false;
  11503.             }
  11504.         }
  11505.        
  11506.         return this.checkConfigurazionePolicy(configurazioneControlloTraffico,policyToCheck);
  11507.     }
  11508.    
  11509.    
  11510.     public boolean checkConfigurazionePolicy(org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale c,ConfigurazionePolicy policy) throws Exception{
  11511.        
  11512.         // Dati Generali
  11513.         if(policy.getIdPolicy()==null || "".equals(policy.getIdPolicy())){
  11514.             String messaggio = "Deve essere indicato un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NOME+"'";
  11515.             this.pd.setMessage(messaggio);
  11516.                 return false;
  11517.         }
  11518.        
  11519.         // Nome
  11520.         if (!RegularExpressionEngine.isMatch(policy.getIdPolicy(),"^[\\-\\._A-Za-z0-9]*$")) {
  11521.             String messaggio = "Il nome indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NOME+
  11522.                     "' puo' contenere solamente caratteri [A-Za-z], numeri [0-9] e i simboli '-','.' e '_'";
  11523.             this.pd.setMessage(messaggio);
  11524.             return false;
  11525.         }
  11526.         if(this.checkLength255(policy.getIdPolicy(), ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_NOME)==false) {
  11527.             return false;
  11528.         }
  11529.        
  11530.         // Descrizione
  11531.         if(policy.getDescrizione()==null || "".equals(policy.getDescrizione())){
  11532.             String messaggio = "Deve essere indicato un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_DESCRIZIONE+"'";
  11533.             this.pd.setMessage(messaggio);
  11534.                 return false;
  11535.         }
  11536.        
  11537.         // Valori di Soglia
  11538.         TipoRisorsa tipoRisorsa = null;
  11539.         try{
  11540.             tipoRisorsa = TipoRisorsa.toEnumConstant(policy.getRisorsa(), true);
  11541.         }catch(Exception e){
  11542.             this.pd.setMessage(e.getMessage());
  11543.             return false;
  11544.         }
  11545.         String name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE;
  11546.         if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)){
  11547.             name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RISPOSTA_LABEL;
  11548.         }
  11549.         else if(TipoRisorsa.OCCUPAZIONE_BANDA.equals(tipoRisorsa)){
  11550.             name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_OCCUPAZIONE_DI_BANDA_LABEL;
  11551.         }
  11552.         else if(TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(tipoRisorsa)){
  11553.             name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_LABEL;
  11554.         }
  11555.         else if(TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(tipoRisorsa)){
  11556.             name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_LABEL;
  11557.         }
  11558.         if(policy.getValore()==null) { //|| "".equals(policy.getValore())){
  11559.             String messaggio = "Deve essere indicato un valore in '"+name+"'";
  11560.             this.pd.setMessage(messaggio);
  11561.                 return false;
  11562.         }
  11563.         long l = policy.getValore();
  11564.         try{
  11565.             if(l<0){
  11566.                 throw new DriverControlStationException("Valore non nell'intervallo");
  11567.             }
  11568.         }catch(Exception e){
  11569.             String messaggio = "Il valore ("+policy.getValore()+") indicato in '"+name+"' deve essere un numero intero maggiore o uguale a 0";
  11570.             this.pd.setMessage(messaggio);
  11571.             return false;
  11572.         }
  11573.         if(TipoRisorsa.NUMERO_RICHIESTE.equals(tipoRisorsa) && policy.isSimultanee()){
  11574.             if(c.getControlloTraffico().isControlloMaxThreadsEnabled()) {
  11575.                 if(l > c.getControlloTraffico().getControlloMaxThreadsSoglia()){
  11576.                     String messaggio = "Deve essere indicato un valore in '"+name+
  11577.                             "' minore di quanto indicato nella configurazione generale alla voce '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_SOGLIA+"'";
  11578.                     this.pd.setMessage(messaggio);
  11579.                     return false;
  11580.                 }
  11581.             }
  11582.         }
  11583.        
  11584.         if(policy.isSimultanee()==false && !TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)){
  11585.             if(policy.getIntervalloOsservazione()==null){
  11586.                 String labelPeriodo = null;
  11587.                 if(TipoControlloPeriodo.REALTIME.equals(policy.getModalitaControllo())){
  11588.                     labelPeriodo = this.getLabel(policy.getTipoIntervalloOsservazioneRealtime());
  11589.                 }else{
  11590.                     labelPeriodo = this.getLabel(policy.getTipoIntervalloOsservazioneStatistico());
  11591.                 }
  11592.                 String messaggio = "Deve essere indicato un valore in '"+labelPeriodo+"'";
  11593.                 this.pd.setMessage(messaggio);
  11594.                 return false;
  11595.             }
  11596.         }
  11597.        
  11598.         if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)) {
  11599.            
  11600.             String labelDimensione = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RICHIESTA_LABEL;
  11601.            
  11602.             if(policy.getValore2()==null) { //|| "".equals(policy.getValore())){
  11603.                 String messaggio = "Deve essere indicato un valore in '"+labelDimensione+"'";
  11604.                 this.pd.setMessage(messaggio);
  11605.                     return false;
  11606.             }
  11607.             try{
  11608.                 long i = policy.getValore2();
  11609.                 if(i<=0){
  11610.                     throw new DriverControlStationException("Valore non nell'intervallo");
  11611.                 }
  11612.             }catch(Exception e){
  11613.                 String messaggio = "Il valore ("+policy.getValore2()+") indicato in '"+labelDimensione+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  11614.                 this.pd.setMessage(messaggio);
  11615.                 return false;
  11616.             }
  11617.         }
  11618.        
  11619.        
  11620.         // Applicabilita
  11621.        
  11622.         if(TipoApplicabilita.CONDIZIONALE.equals(policy.getTipoApplicabilita())){
  11623.            
  11624.             if(!policy.isApplicabilitaConCongestione() &&
  11625.                     !policy.isApplicabilitaDegradoPrestazionale() &&
  11626.                     !policy.isApplicabilitaStatoAllarme()){
  11627.                 String messaggio = "Deve essere selezionato almeno un criterio di applicabilità della Policy";
  11628.                 this.pd.setMessage(messaggio);
  11629.                 return false;
  11630.             }
  11631.            
  11632.         }
  11633.        
  11634.         if(policy.isApplicabilitaDegradoPrestazionale()){
  11635.                        
  11636.             if(policy.getDegradoAvgTimeIntervalloOsservazione()==null){
  11637.                 String labelIntervallo = null;
  11638.                 if(TipoControlloPeriodo.REALTIME.equals(policy.getDegradoAvgTimeModalitaControllo())){
  11639.                     labelIntervallo = this.getLabel(policy.getDegradoAvgTimeTipoIntervalloOsservazioneRealtime());
  11640.                 }
  11641.                 else{
  11642.                     labelIntervallo = this.getLabel(policy.getDegradoAvgTimeTipoIntervalloOsservazioneStatistico());
  11643.                 }
  11644.                 String messaggio = "Deve essere indicato un valore in '"+ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DEGRADO_PRESTAZIONALE
  11645.                         +" - "+labelIntervallo+"'";
  11646.                 this.pd.setMessage(messaggio);
  11647.                 return false;
  11648.             }
  11649.            
  11650.         }
  11651.        
  11652.         if(policy.isApplicabilitaStatoAllarme()){
  11653.             List<String> allarmi = null;
  11654.             try{
  11655.                 List<Allarme> listAllarmiGlobali = this.confCore.allarmiSenzaPluginList(new ConsoleSearch(true), null, null);
  11656.                 if(listAllarmiGlobali!=null && !listAllarmiGlobali.isEmpty()) {
  11657.                     allarmi = new ArrayList<>();
  11658.                     for (Allarme allarme : listAllarmiGlobali) {
  11659.                         allarmi.add(allarme.getNome());
  11660.                     }
  11661.                 }
  11662.             }catch(Exception eError){
  11663.                 this.logError(eError.getMessage(),eError);
  11664.             }

  11665.             if(allarmi==null || allarmi.size()<=0){
  11666.                 String messaggio = "Non risultano attivi allarmi; disabilitare l'opzione '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_LABEL+"'";
  11667.                 this.pd.setMessage(messaggio);
  11668.                 return false;
  11669.             }          
  11670.             else{
  11671.                 if(policy.getAllarmeNome()==null || "".equals(policy.getAllarmeNome())  || "-".equals(policy.getAllarmeNome())) {
  11672.                     String messaggio = "Selezionare uno degli allarmi indicati in '"+ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ALLARME
  11673.                             +" - "+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_STATO_ALLARME_NOME+"'";
  11674.                     this.pd.setMessage(messaggio);
  11675.                     return false;
  11676.                 }
  11677.             }
  11678.         }
  11679.         return true;
  11680.     }
  11681.    
  11682.    
  11683.     public String readDatiAttivazionePolicyFromHttpParameters(AttivazionePolicy policy, boolean first, TipoOperazione tipoOperazione, InfoPolicy infoPolicy) throws Exception{
  11684.        
  11685.         StringBuilder sbParsingError = new StringBuilder();
  11686.         // id
  11687.         String id = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID);
  11688.         if(id!=null && !"".equals(id)){
  11689.             try{
  11690.                 long l = Long.parseLong(id);
  11691.                 if(l<=0){
  11692.                     throw new DriverControlStationException("Valore non nell'intervallo");
  11693.                 }
  11694.                 policy.setId(l);
  11695.             }catch(Exception e){
  11696.                 String messaggio = "Il valore ("+id+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID+"' deve essere un numero intero maggiore di 0 e minore di "+Long.MAX_VALUE;
  11697.                 this.logError(messaggio,e);
  11698.                 this.addParsingError(sbParsingError,messaggio);
  11699.             }
  11700.         }
  11701.        
  11702.         // alias
  11703.         String alias = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ALIAS);
  11704.         if(alias!=null && !"".equals(alias)){
  11705.             policy.setAlias(alias);
  11706.         }
  11707.         else {
  11708.             if(!first) {
  11709.                 policy.setAlias(null);
  11710.             }
  11711.         }
  11712.        
  11713.         // stato
  11714.         String stato = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ENABLED);
  11715.         if(stato!=null && !"".equals(stato)){
  11716.             policy.setEnabled(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO.equalsIgnoreCase(stato) || ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_WARNING_ONLY.equalsIgnoreCase(stato));
  11717.             policy.setWarningOnly(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_WARNING_ONLY.equalsIgnoreCase(stato));
  11718.         }
  11719.         else{
  11720.             if(TipoOperazione.ADD.equals(tipoOperazione)){
  11721.                 policy.setEnabled(true); // default
  11722.                 policy.setWarningOnly(false); // default
  11723.             }
  11724.         }
  11725.        
  11726.         // continue
  11727.         String continueS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_CONTINUE);
  11728.         if(continueS!=null && !"".equals(continueS)){
  11729.             policy.setContinuaValutazione(Boolean.valueOf(continueS));
  11730.         }
  11731.         else {
  11732.             if(TipoOperazione.ADD.equals(tipoOperazione)){
  11733.                 policy.setContinuaValutazione(false); // default
  11734.             }
  11735.         }
  11736.        
  11737.        
  11738.         // ridefinisci
  11739.         String ridefinisci = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_RIDEFINISCI);
  11740.         if(first==false){
  11741.             policy.setRidefinisci(ServletUtils.isCheckBoxEnabled(ridefinisci));
  11742.         }
  11743.        
  11744.        
  11745.         if(infoPolicy!=null){
  11746.            
  11747.             TipoRisorsa tipoRisorsa = infoPolicy.getTipoRisorsa();
  11748.            
  11749.             // valore
  11750.             String valore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VALORE);
  11751.             if(valore!=null && !"".equals(valore)){
  11752.                 if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)) {
  11753.                     try{
  11754.                         Integer i = Integer.parseInt(valore);
  11755.                         if(i<=0){
  11756.                             throw new DriverControlStationException("Valore non nell'intervallo");
  11757.                         }
  11758.                         policy.setValore((long)i);
  11759.                     }catch(Exception e){
  11760.                         String label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RISPOSTA_LABEL;
  11761.                         String messaggio = "Il valore ("+valore+") indicato in '"+label+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  11762.                         this.logError(messaggio,e);
  11763.                         this.addParsingError(sbParsingError,messaggio);
  11764.                     }
  11765.                 }
  11766.                 else {
  11767.                     try{
  11768.                         long l = Long.parseLong(valore);
  11769.                         if(l<=0){
  11770.                             throw new DriverControlStationException("Valore non nell'intervallo");
  11771.                         }
  11772.                         policy.setValore(l);
  11773.                     }catch(Exception e){
  11774.                         String label = null;
  11775.                         if(TipoRisorsa.NUMERO_RICHIESTE.equals(tipoRisorsa)){
  11776.                             label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE;
  11777.                         }
  11778.                         else if(TipoRisorsa.OCCUPAZIONE_BANDA.equals(tipoRisorsa)){
  11779.                             label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_OCCUPAZIONE_DI_BANDA_LABEL;
  11780.                         }
  11781.                         else if(TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(tipoRisorsa)){
  11782.                             label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_LABEL;
  11783.                         }
  11784.                         else{
  11785.                             label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_LABEL;
  11786.                         }
  11787.                         String messaggio = "Il valore ("+valore+") indicato in '"+label+"' deve essere un numero intero maggiore di 0 e minore di "+Long.MAX_VALUE;
  11788.                         this.logError(messaggio,e);
  11789.                         this.addParsingError(sbParsingError,messaggio);
  11790.                     }
  11791.                 }
  11792.             }
  11793.             else{
  11794.                 if(!first){
  11795.                     policy.setValore(null);
  11796.                 }
  11797.             }
  11798.            
  11799.             // valore2
  11800.             if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)) {
  11801.                 String valore2 = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VALORE_2);
  11802.                 if(valore2!=null && !"".equals(valore2)){
  11803.                     try{
  11804.                         Integer i = Integer.parseInt(valore2);
  11805.                         if(i<=0){
  11806.                             throw new DriverControlStationException("Valore non nell'intervallo");
  11807.                         }
  11808.                         policy.setValore2((long)i);
  11809.                     }catch(Exception e){
  11810.                         String label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RICHIESTA_LABEL;
  11811.                         String messaggio = "Il valore ("+valore+") indicato in '"+label+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  11812.                         this.logError(messaggio,e);
  11813.                         this.addParsingError(sbParsingError,messaggio);
  11814.                     }
  11815.                 }
  11816.                 else{
  11817.                     if(!first){
  11818.                         policy.setValore2(null);
  11819.                     }
  11820.                 }
  11821.             }
  11822.                    
  11823.         }
  11824.         else{
  11825.             policy.setValore(null);
  11826.             policy.setValore2(null);
  11827.         }
  11828.            
  11829.        
  11830.         // filtro
  11831.         String errorMsgDatiAttivazione = readDatiAttivazioneFiltroFromHttpParameters(policy, first, infoPolicy);
  11832.         if (errorMsgDatiAttivazione != null) {
  11833.             this.addParsingError(sbParsingError, errorMsgDatiAttivazione);
  11834.         }
  11835.        
  11836.         if(sbParsingError.length() > 0){
  11837.             return sbParsingError.toString();
  11838.         }
  11839.         return null;
  11840.     }

  11841.     public String readDatiAttivazioneFiltroFromHttpParameters(AttivazionePolicy policy,boolean first, InfoPolicy infoPolicy) throws Exception {
  11842.            
  11843.         StringBuilder sbParsingError = new StringBuilder();
  11844.        
  11845.         // Filtro - stato
  11846.         String stato = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_ENABLED);
  11847.         if(stato!=null && !"".equals(stato)){
  11848.             policy.getFiltro().setEnabled(ServletUtils.isCheckBoxEnabled(stato));
  11849.         }
  11850.        
  11851.         // Filtro
  11852.         if(policy.getFiltro().isEnabled()){
  11853.            
  11854.             // ruolo della PdD
  11855.             String ruoloPdD = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_PDD);
  11856.             if(ruoloPdD!=null && !"".equals(ruoloPdD)){
  11857.                 try{
  11858.                     policy.getFiltro().setRuoloPorta(RuoloPolicy.toEnumConstant(ruoloPdD, true));
  11859.                 }catch(Exception e){
  11860.                     String messaggio = "Il valore ("+ruoloPdD+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_PDD+"' non è tra i ruoli gestiti";
  11861.                     this.logError(messaggio,e);
  11862.                     this.addParsingError(sbParsingError,messaggio);
  11863.                 }
  11864.             }
  11865.            
  11866.             // protocollo
  11867.             String protocollo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO);
  11868.             if(protocollo!=null && !"".equals(protocollo) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(protocollo)){
  11869.                 policy.getFiltro().setProtocollo(protocollo);
  11870.             }
  11871.             else{
  11872.                 if(!first){
  11873.                     policy.getFiltro().setProtocollo(null);
  11874.                 }
  11875.             }
  11876.            
  11877.             // ruolo erogatore
  11878.             String ruoloErogatore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_EROGATORE);
  11879.             if(ruoloErogatore!=null && !"".equals(ruoloErogatore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(ruoloErogatore) ){
  11880.                 policy.getFiltro().setRuoloErogatore(ruoloErogatore);
  11881.             }
  11882.             else{
  11883.                 if(!first){
  11884.                     policy.getFiltro().setRuoloErogatore(null);
  11885.                 }
  11886.             }
  11887.            
  11888.             // erogatore
  11889.             String erogatore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_EROGATORE);
  11890.             boolean erogatoreSelected = false;
  11891.             if(erogatore!=null && !"".equals(erogatore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(erogatore) && erogatore.contains("/") ){
  11892.                 String [] tmp = erogatore.split("/");
  11893.                 policy.getFiltro().setTipoErogatore(tmp[0]);
  11894.                 policy.getFiltro().setNomeErogatore(tmp[1]);
  11895.                 erogatoreSelected = true;
  11896.             }
  11897.             else{
  11898.                 if(!first){
  11899.                     policy.getFiltro().setTipoErogatore(null);
  11900.                     policy.getFiltro().setNomeErogatore(null);
  11901.                 }
  11902.             }
  11903.            
  11904.             // servizio applicativo erogatore
  11905.             String servizioApplicativoErogatore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_EROGATORE);
  11906.             if(servizioApplicativoErogatore!=null && !"".equals(servizioApplicativoErogatore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(servizioApplicativoErogatore) ){
  11907.                 policy.getFiltro().setServizioApplicativoErogatore(servizioApplicativoErogatore);
  11908.             }
  11909.             else{
  11910.                 if(!first){
  11911.                     policy.getFiltro().setServizioApplicativoErogatore(null);
  11912.                 }
  11913.             }
  11914.            
  11915.             // tag
  11916.             String tag = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TAG);
  11917.             if(tag!=null && !"".equals(tag) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(tag)){
  11918.                 policy.getFiltro().setTag(tag);
  11919.             }
  11920.             else{
  11921.                 if(!first){
  11922.                     policy.getFiltro().setTag(null);
  11923.                 }
  11924.             }
  11925.            
  11926.             // servizio
  11927.             String servizio = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SERVIZIO);
  11928.             if(servizio!=null && !"".equals(servizio) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(servizio) && servizio.contains("/") ){
  11929.                 String [] tmp = servizio.split("/");
  11930.                 policy.getFiltro().setTipoServizio(tmp[0]);
  11931.                 policy.getFiltro().setNomeServizio(tmp[1]);
  11932.                 policy.getFiltro().setVersioneServizio(Integer.parseInt(tmp[2]));
  11933.                 if(this.core.isControlloTrafficoPolicyGlobaleFiltroApiSoggettoErogatore()) {
  11934.                     policy.getFiltro().setTipoErogatore(tmp[3]);
  11935.                     policy.getFiltro().setNomeErogatore(tmp[4]);
  11936.                 }
  11937.             }
  11938.             else{
  11939.                 if(!first){
  11940.                     policy.getFiltro().setTipoServizio(null);
  11941.                     policy.getFiltro().setNomeServizio(null);
  11942.                     policy.getFiltro().setVersioneServizio(null);
  11943.                     if(this.core.isControlloTrafficoPolicyGlobaleFiltroApiSoggettoErogatore()&& !erogatoreSelected) {
  11944.                         policy.getFiltro().setTipoErogatore(null);
  11945.                         policy.getFiltro().setNomeErogatore(null);
  11946.                     }
  11947.                 }
  11948.             }
  11949.            
  11950.             // azione
  11951.             String [] azione = this.getParameterValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE);
  11952.             if(azione!=null && azione.length>0) {
  11953.                 StringBuilder bf = new StringBuilder();
  11954.                 for (String az : azione) {
  11955.                     if(bf.length()>0) {
  11956.                         bf.append(",");
  11957.                     }
  11958.                     bf.append(az);
  11959.                 }
  11960.                 policy.getFiltro().setAzione(bf.toString());
  11961.             }
  11962.             else{
  11963.                 if(!first){
  11964.                     policy.getFiltro().setAzione(null);
  11965.                 }
  11966.             }
  11967.            
  11968.             // ruolo fruitore
  11969.             String ruoloFruitore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_FRUITORE);
  11970.             if(ruoloFruitore!=null && !"".equals(ruoloFruitore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(ruoloFruitore) ){
  11971.                 policy.getFiltro().setRuoloFruitore(ruoloFruitore);
  11972.             }
  11973.             else{
  11974.                 if(!first){
  11975.                     policy.getFiltro().setRuoloFruitore(null);
  11976.                 }
  11977.             }
  11978.            
  11979.             // fruitore
  11980.             String fruitore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_FRUITORE);
  11981.             if(fruitore!=null && !"".equals(fruitore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(fruitore) && fruitore.contains("/") ){
  11982.                 String [] tmp = fruitore.split("/");
  11983.                 policy.getFiltro().setTipoFruitore(tmp[0]);
  11984.                 policy.getFiltro().setNomeFruitore(tmp[1]);
  11985.             }
  11986.             else{
  11987.                 if(!first){
  11988.                     policy.getFiltro().setTipoFruitore(null);
  11989.                     policy.getFiltro().setNomeFruitore(null);
  11990.                 }
  11991.             }
  11992.            
  11993.             // servizio applicativo fruitore
  11994.             String servizioApplicativoFruitore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE);
  11995.             if(servizioApplicativoFruitore!=null && !"".equals(servizioApplicativoFruitore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(servizioApplicativoFruitore) ){
  11996.                 policy.getFiltro().setServizioApplicativoFruitore(servizioApplicativoFruitore);
  11997.             }
  11998.             else{
  11999.                 if(!first){
  12000.                     policy.getFiltro().setServizioApplicativoFruitore(null);
  12001.                 }
  12002.             }
  12003.            
  12004.             // claims
  12005.             String tokenClaims = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TOKEN_CLAIMS);
  12006.             if(tokenClaims!=null && !"".equals(tokenClaims) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(tokenClaims) ){
  12007.                 policy.getFiltro().setTokenClaims(tokenClaims);
  12008.             }
  12009.             else{
  12010.                 if(!first){
  12011.                     policy.getFiltro().setTokenClaims(null);
  12012.                 }
  12013.             }
  12014.            
  12015.             // per Chiave
  12016.             String perChiave = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED);
  12017.             if(first==false){
  12018.                 policy.getFiltro().setInformazioneApplicativaEnabled(ServletUtils.isCheckBoxEnabled(perChiave));
  12019.             }
  12020.            
  12021.             if(policy.getFiltro().isInformazioneApplicativaEnabled()){
  12022.                
  12023.                 // Per Chiave - Tipo
  12024.                 String perChiaveTipo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO);
  12025.                 if(perChiaveTipo!=null && !"".equals(perChiaveTipo) ){
  12026.                     policy.getFiltro().setInformazioneApplicativaTipo(perChiaveTipo);
  12027.                 }
  12028.                 else{
  12029.                     if(!first){
  12030.                         policy.getFiltro().setInformazioneApplicativaTipo(ConfigurazioneCostanti.CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO_DEFAULT); // default
  12031.                     }
  12032.                 }
  12033.                
  12034.                 // Per Chiave - Nome
  12035.                 String perChiaveNome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_NOME);
  12036.                 if(perChiaveNome!=null && !"".equals(perChiaveNome) ){
  12037.                     policy.getFiltro().setInformazioneApplicativaNome(perChiaveNome);
  12038.                 }
  12039.                 else{
  12040.                     if(!first){
  12041.                         policy.getFiltro().setInformazioneApplicativaNome(null);
  12042.                     }
  12043.                 }
  12044.                
  12045.                 // Per Chiave - Valore
  12046.                 String perChiaveValore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_VALORE);
  12047.                 if(perChiaveValore!=null && !"".equals(perChiaveValore) ){
  12048.                     policy.getFiltro().setInformazioneApplicativaValore(StringEscapeUtils.unescapeHtml(perChiaveValore)); // il valore viene "escaped" perchè può conteenere ""
  12049.                 }
  12050.                 else{
  12051.                     if(!first){
  12052.                         policy.getFiltro().setInformazioneApplicativaValore(null);
  12053.                     }
  12054.                 }
  12055.                
  12056.             }
  12057.             else{
  12058.                 policy.getFiltro().setInformazioneApplicativaTipo(null);
  12059.                 policy.getFiltro().setInformazioneApplicativaNome(null);
  12060.                 policy.getFiltro().setInformazioneApplicativaValore(null);
  12061.             }
  12062.         }
  12063.         else{
  12064.             policy.getFiltro().setRuoloPorta(RuoloPolicy.ENTRAMBI);
  12065.             policy.getFiltro().setTipoFruitore(null);
  12066.             policy.getFiltro().setNomeFruitore(null);
  12067.             policy.getFiltro().setServizioApplicativoFruitore(null);
  12068.             policy.getFiltro().setTipoErogatore(null);
  12069.             policy.getFiltro().setNomeErogatore(null);
  12070.             policy.getFiltro().setServizioApplicativoErogatore(null);
  12071.             policy.getFiltro().setTipoServizio(null);
  12072.             policy.getFiltro().setNomeServizio(null);
  12073.             policy.getFiltro().setAzione(null);
  12074.             policy.getFiltro().setTokenClaims(null);
  12075.             policy.getFiltro().setInformazioneApplicativaEnabled(false);
  12076.             policy.getFiltro().setInformazioneApplicativaTipo(null);
  12077.             policy.getFiltro().setInformazioneApplicativaNome(null);
  12078.             policy.getFiltro().setInformazioneApplicativaValore(null);
  12079.         }
  12080.        
  12081.         // GroupBy - stato
  12082.         String statoGroupBy = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_ENABLED);
  12083.         if(statoGroupBy!=null && !"".equals(statoGroupBy)){
  12084.             policy.getGroupBy().setEnabled(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_COLLEZIONAMENTO_ABILITATO.equals(statoGroupBy) ||
  12085.                     ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(statoGroupBy));
  12086.         }
  12087.        
  12088.         // GroupBy
  12089.         if(policy.getGroupBy().isEnabled()){
  12090.            
  12091.             // ruolo della PdD
  12092.             String ruoloPdD = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_RUOLO_PDD);
  12093.             if(first==false){
  12094.                 policy.getGroupBy().setRuoloPorta(ServletUtils.isCheckBoxEnabled(ruoloPdD));
  12095.             }
  12096.            
  12097.             // protocollo
  12098.             String protocollo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PROTOCOLLO);
  12099.             if(first==false){
  12100.                 policy.getGroupBy().setProtocollo(ServletUtils.isCheckBoxEnabled(protocollo));
  12101.             }
  12102.            
  12103.             // erogatore
  12104.             String erogatore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_EROGATORE);
  12105.             if(first==false){
  12106.                 policy.getGroupBy().setErogatore(ServletUtils.isCheckBoxEnabled(erogatore));
  12107.             }
  12108.            
  12109.             // servizio applicativo erogatore
  12110.             String servizioApplicativoErogatore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SA_EROGATORE);
  12111.             if(first==false){
  12112.                 policy.getGroupBy().setServizioApplicativoErogatore(ServletUtils.isCheckBoxEnabled(servizioApplicativoErogatore));
  12113.             }
  12114.            
  12115.             // servizio
  12116.             String servizio = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SERVIZIO);
  12117.             if(first==false){
  12118.                 policy.getGroupBy().setServizio(ServletUtils.isCheckBoxEnabled(servizio));
  12119.                 policy.getGroupBy().setErogatore(ServletUtils.isCheckBoxEnabled(servizio)); // imposto anche l'erogatore poiche' identifica API differenti
  12120.             }
  12121.            
  12122.             // azione
  12123.             String azione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_AZIONE);
  12124.             if(first==false){
  12125.                 policy.getGroupBy().setAzione(ServletUtils.isCheckBoxEnabled(azione));
  12126.             }
  12127.            
  12128.             // fruitore
  12129.             String fruitore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_FRUITORE);
  12130.             if(first==false){
  12131.                 policy.getGroupBy().setFruitore(ServletUtils.isCheckBoxEnabled(fruitore));
  12132.             }
  12133.            
  12134.             // servizio applicativo fruitore
  12135.             String servizioApplicativoFruitore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SA_FRUITORE);
  12136.             if(first==false){
  12137.                 policy.getGroupBy().setServizioApplicativoFruitore(ServletUtils.isCheckBoxEnabled(servizioApplicativoFruitore));
  12138.             }
  12139.            
  12140.             // richiedente
  12141.             String richiedente = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_RICHIEDENTE);
  12142.             if(first==false){
  12143.                 policy.getGroupBy().setServizioApplicativoFruitore(ServletUtils.isCheckBoxEnabled(richiedente));
  12144.                 policy.getGroupBy().setFruitore(ServletUtils.isCheckBoxEnabled(richiedente));
  12145.                 policy.getGroupBy().setIdentificativoAutenticato(ServletUtils.isCheckBoxEnabled(richiedente));
  12146.             }
  12147.            
  12148.             // token
  12149.             String token = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_TOKEN);
  12150.             if(first==false){
  12151.                 if(ServletUtils.isCheckBoxEnabled(token)) {
  12152.                     String [] tokenSelezionati = this.getParameterValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_TOKEN_CLAIMS);
  12153.                     if(tokenSelezionati!=null && tokenSelezionati.length>0) {
  12154.                         StringBuilder bf = new StringBuilder();
  12155.                         for (int i = 0; i < tokenSelezionati.length; i++) {
  12156.                             TipoCredenzialeMittente tipo = TipoCredenzialeMittente.toEnumConstant(tokenSelezionati[i], true);
  12157.                             if(TipoCredenzialeMittente.TOKEN_ISSUER.equals(tipo)) {
  12158.                                 continue;
  12159.                             }
  12160.                             else if(TipoCredenzialeMittente.TOKEN_SUBJECT.equals(tipo)) {
  12161.                                 if(!bf.toString().endsWith(",") && bf.length()>0) {
  12162.                                     bf.append(",");
  12163.                                 }
  12164.                                 bf.append(TipoCredenzialeMittente.TOKEN_ISSUER.getRawValue());
  12165.                                 if(i==0) {
  12166.                                     bf.append(",");
  12167.                                 }
  12168.                             }
  12169.                             if(i>0) {
  12170.                                 bf.append(",");
  12171.                             }
  12172.                             bf.append(tokenSelezionati[i]);
  12173.                         }
  12174.                         if(bf.length()>0) {
  12175.                             policy.getGroupBy().setToken(bf.toString());
  12176.                         }
  12177.                         else {
  12178.                             policy.getGroupBy().setToken(null);
  12179.                         }
  12180.                     }
  12181.                     else {
  12182.                         policy.getGroupBy().setToken(null);
  12183.                     }
  12184.                 }
  12185.                 else {
  12186.                     policy.getGroupBy().setToken(null);
  12187.                 }
  12188.             }

  12189.             // per Chiave
  12190.             String perChiave = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_ENABLED);
  12191.             if(first==false){
  12192.                 policy.getGroupBy().setInformazioneApplicativaEnabled(ServletUtils.isCheckBoxEnabled(perChiave));
  12193.             }
  12194.            
  12195.             if(policy.getGroupBy().isInformazioneApplicativaEnabled()){
  12196.                
  12197.                 // Per Chiave - Tipo
  12198.                 String perChiaveTipo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_TIPO);
  12199.                 if(perChiaveTipo!=null && !"".equals(perChiaveTipo) ){
  12200.                     policy.getGroupBy().setInformazioneApplicativaTipo(perChiaveTipo);
  12201.                 }
  12202.                 else{
  12203.                     if(!first){
  12204.                         policy.getGroupBy().setInformazioneApplicativaTipo(ConfigurazioneCostanti.CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_TIPO_DEFAULT); // default
  12205.                     }
  12206.                 }
  12207.                
  12208.                 // Per Chiave - Nome
  12209.                 String perChiaveNome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_NOME);
  12210.                 if(perChiaveNome!=null && !"".equals(perChiaveNome) ){
  12211.                     policy.getGroupBy().setInformazioneApplicativaNome(perChiaveNome);
  12212.                 }
  12213.                 else{
  12214.                     if(!first){
  12215.                         policy.getGroupBy().setInformazioneApplicativaNome(null);
  12216.                     }
  12217.                 }
  12218.                
  12219.                
  12220.             }
  12221.             else{
  12222.                 policy.getGroupBy().setInformazioneApplicativaTipo(null);
  12223.                 policy.getGroupBy().setInformazioneApplicativaNome(null);
  12224.             }
  12225.         }
  12226.         else{
  12227.             policy.getGroupBy().setRuoloPorta(false);
  12228.             policy.getGroupBy().setFruitore(false);
  12229.             policy.getGroupBy().setServizioApplicativoFruitore(false);
  12230.             policy.getGroupBy().setIdentificativoAutenticato(false);
  12231.             policy.getGroupBy().setToken(null);
  12232.             policy.getGroupBy().setErogatore(false);
  12233.             policy.getGroupBy().setServizioApplicativoErogatore(false);
  12234.             policy.getGroupBy().setServizio(false);
  12235.             policy.getGroupBy().setAzione(false);
  12236.             policy.getGroupBy().setInformazioneApplicativaEnabled(false);
  12237.             policy.getGroupBy().setInformazioneApplicativaTipo(null);
  12238.             policy.getGroupBy().setInformazioneApplicativaNome(null);
  12239.         }
  12240.        
  12241.        
  12242.         if(sbParsingError.length() > 0){
  12243.             return sbParsingError.toString();
  12244.         }
  12245.         return null;
  12246.     }

  12247.     private void addDataElementRisorsa(
  12248.             List<DataElement> dati,
  12249.             String parametroRisorsaNome, String valoreRisorsa,
  12250.             String parametroEsitiNome, String valoreEsiti,
  12251.             boolean editMode) {
  12252.         addDataElementRisorsa(
  12253.                 dati,
  12254.                 parametroRisorsaNome, valoreRisorsa,
  12255.                 parametroEsitiNome, valoreEsiti,
  12256.                 editMode,
  12257.                 null);
  12258.     }
  12259.     private void addDataElementRisorsa(
  12260.             List<DataElement> dati,
  12261.             String parametroRisorsaNome, String valoreRisorsa,
  12262.             String parametroEsitiNome, String valoreEsiti,
  12263.             boolean editMode,
  12264.             PolicyGroupByActiveThreadsType type) {
  12265.        
  12266.         if(CostantiControlStation.USE_SELECT_LIST_SEPARATE_METRICHE) {
  12267.            
  12268.             DataElement de = new DataElement();
  12269.             de.setName(parametroRisorsaNome);
  12270.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA);
  12271.             if(editMode) {
  12272.                 de.setValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA);
  12273.                 de.setSelected(valoreRisorsa);
  12274.                 de.setType(DataElementType.SELECT);
  12275.                 de.setPostBack_viaPOST(true);
  12276.             }
  12277.             else {
  12278.                 de.setType(DataElementType.TEXT);
  12279.             }
  12280.             de.setValue(valoreRisorsa);
  12281.             dati.add(de);
  12282.            
  12283.             if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_NUMERO_RICHIESTE.equals(valoreRisorsa)) {
  12284.                
  12285.                 de = new DataElement();
  12286.                 de.setName(parametroEsitiNome);
  12287.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ESITI);
  12288.                 if(editMode) {
  12289.                     de.setValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_ESITI);
  12290.                     de.setSelected(valoreEsiti);
  12291.                     de.setType(DataElementType.SELECT);
  12292.                     de.setPostBack_viaPOST(true);
  12293.                 }
  12294.                 else {
  12295.                     if(valoreEsiti==null || "".equals(valoreEsiti)) {
  12296.                         valoreEsiti = CostantiControlStation.LABEL_QUALSIASI;
  12297.                     }
  12298.                     de.setType(DataElementType.TEXT);
  12299.                 }
  12300.                 de.setValue(valoreEsiti);
  12301.                 dati.add(de);
  12302.                
  12303.             }
  12304.         }
  12305.         else {
  12306.             DataElement de = new DataElement();
  12307.             de.setName(parametroRisorsaNome);
  12308.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA_TIPO);
  12309.             if(editMode) {
  12310.                 if(type!=null) {
  12311.                     List<String> valoriFiltrati = new ArrayList<>();
  12312.                     List<String> labelFiltrate = new ArrayList<>();
  12313.                     for (int i = 0; i < CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_RISORSE_VALORI.length; i++) {
  12314.                         String v = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_RISORSE_VALORI[i];
  12315.                         TipoRisorsaPolicyAttiva tipoRisorsa = TipoRisorsaPolicyAttiva.toEnumConstant(v);
  12316.                         if(type.isSupportedResource(tipoRisorsa)) {
  12317.                             valoriFiltrati.add(v);
  12318.                             labelFiltrate.add(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_RISORSE_LABELS[i]);
  12319.                         }
  12320.                     }
  12321.                     de.setValues(valoriFiltrati);
  12322.                     de.setLabels(labelFiltrate);
  12323.                 }
  12324.                 else {
  12325.                     de.setValues(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_RISORSE_VALORI);
  12326.                     de.setLabels(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_RISORSE_LABELS);
  12327.                 }
  12328.                 de.setSelected(valoreRisorsa);
  12329.                 de.setType(DataElementType.SELECT);
  12330.                 de.setPostBack_viaPOST(true);
  12331.                 de.setValue(valoreRisorsa);
  12332.             }
  12333.             else {
  12334.                 de.setType(DataElementType.HIDDEN);
  12335.                 de.setValue(valoreRisorsa);
  12336.                 dati.add(de);
  12337.                
  12338.                 de = new DataElement();
  12339.                 de.setName(parametroRisorsaNome+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  12340.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA_TIPO);
  12341.                 de.setType(DataElementType.TEXT);
  12342.                 String labelRisorsaPolicyAttiva = this.getLabelTipoRisorsaPolicyAttiva(valoreRisorsa);
  12343.                 de.setValue(labelRisorsaPolicyAttiva);
  12344.             }
  12345.             dati.add(de);
  12346.         }
  12347.        
  12348.     }
  12349.    
  12350.     private TipoRisorsa getTipoRisorsa(String valoreRisorsa, String valoreEsiti) throws DriverControlStationException, NotFoundException {
  12351.        
  12352.         if(CostantiControlStation.USE_SELECT_LIST_SEPARATE_METRICHE) {
  12353.        
  12354.             TipoRisorsa tipoRisorsaSelezionata = null;
  12355.             if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_NUMERO_RICHIESTE.equals(valoreRisorsa)) {
  12356.                 if(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_OK.equals(valoreEsiti)) {
  12357.                     tipoRisorsaSelezionata = TipoRisorsa.NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO;
  12358.                 }
  12359.                 else if(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_FALLITE.equals(valoreEsiti)) {
  12360.                     tipoRisorsaSelezionata = TipoRisorsa.NUMERO_RICHIESTE_FALLITE;
  12361.                 }
  12362.                 else if(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_FAULT.equals(valoreEsiti)) {
  12363.                     tipoRisorsaSelezionata = TipoRisorsa.NUMERO_FAULT_APPLICATIVI;
  12364.                 }
  12365.                 else if(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_FALLITE_FAULT.equals(valoreEsiti)) {
  12366.                     tipoRisorsaSelezionata = TipoRisorsa.NUMERO_RICHIESTE_FALLITE_OFAULT_APPLICATIVI;
  12367.                 }
  12368.                 else if(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_OK_FAULT.equals(valoreEsiti)) {
  12369.                     tipoRisorsaSelezionata = TipoRisorsa.NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_OFAULT_APPLICATIVI;
  12370.                 }
  12371.                 else {
  12372.                     tipoRisorsaSelezionata = TipoRisorsa.NUMERO_RICHIESTE;
  12373.                 }
  12374.             }
  12375.             else if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_NUMERO_RICHIESTE_SIMULTANEE.equals(valoreRisorsa)) {
  12376.                 tipoRisorsaSelezionata = TipoRisorsa.NUMERO_RICHIESTE;
  12377.             }
  12378.             else if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_OCCUPAZIONE_BANDA.equals(valoreRisorsa)) {
  12379.                 tipoRisorsaSelezionata = TipoRisorsa.OCCUPAZIONE_BANDA;
  12380.             }
  12381.             else if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_TEMPO_MEDIO_RISPOSTA.equals(valoreRisorsa)) {
  12382.                 tipoRisorsaSelezionata = TipoRisorsa.TEMPO_MEDIO_RISPOSTA;
  12383.             }
  12384.             else if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_TEMPO_COMPLESSIVO_RISPOSTA.equals(valoreRisorsa)) {
  12385.                 tipoRisorsaSelezionata = TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA;
  12386.             }
  12387.             else {
  12388.                 throw new DriverControlStationException("Risorsa '"+valoreRisorsa+"' sconosciuta");
  12389.             }
  12390.             return tipoRisorsaSelezionata;
  12391.            
  12392.         }
  12393.         else {
  12394.            
  12395.             TipoRisorsaPolicyAttiva tipoRisorsaPolicyAttiva = TipoRisorsaPolicyAttiva.toEnumConstant(valoreRisorsa, false);
  12396.             if(tipoRisorsaPolicyAttiva==null) {
  12397.                 throw new DriverControlStationException("Risorsa '"+valoreRisorsa+"' sconosciuta");
  12398.             }
  12399.             return tipoRisorsaPolicyAttiva.getTipoRisorsa(true);
  12400.            
  12401.         }
  12402.        
  12403.     }
  12404.     public boolean isTipoRisorsaNumeroRichiesteSimultanee(String valoreRisorsa) throws Exception {
  12405.         if(CostantiControlStation.USE_SELECT_LIST_SEPARATE_METRICHE) {
  12406.             return ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_NUMERO_RICHIESTE_SIMULTANEE.equals(valoreRisorsa);
  12407.         }
  12408.         else {
  12409.             TipoRisorsaPolicyAttiva tipoRisorsaPolicyAttiva = TipoRisorsaPolicyAttiva.toEnumConstant(valoreRisorsa, false);
  12410.             if(tipoRisorsaPolicyAttiva==null) {
  12411.                 return false;
  12412.             }
  12413.             return tipoRisorsaPolicyAttiva.isRichiesteSimultanee();
  12414.         }
  12415.     }
  12416.    
  12417.     public String getDataElementValueRisorsa(String tipoRisorsa, boolean simultanee) throws Exception {
  12418.         TipoRisorsa tipo = TipoRisorsa.toEnumConstant(tipoRisorsa);
  12419.         if(tipo==null) {
  12420.             return null;
  12421.         }
  12422.         return this.getDataElementValueRisorsa(tipo, simultanee);
  12423.     }
  12424.     public String getDataElementValueRisorsa(TipoRisorsa tipoRisorsa, boolean simultanee) throws Exception {
  12425.         if(CostantiControlStation.USE_SELECT_LIST_SEPARATE_METRICHE) {
  12426.             switch (tipoRisorsa) {
  12427.             case NUMERO_RICHIESTE:
  12428.                 if(simultanee) {
  12429.                     return ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_NUMERO_RICHIESTE_SIMULTANEE;
  12430.                 }
  12431.                 else {
  12432.                     return ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_NUMERO_RICHIESTE;
  12433.                 }
  12434.             case NUMERO_RICHIESTE_FALLITE:
  12435.             case NUMERO_FAULT_APPLICATIVI:
  12436.             case NUMERO_RICHIESTE_FALLITE_OFAULT_APPLICATIVI:
  12437.             case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO:
  12438.             case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_OFAULT_APPLICATIVI:
  12439.                 return ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_NUMERO_RICHIESTE;
  12440.             case OCCUPAZIONE_BANDA:
  12441.                 return ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_OCCUPAZIONE_BANDA;
  12442.             case TEMPO_MEDIO_RISPOSTA:
  12443.                 return ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_TEMPO_MEDIO_RISPOSTA;
  12444.             case TEMPO_COMPLESSIVO_RISPOSTA:
  12445.                 return ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_TEMPO_COMPLESSIVO_RISPOSTA;
  12446.             case DIMENSIONE_MASSIMA_MESSAGGIO:
  12447.                 return ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_DIMENSIONE_MASSIMA;
  12448.             }
  12449.            
  12450.             throw new DriverControlStationException("Tipo risorsa '"+tipoRisorsa+"' non gestita");
  12451.         }
  12452.         else {
  12453.             TipoRisorsaPolicyAttiva tipoRisorsaPolicyAttiva = TipoRisorsaPolicyAttiva.getTipo(tipoRisorsa, simultanee);
  12454.             return tipoRisorsaPolicyAttiva.getValue();
  12455.         }
  12456.     }
  12457.    
  12458.     public String getDataElementValueRisorsaEsiti(String tipoRisorsa) throws Exception {
  12459.         TipoRisorsa tipo = TipoRisorsa.toEnumConstant(tipoRisorsa);
  12460.         if(tipo==null) {
  12461.             return null;
  12462.         }
  12463.         return this.getDataElementValueRisorsaEsiti(tipo);
  12464.     }
  12465.     public String getDataElementValueRisorsaEsiti(TipoRisorsa tipoRisorsa) throws DriverControlStationException {
  12466.         if(CostantiControlStation.USE_SELECT_LIST_SEPARATE_METRICHE) {
  12467.             switch (tipoRisorsa) {
  12468.             case NUMERO_RICHIESTE_FALLITE:
  12469.                 return ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_FALLITE;
  12470.             case NUMERO_FAULT_APPLICATIVI:
  12471.                 return ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_FAULT;
  12472.             case NUMERO_RICHIESTE_FALLITE_OFAULT_APPLICATIVI:
  12473.                 return ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_FALLITE_FAULT;
  12474.             case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO:
  12475.                 return ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_OK;
  12476.             case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_OFAULT_APPLICATIVI:
  12477.                 return ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_OK_FAULT;
  12478.             case NUMERO_RICHIESTE:
  12479.             case OCCUPAZIONE_BANDA:
  12480.             case TEMPO_MEDIO_RISPOSTA:
  12481.             case TEMPO_COMPLESSIVO_RISPOSTA:
  12482.             case DIMENSIONE_MASSIMA_MESSAGGIO:
  12483.                 return null;
  12484.             }
  12485.            
  12486.             throw new DriverControlStationException("Tipo risorsa '"+tipoRisorsa+"' non gestita");
  12487.         }
  12488.         else {
  12489.             return null;
  12490.         }
  12491.     }
  12492.    
  12493.     public void findPolicyBuiltIn(List<InfoPolicy> policies,
  12494.             List<InfoPolicy> idPoliciesSoddisfanoCriteri,
  12495.             String modalitaRisorsa, String modalitaEsiti,
  12496.             boolean modalitaSimultaneeEnabled, String modalitaIntervallo,
  12497.             boolean modalitaCongestioneEnabled,
  12498.             boolean modalitaDegradoEnabled,
  12499.             boolean modalitaErrorRateEnabled) throws Exception {
  12500.         if(policies!=null && policies.size()>0 && modalitaRisorsa!=null){
  12501.        
  12502.             TipoRisorsa tipoRisorsaSelezionata = getTipoRisorsa(modalitaRisorsa, modalitaEsiti);
  12503.            
  12504.             for (InfoPolicy info : policies) {
  12505.                
  12506.                 if(!tipoRisorsaSelezionata.equals(info.getTipoRisorsa())) {
  12507.                     continue;
  12508.                 }
  12509.                
  12510.                 if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsaSelezionata)) {
  12511.                     idPoliciesSoddisfanoCriteri.add(info);
  12512.                     continue;
  12513.                 }
  12514.                
  12515.                 if(modalitaSimultaneeEnabled) {
  12516.                     if(!info.isCheckRichiesteSimultanee()) {
  12517.                         continue;
  12518.                     }
  12519.                 }
  12520.                
  12521.                 if(!modalitaSimultaneeEnabled) {
  12522.                     if(!info.isIntervalloUtilizzaRisorseRealtime()) {
  12523.                         continue;
  12524.                     }
  12525.                     if(modalitaIntervallo==null) {
  12526.                         throw new DriverControlStationException("Intervallo Temporale non definito");
  12527.                     }
  12528.                     TipoPeriodoRealtime tipo = TipoPeriodoRealtime.toEnumConstant(modalitaIntervallo, true);
  12529.                     if(!tipo.equals(info.getIntervalloUtilizzaRisorseRealtimeTipoPeriodo())) {
  12530.                         continue;
  12531.                     }
  12532.                 }
  12533.                
  12534.                 if(modalitaCongestioneEnabled) {
  12535.                     if(!info.isControlloCongestione()) {
  12536.                         continue;
  12537.                     }
  12538.                 }
  12539.                 else {
  12540.                     if(info.isControlloCongestione()) {
  12541.                         continue;
  12542.                     }
  12543.                 }
  12544.                
  12545.                 if(modalitaDegradoEnabled) {
  12546.                     if(!info.isDegradoPrestazionaleUtilizzaRisorseStatistiche()) {
  12547.                         continue;
  12548.                     }
  12549.                 }
  12550.                 else {
  12551.                     if(info.isDegradoPrestazionaleUtilizzaRisorseStatistiche()) {
  12552.                         continue;
  12553.                     }
  12554.                 }
  12555.                
  12556.                 if(modalitaErrorRateEnabled) {
  12557.                     if(!info.isErrorRate()) {
  12558.                         continue;
  12559.                     }
  12560.                 }
  12561.                 else {
  12562.                     if(info.isErrorRate()) {
  12563.                         continue;
  12564.                     }
  12565.                 }
  12566.                
  12567.                 idPoliciesSoddisfanoCriteri.add(info);
  12568.             }
  12569.         }
  12570.     }
  12571.    
  12572.     public void addAttivazionePolicyToDati(List<DataElement> dati, TipoOperazione tipoOperazione, AttivazionePolicy policy, String nomeSezione, List<InfoPolicy> policies,
  12573.             RuoloPolicy ruoloPorta, String nomePorta, ServiceBinding serviceBinding, String modalita, PolicyGroupByActiveThreadsType type) throws Exception {
  12574.                
  12575.        
  12576.        
  12577.         Parameter parRuoloPorta = null;
  12578.         if(ruoloPorta!=null) {
  12579.             parRuoloPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_RUOLO_PORTA, ruoloPorta.getValue());
  12580.         }
  12581.         Parameter parNomePorta = null;
  12582.         if(nomePorta!=null) {
  12583.             parNomePorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_NOME_PORTA, nomePorta);
  12584.         }
  12585.         Parameter parServiceBinding = null;
  12586.         if(serviceBinding!=null) {
  12587.             parServiceBinding = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_SERVICE_BINDING, serviceBinding.name());
  12588.         }
  12589.        
  12590.         DataElement de = new DataElement();
  12591.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_IS_ATTIVAZIONE_GLOBALE);
  12592.         de.setValue(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_IS_ATTIVAZIONE_GLOBALE_VALORE);
  12593.         de.setType(DataElementType.HIDDEN);
  12594.         dati.add(de);
  12595.        
  12596.         de = new DataElement();
  12597.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_RUOLO_PORTA);
  12598.         de.setValue(ruoloPorta!=null ? ruoloPorta.getValue() : null);
  12599.         de.setType(DataElementType.HIDDEN);
  12600.         dati.add(de);
  12601.        
  12602.         de = new DataElement();
  12603.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_NOME_PORTA);
  12604.         de.setValue(nomePorta);
  12605.         de.setType(DataElementType.HIDDEN);
  12606.         dati.add(de);
  12607.        
  12608.         if(serviceBinding!=null) {
  12609.             de = new DataElement();
  12610.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_SERVICE_BINDING);
  12611.             de.setValue(serviceBinding.name());
  12612.             de.setType(DataElementType.HIDDEN);
  12613.             dati.add(de);
  12614.         }
  12615.                        
  12616.         /* Servono per le bradcump */
  12617.        
  12618.         String jmxParam = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE);
  12619.         boolean jmx = jmxParam!=null && "true".equals(jmxParam);
  12620.        
  12621.         if(!jmx){
  12622.             de = new DataElement();
  12623.             de.setLabel(nomeSezione);
  12624.             de.setType(DataElementType.TITLE);
  12625.             dati.add(de);
  12626.         }
  12627.        
  12628.         if(policy!=null && policy.getId()!=null && policy.getId()>0){
  12629.             // id
  12630.             de = new DataElement();
  12631.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID);
  12632.             de.setValue(policy.getId()+"");
  12633.             de.setType(DataElementType.HIDDEN);
  12634.             dati.add(de);
  12635.         }
  12636.            
  12637.         InfoPolicy infoPolicy = null;
  12638.         List<String> idPolicies = new ArrayList<>();
  12639.         String modalitaRisorsa = null;
  12640.         String modalitaEsiti = null;
  12641.         String modalitaIntervallo = null;
  12642.         String modalitaCongestione = null;
  12643.         String modalitaDegrado = null;
  12644.         String modalitaErrorRate = null;
  12645.         boolean modalitaSimultaneeEnabled = false;
  12646.         boolean modalitaCongestioneEnabled = false;
  12647.         boolean modalitaDegradoEnabled = false;
  12648.         boolean modalitaErrorRateEnabled = false;
  12649.        
  12650.         boolean addInfoDescrizionePolicy = !jmx;
  12651.        
  12652.         if(TipoOperazione.ADD.equals(tipoOperazione)){
  12653.        
  12654.             if(modalita==null) {
  12655.                 modalita = ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_DEFAULT;
  12656.             }
  12657.            
  12658.         }
  12659.        
  12660.        
  12661.         if(TipoOperazione.ADD.equals(tipoOperazione) && modalita!=null &&
  12662.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_BUILT_IN.equals(modalita)){
  12663.        
  12664.             modalitaRisorsa = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_RISORSA);
  12665.             modalitaEsiti = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_ESITI);
  12666.             modalitaIntervallo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_INTERVALLO);
  12667.             modalitaCongestione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_CONGESTIONE);
  12668.             modalitaDegrado = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_DEGRADO);
  12669.             modalitaErrorRate = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_ERROR_RATE);
  12670.        
  12671.             if(modalitaRisorsa==null) {
  12672.                 if(CostantiControlStation.USE_SELECT_LIST_SEPARATE_METRICHE) {
  12673.                     modalitaRisorsa = ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_DEFAULT;
  12674.                 }
  12675.                 else {
  12676.                     modalitaRisorsa = CostantiControlStation.DEFAULT_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA_TIPO_VALUE.getValue();
  12677.                 }
  12678.             }
  12679.             if(modalitaEsiti==null) {
  12680.                 if(CostantiControlStation.USE_SELECT_LIST_SEPARATE_METRICHE) {
  12681.                     modalitaEsiti = ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_ESITI_DEFAULT;
  12682.                 }
  12683.             }
  12684.             if(modalitaIntervallo==null) {
  12685.                 modalitaIntervallo = ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_RISORSA_INTERVALLO_OSSERVAZIONE_DEFAULT;
  12686.             }
  12687.                
  12688.             modalitaSimultaneeEnabled = isTipoRisorsaNumeroRichiesteSimultanee(modalitaRisorsa);

  12689.             modalitaCongestioneEnabled = ServletUtils.isCheckBoxEnabled(modalitaCongestione);
  12690.            
  12691.             modalitaDegradoEnabled = ServletUtils.isCheckBoxEnabled(modalitaDegrado);
  12692.            
  12693.             modalitaErrorRateEnabled = ServletUtils.isCheckBoxEnabled(modalitaErrorRate);
  12694.            
  12695.             List<String> idPoliciesTmp = new ArrayList<>();
  12696.             List<InfoPolicy> idPoliciesSoddisfanoCriteri = new ArrayList<>();
  12697.             findPolicyBuiltIn(policies,
  12698.                     idPoliciesSoddisfanoCriteri,
  12699.                     modalitaRisorsa, modalitaEsiti,
  12700.                     modalitaSimultaneeEnabled, modalitaIntervallo,
  12701.                     modalitaCongestioneEnabled,
  12702.                     modalitaDegradoEnabled,
  12703.                     modalitaErrorRateEnabled);
  12704.            
  12705.             // filtro per compatibilita'
  12706.             if(type!=null) {
  12707.                 List<InfoPolicy> idPoliciesSoddisfanoCriteriFiltered = new ArrayList<>();
  12708.                 for (InfoPolicy infoPolicyCheck : idPoliciesSoddisfanoCriteri) {
  12709.                     TipoRisorsaPolicyAttiva tipoRisorsa = TipoRisorsaPolicyAttiva.getTipo(infoPolicyCheck.getTipoRisorsa(), infoPolicyCheck.isCheckRichiesteSimultanee());
  12710.                     if(type.isSupportedResource(tipoRisorsa)) {
  12711.                         idPoliciesSoddisfanoCriteriFiltered.add(infoPolicyCheck);
  12712.                     }
  12713.                 }
  12714.                 idPoliciesSoddisfanoCriteri = idPoliciesSoddisfanoCriteriFiltered;
  12715.             }
  12716.            
  12717.             if(!idPoliciesSoddisfanoCriteri.isEmpty()) {
  12718.                 for (InfoPolicy infoPolicyCheck : idPoliciesSoddisfanoCriteri) {
  12719.                     idPoliciesTmp.add(infoPolicyCheck.getIdPolicy());
  12720.                     if(policy.getIdPolicy()!=null && policy.getIdPolicy().equals(infoPolicyCheck.getIdPolicy())){
  12721.                         infoPolicy = infoPolicyCheck;
  12722.                     }  
  12723.                 }
  12724.             }
  12725.             if(idPoliciesTmp.size()<=0) {
  12726.                
  12727.                 if(policies==null || policies.size()<=0 ) {
  12728.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_POLICY_BUILT_IN_NON_ESISTENTI, MessageType.ERROR);
  12729.                 }
  12730.                 else {
  12731.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_POLICY_BUILT_IN_CRITERI_NON_ESISTENTI, MessageType.ERROR);
  12732.                 }
  12733.                
  12734.             }
  12735.             else {
  12736.                
  12737.                 if(idPoliciesTmp.size()>1) {
  12738.                     idPoliciesTmp.add("-");
  12739.                     idPolicies.addAll(idPoliciesTmp);
  12740.                 }
  12741.                 else {
  12742.                     String idPolicy = idPoliciesTmp.get(0);
  12743.                     idPolicies.add(idPolicy);
  12744.                     for (InfoPolicy info : policies) {
  12745.                         if(idPolicy!=null && idPolicy.equals(info.getIdPolicy())){
  12746.                             infoPolicy = info;
  12747.                         }
  12748.                     }
  12749.                 }
  12750.                
  12751.             }
  12752.            
  12753.         }
  12754.         else {
  12755.            
  12756.             // filtro per compatibilita'
  12757.             if(type!=null) {
  12758.                 List<InfoPolicy> idPoliciesSoddisfanoCriteriFiltered = new ArrayList<>();
  12759.                 for (InfoPolicy infoPolicyCheck : policies) {
  12760.                     TipoRisorsaPolicyAttiva tipoRisorsa = TipoRisorsaPolicyAttiva.getTipo(infoPolicyCheck.getTipoRisorsa(), infoPolicyCheck.isCheckRichiesteSimultanee());
  12761.                     if(type.isSupportedResource(tipoRisorsa)) {
  12762.                         idPoliciesSoddisfanoCriteriFiltered.add(infoPolicyCheck);
  12763.                     }
  12764.                 }
  12765.                 policies = idPoliciesSoddisfanoCriteriFiltered;
  12766.             }
  12767.            
  12768.             if(policies==null || policies.size()<=0) {
  12769.                
  12770.                 this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_POLICY_UTENTE_NON_ESISTENTI, MessageType.ERROR);
  12771.                
  12772.             }
  12773.             else {
  12774.                 idPolicies.add("-");
  12775.                 for (InfoPolicy info : policies) {
  12776.                     idPolicies.add(info.getIdPolicy());
  12777.                     if(policy.getIdPolicy()!=null && policy.getIdPolicy().equals(info.getIdPolicy())){
  12778.                         infoPolicy = info;
  12779.                     }
  12780.                 }
  12781.             }
  12782.         }
  12783.                        
  12784.         if(!jmx){
  12785.        
  12786.             // alias
  12787.             de = new DataElement();
  12788.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ALIAS);
  12789.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ALIAS);
  12790.             //if(infoPolicy!=null){
  12791.             de.setType(DataElementType.TEXT_EDIT);
  12792. //          }
  12793. //          else {
  12794. //              de.setType(DataElementType.HIDDEN);
  12795. //          }
  12796.             de.setValue(policy.getAlias());
  12797.             de.setRequired(true);
  12798.             dati.add(de);
  12799.            
  12800.             // descrizione
  12801.             de = new DataElement();
  12802.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_DESCRIZIONE);
  12803.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_DESCRIZIONE);
  12804.             if(infoPolicy!=null){
  12805.                 if(!addInfoDescrizionePolicy) {
  12806.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  12807.                     de.setRows(6);
  12808.                     //de.setCols(57);
  12809.                     de.setCols(55);
  12810.                     de.setLabelAffiancata(true);
  12811.                 }
  12812.                 else {
  12813.                     de.setType(DataElementType.HIDDEN);                
  12814.                 }
  12815.                 de.setValue(infoPolicy.getDescrizione());
  12816.             }
  12817.             else{
  12818.                 de.setType(DataElementType.HIDDEN);
  12819.                 de.setValue(null);
  12820.             }
  12821.             dati.add(de);
  12822.            
  12823.             //if(infoPolicy!=null){
  12824.             // stato
  12825.             //boolean hidden = (ruoloPorta!=null);
  12826.             boolean hidden = false; // anche una policy di rate limiting sulla singola porta puo' essere disabiltiata temporaneamente
  12827.             boolean policyWithWarningOnly = true;
  12828.             if(infoPolicy!=null && TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(infoPolicy.getTipoRisorsa())) {
  12829.                 policyWithWarningOnly=false;
  12830.             }
  12831.             addToDatiDataElementStato_postBackViaPOST(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ENABLED,
  12832.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ENABLED, policy.isEnabled(), false,
  12833.                     policyWithWarningOnly, policy.isWarningOnly(), hidden);
  12834.            
  12835.             if(TipoOperazione.CHANGE.equals(tipoOperazione) && addInfoDescrizionePolicy && infoPolicy!=null) {
  12836.                 DataElementInfo dInfoDescrizionePolicy = new DataElementInfo(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ID);
  12837.                 dInfoDescrizionePolicy.setHeaderBody(replaceToHtmlSeparator(infoPolicy.getDescrizione()));
  12838.                 dInfoDescrizionePolicy.setListBody(CostantiControlStation.LABEL_CONFIGURAZIONE_POLICY_STATO_VALORI);
  12839.                 dati.get(dati.size()-1).setInfo(dInfoDescrizionePolicy);
  12840.             }
  12841.             else {
  12842.                 DataElementInfo dInfoDescrizionePolicy = new DataElementInfo(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ENABLED);
  12843.                 dInfoDescrizionePolicy.setListBody(CostantiControlStation.LABEL_CONFIGURAZIONE_POLICY_STATO_VALORI);
  12844.                 dati.get(dati.size()-1).setInfo(dInfoDescrizionePolicy);
  12845.             }

  12846.            
  12847.             // continue
  12848.             de = new DataElement();
  12849.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_CONTINUE);
  12850.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_CONTINUE);
  12851.             if(hidden) {
  12852.                 de.setType(DataElementType.HIDDEN);
  12853.             }
  12854.             else {
  12855.                 de.setType(DataElementType.SELECT);
  12856.                 de.setValues(ConfigurazioneCostanti.PARAMETRI_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_CONTINUE);
  12857.                 de.setLabels(ConfigurazioneCostanti.LABELS_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_CONTINUE);
  12858.                 de.setPostBack_viaPOST(true);
  12859.                 de.setSelected(policy.isContinuaValutazione()+"");
  12860.             }
  12861.             de.setValue(policy.isContinuaValutazione()+"");
  12862.            
  12863.             DataElementInfo dInfoContinuePolicy = new DataElementInfo(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_CONTINUE);
  12864.             dInfoContinuePolicy.setListBody(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_CONTINUE_ELEM);
  12865.             de.setInfo(dInfoContinuePolicy);
  12866.            
  12867.             dati.add(de);
  12868.         }
  12869.        
  12870.         if(!jmx){
  12871.             if(TipoOperazione.CHANGE.equals(tipoOperazione) && infoPolicy!=null) {
  12872.                
  12873.                 if(infoPolicy.isBuiltIn()) {
  12874.                    
  12875.                     de = new DataElement();
  12876.                     de.setLabel(ConfigurazioneCostanti.LABEL_POLICY_CRITERI);
  12877.                     de.setType(DataElementType.SUBTITLE);
  12878.                     dati.add(de);
  12879.                    
  12880.                     String modalitaRisorsaConvertValue = this.getDataElementValueRisorsa(infoPolicy.getTipoRisorsa(), infoPolicy.isCheckRichiesteSimultanee());
  12881.                     String modalitaEsitiConvertValue = this.getDataElementValueRisorsaEsiti(infoPolicy.getTipoRisorsa());
  12882.                     addDataElementRisorsa(dati,
  12883.                             ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_RISORSA+CostantiControlStation.PARAMETRO_SUFFIX_LABEL, modalitaRisorsaConvertValue,
  12884.                             ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_ESITI+CostantiControlStation.PARAMETRO_SUFFIX_LABEL, modalitaEsitiConvertValue,
  12885.                             false);
  12886.                    
  12887.                     if(!TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(modalitaRisorsaConvertValue)) {
  12888.                    
  12889.                         if(!infoPolicy.isCheckRichiesteSimultanee()) {
  12890.                             de = new DataElement();
  12891.                             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_INTERVALLO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  12892.                             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_INTERVALLO_OSSERVAZIONE);
  12893.                             de.setType(DataElementType.TEXT);
  12894.                             if(infoPolicy.getIntervalloUtilizzaRisorseRealtimeTipoPeriodo()!=null) {
  12895.                                 String labelValue = infoPolicy.getIntervalloUtilizzaRisorseRealtimeTipoPeriodo().getValue();
  12896.                                 for (int i = 0; i < ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_INTERVALLO_OSSERVAZIONE.length; i++) {
  12897.                                     if(labelValue.equals(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_INTERVALLO_OSSERVAZIONE[i])) {
  12898.                                         labelValue = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_INTERVALLO_OSSERVAZIONE[i];
  12899.                                         break;
  12900.                                     }
  12901.                                 }
  12902.                                 de.setValue(labelValue);
  12903.                             }
  12904.                             dati.add(de);
  12905.                         }
  12906.                        
  12907.                         if(infoPolicy.isControlloCongestione()) {
  12908.                             de = new DataElement();
  12909.                             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_CONGESTIONE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  12910.                             de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_NOTE);
  12911.                             de.setType(DataElementType.TEXT);
  12912.                             dati.add(de);
  12913.                         }
  12914.                        
  12915.                         if(infoPolicy.isDegradoPrestazione()) {
  12916.                             de = new DataElement();
  12917.                             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_DEGRADO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  12918.                             de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_NOTE);
  12919.                             de.setType(DataElementType.TEXT);
  12920.                             dati.add(de);
  12921.                         }
  12922.                     }
  12923.    
  12924.                 }
  12925.                 else {
  12926.                    
  12927.                     de = new DataElement();
  12928.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ID+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  12929.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ID);
  12930.                     de.setType(DataElementType.TEXT);
  12931.                     de.setValue(infoPolicy.getIdPolicy());
  12932.                     dati.add(de);
  12933.                    
  12934.                 }
  12935.                
  12936.             }
  12937.         }
  12938.        

  12939.         if(!jmx){
  12940.            
  12941.             if(TipoOperazione.CHANGE.equals(tipoOperazione)){
  12942.                 if(policy!=null && policy.isEnabled()){
  12943.                    
  12944.                     if(infoPolicy==null || !TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(infoPolicy.getTipoRisorsa())) {
  12945.                    
  12946.                         de = new DataElement();
  12947.                         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RUNTIME);
  12948.                         de.setType(DataElementType.SUBTITLE);
  12949.                         dati.add(de);
  12950.                     }
  12951.                 }
  12952.             }
  12953.            
  12954.         }
  12955.        
  12956.         if(TipoOperazione.CHANGE.equals(tipoOperazione) &&
  12957.                 policy.getIdActivePolicy()!=null && !"".equals(policy.getIdActivePolicy())){
  12958.             // id-active-policy
  12959.             de = new DataElement();
  12960.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_ID_UNICO);
  12961.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_ID_UNICO);
  12962.             //if(!jmx){
  12963.                 //de.setType(DataElementType.TEXT);
  12964.                 de.setType(DataElementType.HIDDEN);
  12965.             //}
  12966.             //else{
  12967.             //  de.setType(DataElementType.HIDDEN);
  12968.             //}
  12969.             de.setValue(policy.getIdActivePolicy());
  12970.             dati.add(de);
  12971.         }
  12972.        
  12973.         if(!jmx){
  12974.            
  12975.             if(TipoOperazione.CHANGE.equals(tipoOperazione)){
  12976.                 if(policy!=null && policy.isEnabled()){
  12977.                    
  12978.                     if(infoPolicy==null || !TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(infoPolicy.getTipoRisorsa())) {
  12979.                    
  12980.                         // Link visualizza stato
  12981.                         de = new DataElement();
  12982.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_STATO);
  12983.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_STATO);
  12984.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_STATO);
  12985.                         if(ruoloPorta!=null) {
  12986.                             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE,
  12987.                                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID,policy.getId()+""),
  12988.                                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE, true+""),
  12989.                                     parRuoloPorta,parNomePorta,parServiceBinding);          
  12990.                         }
  12991.                         else {
  12992.                             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE,
  12993.                                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID,policy.getId()+""),
  12994.                                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE, true+""));
  12995.                         }
  12996.                         de.setType(DataElementType.LINK);
  12997.                         dati.add(de);
  12998.                        
  12999.                     }
  13000.                 }
  13001.             }
  13002.            
  13003.            
  13004.             if(TipoOperazione.ADD.equals(tipoOperazione)) {
  13005.                
  13006.                 de = new DataElement();
  13007.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA);
  13008.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA);
  13009.                 de.setValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_VALORI);
  13010.                 de.setSelected(modalita);
  13011.                 de.setValue(modalita);
  13012.                 de.setType(DataElementType.SELECT);
  13013.                 de.setPostBack_viaPOST(true);
  13014.                 dati.add(de);
  13015.                
  13016.             }
  13017.            
  13018.         }
  13019.        
  13020.         // policy
  13021.         de = new DataElement();
  13022.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ID);
  13023.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ID);
  13024.         boolean configurazionePerCriteri = false;
  13025.         if(TipoOperazione.ADD.equals(tipoOperazione)){
  13026.             if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_BUILT_IN.equals(modalita) &&
  13027.                     (idPolicies==null || idPolicies.size()<=1)) {
  13028.                 de.setType(DataElementType.HIDDEN);
  13029.                 configurazionePerCriteri = true;
  13030.             }
  13031.             else {
  13032.                 de.setValues(idPolicies);
  13033.                 if(policy.getIdPolicy()!=null)
  13034.                     de.setSelected(policy.getIdPolicy());
  13035.                 else
  13036.                     de.setSelected("-");
  13037.                 de.setType(DataElementType.SELECT);
  13038.                 de.setRequired(true);
  13039.                 de.setPostBack_viaPOST(true);
  13040.                
  13041.                 if(addInfoDescrizionePolicy && infoPolicy!=null) {
  13042.                     DataElementInfo dInfoDescrizionePolicy = new DataElementInfo(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ID);
  13043.                     dInfoDescrizionePolicy.setHeaderBody(replaceToHtmlSeparator(infoPolicy.getDescrizione()));
  13044.                     de.setInfo(dInfoDescrizionePolicy);
  13045.                 }
  13046.             }
  13047.         }
  13048.         else{
  13049.             de.setType(DataElementType.HIDDEN);
  13050.         }
  13051.         if(configurazionePerCriteri && idPolicies!=null && idPolicies.size()==1) {
  13052.             de.setValue(idPolicies.get(0));
  13053.         }
  13054.         else {
  13055.             if(policy.getIdPolicy()!=null) {
  13056.                 de.setValue(policy.getIdPolicy());
  13057.             }
  13058.             else {
  13059.                 de.setValue("-");
  13060.             }
  13061.         }
  13062.         dati.add(de);
  13063.        
  13064.         if(!jmx){
  13065.            
  13066.             if(TipoOperazione.ADD.equals(tipoOperazione) && modalita!=null &&
  13067.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_BUILT_IN.equals(modalita)){
  13068.            
  13069.                 org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale configurazioneControlloTraffico = this.confCore.getConfigurazioneControlloTraffico();
  13070.                
  13071.                 de = new DataElement();
  13072.                 de.setLabel(ConfigurazioneCostanti.LABEL_POLICY_CRITERI);
  13073.                 de.setType(DataElementType.SUBTITLE);
  13074.                 dati.add(de);
  13075.                
  13076.                 addDataElementRisorsa(dati,
  13077.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_RISORSA, modalitaRisorsa,
  13078.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_ESITI, modalitaEsiti,
  13079.                         true,
  13080.                         type);
  13081.                
  13082.                 if(!TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(modalitaRisorsa)) {
  13083.                
  13084.                     if(!modalitaSimultaneeEnabled) {
  13085.                         de = new DataElement();
  13086.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_INTERVALLO);
  13087.                         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_INTERVALLO_OSSERVAZIONE);
  13088.                         de.setType(DataElementType.SELECT);
  13089.                         de.setValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_INTERVALLO_OSSERVAZIONE);
  13090.                         de.setLabels(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_INTERVALLO_OSSERVAZIONE);
  13091.                         de.setSelected(modalitaIntervallo);
  13092.                         de.setValue(modalitaIntervallo);
  13093.                         de.setPostBack_viaPOST(true);
  13094.                         dati.add(de);
  13095.                     }
  13096.                    
  13097.                     de = new DataElement();
  13098.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_CONGESTIONE);
  13099.                     //de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_LABEL);
  13100.                     de.setLabelRight(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_NOTE);
  13101.                     de.setType(DataElementType.CHECKBOX);
  13102.                     de.setSelected(modalitaCongestioneEnabled);
  13103.                     de.setValue(modalitaCongestioneEnabled+"");
  13104.                     de.setPostBack_viaPOST(true);
  13105.                     DataElementInfo dInfoDescrizioneCongestione = new DataElementInfo(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_CONGESTIONE_LABEL);
  13106.                     dInfoDescrizioneCongestione.setHeaderBody(replaceToHtmlSeparator(this.getApplicabilitaConCongestione(configurazioneControlloTraffico.getControlloTraffico())));
  13107.                     de.setInfo(dInfoDescrizioneCongestione);
  13108.                     dati.add(de);
  13109.                    
  13110.                     de = new DataElement();
  13111.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_DEGRADO);
  13112.                     //de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_LABEL);
  13113.                     de.setLabelRight(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_NOTE);
  13114.                     if(!TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(modalitaRisorsa) &&
  13115.                         !TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(modalitaRisorsa)
  13116.                         ){
  13117.                         de.setType(DataElementType.CHECKBOX);
  13118.                     }
  13119.                     else{
  13120.                         de.setType(DataElementType.HIDDEN);
  13121.                     }
  13122.                     de.setSelected(modalitaDegradoEnabled);
  13123.                     de.setValue(modalitaDegradoEnabled+"");
  13124.                     de.setPostBack_viaPOST(true);
  13125.                     DataElementInfo dInfoDescrizioneDegrado = new DataElementInfo(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_CON_DEGRADO_PRESTAZIONALE_LABEL);
  13126.                     dInfoDescrizioneDegrado.setHeaderBody(replaceToHtmlSeparator(this.getApplicabilitaDegradoPrestazionale()));
  13127.                     de.setInfo(dInfoDescrizioneDegrado);
  13128.                     dati.add(de);
  13129.                    
  13130.     //              de = new DataElement();
  13131.     //              de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_MODALITA_CRITERIO_ERROR_RATE);
  13132.     //              //de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_ERROR_RATE_LABEL);
  13133.     //              de.setLabelRight(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_APPLICABILITA_ERROR_RATE_NOTE);
  13134.     //              de.setType(DataElementType.CHECKBOX);
  13135.     //              de.setSelected(modalitaErrorRateEnabled);
  13136.     //              de.setValue(modalitaErrorRateEnabled+"");
  13137.     //              de.setPostBack_viaPOST(true);
  13138.     //              dati.add(de);
  13139.                 }
  13140.                
  13141.             }
  13142.            
  13143.            
  13144.             if(idPolicies!=null && idPolicies.size()>0 && infoPolicy!=null) {
  13145.                 de = new DataElement();
  13146.                 de.setLabel(ConfigurazioneCostanti.LABEL_POLICY_INFORMAZIONI_SOGLIA);
  13147.                 de.setType(DataElementType.TITLE);
  13148.                 dati.add(de);
  13149.             }
  13150.            
  13151.             // ridefinisci
  13152.             de = new DataElement();
  13153.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_RIDEFINISCI);
  13154.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_RIDEFINISCI);
  13155.             if(infoPolicy!=null){
  13156.                 de.setType(DataElementType.CHECKBOX);
  13157.                 de.setSelected(policy.isRidefinisci());
  13158.                 de.setValue(policy.isRidefinisci()+"");
  13159.             }
  13160.             else{
  13161.                 de.setType(DataElementType.HIDDEN);
  13162.                 de.setValue("false");
  13163.             }
  13164.             de.setPostBack_viaPOST(true);
  13165.             dati.add(de);
  13166.            
  13167.             // Valore Soglia
  13168.            
  13169.             if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(modalitaRisorsa) ||
  13170.                     (infoPolicy!=null && infoPolicy.getTipoRisorsa()!=null && TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(infoPolicy.getTipoRisorsa()))) {
  13171.                 de = new DataElement();
  13172.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VALORE_2);
  13173.                 if(infoPolicy!=null){
  13174.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RICHIESTA_LABEL);
  13175.                 }
  13176.                 if(infoPolicy!=null){
  13177.                     if(policy.isRidefinisci()){
  13178.                         de.setType(DataElementType.TEXT_EDIT);
  13179.                         de.setRequired(true);
  13180.                         if(policy.getValore2()!=null){
  13181.                             de.setValue(policy.getValore2()+"");
  13182.                         }
  13183.                         else{
  13184.                             de.setValue("");
  13185.                         }
  13186.                     }
  13187.                     else{
  13188.                         de.setType(DataElementType.TEXT);
  13189.                         if(infoPolicy.getValore2()!=null){
  13190.                             de.setValue(infoPolicy.getValore2()+"");
  13191.                         }
  13192.                         else{
  13193.                             de.setValue("");
  13194.                         }
  13195.                     }
  13196.                 }
  13197.                 else{
  13198.                     de.setType(DataElementType.HIDDEN);
  13199.                     de.setValue("");
  13200.                 }
  13201.                 //de.setSize(consoleHelper.getSize());
  13202.                 dati.add(de);
  13203.             }
  13204.            
  13205.             de = new DataElement();
  13206.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VALORE);
  13207.             if(infoPolicy!=null){
  13208.                 switch (infoPolicy.getTipoRisorsa()) {
  13209.                 case NUMERO_RICHIESTE:
  13210.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  13211.                     break;
  13212.                 case DIMENSIONE_MASSIMA_MESSAGGIO:
  13213.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RISPOSTA_LABEL);
  13214.                     de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_NOTE);
  13215.                     break;
  13216.                 case OCCUPAZIONE_BANDA:
  13217.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_OCCUPAZIONE_DI_BANDA_LABEL);
  13218.                     de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_OCCUPAZIONE_DI_BANDA_NOTE);
  13219.                     break;
  13220.                 case TEMPO_MEDIO_RISPOSTA:
  13221.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_LABEL);
  13222.                     de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_NOTE);
  13223.                     break;
  13224.                 case TEMPO_COMPLESSIVO_RISPOSTA:
  13225.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_LABEL);
  13226.                     de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_NOTE);
  13227.                     break;
  13228.                 case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO:
  13229.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  13230.                     de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_NOTE);
  13231.                     break;
  13232.                 case NUMERO_RICHIESTE_FALLITE:
  13233.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  13234.                     de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE_FALLITE_NOTE);
  13235.                     break;
  13236.                 case NUMERO_FAULT_APPLICATIVI:
  13237.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  13238.                     de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_FAULT_APPLICATIVI_NOTE);
  13239.                     break;
  13240.                 case NUMERO_RICHIESTE_FALLITE_OFAULT_APPLICATIVI:
  13241.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  13242.                     de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE_FALLITE_O_FAULT_NOTE);
  13243.                     break;
  13244.                 case NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_OFAULT_APPLICATIVI:
  13245.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE);
  13246.                     de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE_COMPLETATE_CON_SUCCESSO_O_FAULT_NOTE);
  13247.                     break;
  13248.                 }
  13249.             }
  13250.             if(infoPolicy!=null){
  13251.                 if(policy.isRidefinisci()){
  13252.                     de.setType(DataElementType.TEXT_EDIT);
  13253.                     de.setRequired(true);
  13254.                     if(policy.getValore()!=null){
  13255.                         de.setValue(policy.getValore()+"");
  13256.                     }
  13257.                     else{
  13258.                         de.setValue("");
  13259.                     }
  13260.                 }
  13261.                 else{
  13262.                     de.setType(DataElementType.TEXT);
  13263.                     if(infoPolicy.getValore()!=null){
  13264.                         de.setValue(infoPolicy.getValore()+"");
  13265.                     }
  13266.                     else{
  13267.                         de.setValue("");
  13268.                     }
  13269.                 }
  13270.             }
  13271.             else{
  13272.                 de.setType(DataElementType.HIDDEN);
  13273.                 de.setValue("");
  13274.             }
  13275.             //de.setSize(consoleHelper.getSize());
  13276.             dati.add(de);
  13277.            
  13278.             if(infoPolicy!=null){
  13279.                                
  13280.                 boolean delegata = false;
  13281.                 boolean applicativa = false;
  13282.                 @SuppressWarnings("unused")
  13283.                 boolean configurazione = false;
  13284.                 if(ruoloPorta!=null) {
  13285.                     if(RuoloPolicy.DELEGATA.equals(ruoloPorta)) {
  13286.                         delegata = (nomePorta!=null);
  13287.                     }
  13288.                     else if(RuoloPolicy.APPLICATIVA.equals(ruoloPorta)) {
  13289.                         applicativa = (nomePorta!=null);
  13290.                     }
  13291.                 }
  13292.                 configurazione = !delegata && !applicativa;
  13293.                
  13294.                 boolean multitenant = this.confCore.isMultitenant();
  13295.                
  13296.                 boolean tokenAbilitato = true;
  13297.                
  13298.                 PddTipologia pddTipologiaSoggettoAutenticati = null;
  13299.                 boolean gestioneErogatori_soggettiAutenticati_escludiSoggettoErogatore = false;
  13300.                 PortaDelegata portaDelegata = null;
  13301.                 PortaApplicativa portaApplicativa = null;
  13302.                 CredenzialeTipo tipoAutenticazione = null;
  13303.                 Boolean appId = null;
  13304.                 String tokenPolicy = null;
  13305.                 IDSoggetto idSoggettoProprietario = null;
  13306.                 if(ruoloPorta!=null) {
  13307.                     if(applicativa) {
  13308.                        
  13309.                         if(multitenant && this.confCore.getMultitenantSoggettiErogazioni()!=null) {
  13310.                             switch (this.confCore.getMultitenantSoggettiErogazioni()) {
  13311.                             case SOLO_SOGGETTI_ESTERNI:
  13312.                                 pddTipologiaSoggettoAutenticati = PddTipologia.ESTERNO;
  13313.                                 break;
  13314.                             case ESCLUDI_SOGGETTO_EROGATORE:
  13315.                                 gestioneErogatori_soggettiAutenticati_escludiSoggettoErogatore = true;
  13316.                                 break;
  13317.                             case TUTTI:
  13318.                                 break;
  13319.                             }
  13320.                         }
  13321.                        
  13322.                         IDPortaApplicativa idPA = new IDPortaApplicativa();
  13323.                         idPA.setNome(nomePorta);
  13324.                         portaApplicativa = this.porteApplicativeCore.getPortaApplicativa(idPA);
  13325.                         tipoAutenticazione = CredenzialeTipo.toEnumConstant(portaApplicativa.getAutenticazione());
  13326.                         if(CredenzialeTipo.APIKEY.equals(tipoAutenticazione)) {
  13327.                             ApiKeyState apiKeyState =  new ApiKeyState(this.porteApplicativeCore.getParametroAutenticazione(portaApplicativa.getAutenticazione(), portaApplicativa.getProprietaAutenticazioneList()));
  13328.                             appId = apiKeyState.appIdSelected;
  13329.                         }
  13330.                         if(portaApplicativa.getGestioneToken()!=null && portaApplicativa.getGestioneToken().getPolicy()!=null) {
  13331.                             tokenPolicy = portaApplicativa.getGestioneToken().getPolicy();
  13332.                         }
  13333.                         idSoggettoProprietario = new IDSoggetto(portaApplicativa.getTipoSoggettoProprietario(), portaApplicativa.getNomeSoggettoProprietario());
  13334.                        
  13335.                         if(portaApplicativa.getGestioneToken()!=null) {
  13336.                             String gestioneTokenPolicy = portaApplicativa.getGestioneToken().getPolicy();
  13337.                             if( gestioneTokenPolicy == null ||
  13338.                                     gestioneTokenPolicy.equals("") ||
  13339.                                     gestioneTokenPolicy.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO)) {
  13340.                                 tokenAbilitato = false;
  13341.                             }                      
  13342.                         }
  13343.                         else {
  13344.                             tokenAbilitato = false;
  13345.                         }
  13346.    
  13347.                     }
  13348.                     if(delegata) {
  13349.                         IDPortaDelegata idPD = new IDPortaDelegata();
  13350.                         idPD.setNome(nomePorta);
  13351.                         portaDelegata = this.porteDelegateCore.getPortaDelegata(idPD);
  13352.                         tipoAutenticazione = CredenzialeTipo.toEnumConstant(portaDelegata.getAutenticazione());
  13353.                         if(CredenzialeTipo.APIKEY.equals(tipoAutenticazione)) {
  13354.                             ApiKeyState apiKeyState =  new ApiKeyState(this.porteDelegateCore.getParametroAutenticazione(portaDelegata.getAutenticazione(), portaDelegata.getProprietaAutenticazioneList()));
  13355.                             appId = apiKeyState.appIdSelected;
  13356.                         }
  13357.                         if(portaDelegata.getGestioneToken()!=null && portaDelegata.getGestioneToken().getPolicy()!=null) {
  13358.                             tokenPolicy = portaDelegata.getGestioneToken().getPolicy();
  13359.                         }
  13360.                         idSoggettoProprietario = new IDSoggetto(portaDelegata.getTipoSoggettoProprietario(), portaDelegata.getNomeSoggettoProprietario());
  13361.                        
  13362.                         if(portaDelegata.getGestioneToken()!=null) {
  13363.                             String gestioneTokenPolicy = portaDelegata.getGestioneToken().getPolicy();
  13364.                             if( gestioneTokenPolicy == null ||
  13365.                                     gestioneTokenPolicy.equals("") ||
  13366.                                     gestioneTokenPolicy.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO)) {
  13367.                                 tokenAbilitato = false;
  13368.                             }                      
  13369.                         }
  13370.                         else {
  13371.                             tokenAbilitato = false;
  13372.                         }
  13373.                     }
  13374.                 }
  13375.                
  13376.                 // GroupBy
  13377.                 if(!TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(modalitaRisorsa) &&
  13378.                         (infoPolicy==null || infoPolicy.getTipoRisorsa()==null || !TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(infoPolicy.getTipoRisorsa()))) {
  13379.                     addToDatiAttivazioneGroupBy(dati, tipoOperazione, policy, nomeSezione, infoPolicy,
  13380.                             ruoloPorta, nomePorta, serviceBinding,
  13381.                             tokenAbilitato
  13382.                             );
  13383.                 }
  13384.                
  13385.                 // Filtro
  13386.                 addToDatiAttivazioneFiltro(dati, tipoOperazione, policy, nomeSezione, infoPolicy, ruoloPorta, nomePorta, serviceBinding,
  13387.                         idSoggettoProprietario, tokenAbilitato,
  13388.                         tipoAutenticazione, appId, tokenPolicy,
  13389.                         pddTipologiaSoggettoAutenticati, gestioneErogatori_soggettiAutenticati_escludiSoggettoErogatore
  13390.                         );
  13391.                
  13392.             }
  13393.            
  13394.         }
  13395.        
  13396.         else{
  13397.            
  13398.             // jmx
  13399.            
  13400.             List<String> aliases = this.core.getJmxPdDAliases();
  13401.             if(aliases==null || aliases.size()<=0){
  13402.                 throw new DriverControlStationException("Pagina non prevista, la sezione configurazione non permette di accedere a questa pagina, se la configurazione non e' corretta");
  13403.             }
  13404.            
  13405.             String jmxResetParam = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_RESET);
  13406.             boolean jmxReset = jmxResetParam!=null && !"".equals(jmxResetParam);
  13407.             String aliasJmxReset = null;
  13408.             if(jmxReset){
  13409.                 if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_RESET_ALL_VALUE.equals(jmxResetParam)==false){
  13410.                     aliasJmxReset = jmxResetParam;
  13411.                 }
  13412.             }

  13413.             boolean showResetCounters =  (infoPolicy.isCheckRichiesteSimultanee()==false) &&
  13414.                     (infoPolicy.isIntervalloUtilizzaRisorseRealtime() || infoPolicy.isDegradoPrestazionaleUtilizzaRisorseRealtime());

  13415.             de = new DataElement();
  13416.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_INFORMAZIONI_RUNTIME);
  13417.             de.setType(DataElementType.TITLE);
  13418.             dati.add(de);
  13419.            
  13420.             // Link refresh
  13421.             de = new DataElement();
  13422.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_STATO);
  13423.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_STATO_REFRESH);
  13424.             de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_STATO_REFRESH);
  13425.             if(ruoloPorta!=null) {
  13426.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE,
  13427.                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID,policy.getId()+""),
  13428.                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE, true+""),
  13429.                         parRuoloPorta, parNomePorta,parServiceBinding);
  13430.             }
  13431.             else {
  13432.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE,
  13433.                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID,policy.getId()+""),
  13434.                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE, true+""));
  13435.             }
  13436.             de.setType(DataElementType.LINK);
  13437.             dati.add(de);

  13438.             if(showResetCounters && aliases.size()>1){
  13439.                 // Link resetCounters
  13440.                 de = new DataElement();
  13441.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_RESET);
  13442.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_STATO_RESET_ALL_NODES);
  13443.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_STATO_RESET_ALL_NODES);
  13444.                 if(ruoloPorta!=null) {
  13445.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE,
  13446.                             new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID,policy.getId()+""),
  13447.                             new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE, true+""),
  13448.                             new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_RESET,
  13449.                                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_RESET_ALL_VALUE),
  13450.                             parRuoloPorta, parNomePorta,parServiceBinding);
  13451.                 }
  13452.                 else {
  13453.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE,
  13454.                             new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID,policy.getId()+""),
  13455.                             new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE, true+""),
  13456.                             new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_RESET,
  13457.                                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_RESET_ALL_VALUE));
  13458.                 }
  13459.                 de.setType(DataElementType.LINK);
  13460.                 dati.add(de);
  13461.             }
  13462.            
  13463.             int i=0;
  13464.             for (String alias : aliases) {
  13465.                
  13466.                 String descrizioneAlias = this.core.getJmxPdDDescrizione(alias);
  13467.                
  13468.                 de = new DataElement();
  13469.                 de.setLabel(descrizioneAlias);
  13470.                 de.setValue(descrizioneAlias);
  13471.                 de.setType(DataElementType.TITLE);
  13472.                 dati.add(de);
  13473.                
  13474.                 if(jmxReset && (aliasJmxReset==null || aliasJmxReset.equals(alias))){
  13475.                    
  13476.                     String resultReset = null;
  13477.                     String uniqueIdMap = null;
  13478.                     try{
  13479.                         uniqueIdMap = UniqueIdentifierUtilities.getUniqueId(policy);
  13480.                         resultReset = this.core.getInvoker().invokeJMXMethod(alias,JMXConstants.JMX_TYPE,
  13481.                                 JMXConstants.JMX_NAME,
  13482.                                 JMXConstants.CC_METHOD_NAME_RESET_POLICY_COUNTERS,
  13483.                                 uniqueIdMap);
  13484.                     }catch(Exception e){
  13485.                         String errorMessage = "Errore durante l'invocazione dell'operazione ["+JMXConstants.CC_METHOD_NAME_RESET_POLICY_COUNTERS+"] sulla risorsa ["+JMXConstants.JMX_NAME+"] (param:"+uniqueIdMap+"): "+e.getMessage();
  13486.                         ControlStationCore.getLog().error(errorMessage,e);
  13487.                         resultReset = errorMessage;
  13488.                     }
  13489.                    
  13490.                     de = new DataElement();
  13491.                     de.setType(DataElementType.NOTE);
  13492.                     de.setValue(resultReset);
  13493.                     dati.add(de);
  13494.                    
  13495.                 }
  13496.                
  13497.                 // Link resetCounters
  13498.                 if(showResetCounters){
  13499.                     de = new DataElement();
  13500.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_RESET+"_"+i);
  13501.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_STATO_RESET);
  13502.                     de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_VISUALIZZA_STATO_RESET);
  13503.                     if(ruoloPorta!=null) {
  13504.                         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE,
  13505.                                 new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID,policy.getId()+""),
  13506.                                 new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE, true+""),
  13507.                                 new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_RESET, alias),
  13508.                                 parRuoloPorta, parNomePorta,parServiceBinding);
  13509.                     }
  13510.                     else {
  13511.                         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_CHANGE,
  13512.                                 new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ID,policy.getId()+""),
  13513.                                 new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE, true+""),
  13514.                                 new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_RESET, alias));
  13515.                     }
  13516.                     de.setType(DataElementType.LINK);
  13517.                     dati.add(de);
  13518.                 }
  13519.                    
  13520.                 String result = null;
  13521.                 String uniqueIdMap = null;
  13522.                 try{
  13523.                     uniqueIdMap = UniqueIdentifierUtilities.getUniqueId(policy);
  13524.                     result = this.core.getInvoker().invokeJMXMethod(alias,JMXConstants.JMX_TYPE,
  13525.                             JMXConstants.JMX_NAME,
  13526.                             JMXConstants.CC_METHOD_NAME_GET_STATO_POLICY,
  13527.                             uniqueIdMap);
  13528.                 }catch(Exception e){
  13529.                     String errorMessage = "Errore durante l'invocazione dell'operazione ["+JMXConstants.CC_METHOD_NAME_GET_STATO_POLICY+"] sulla risorsa ["+JMXConstants.JMX_NAME+"] (param:"+uniqueIdMap+"): "+e.getMessage();
  13530.                     ControlStationCore.getLog().error(errorMessage,e);
  13531.                     result = errorMessage;
  13532.                 }
  13533.                
  13534.                 de = new DataElement();
  13535.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_JMX_STATE);
  13536.                 de.setLabelAffiancata(false);
  13537.                 de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  13538.                 de.setRows(20);
  13539.                 de.setCols(100);
  13540.                 de.setValue(result);
  13541.                 dati.add(de);
  13542.                
  13543.                 this.pd.disableEditMode();
  13544.                
  13545.                 i++;
  13546.             }
  13547.            
  13548.         }
  13549.     }
  13550.    
  13551.     protected void addToDatiDataElementStato_postBackViaGET(List<DataElement> dati, String param, String label, boolean enabled, boolean postBack, boolean withWarningOnly,
  13552.             boolean warningOnly, boolean hidden){
  13553.         this._addToDatiDataElementStato(dati, param, label, enabled, postBack, false, withWarningOnly, warningOnly, hidden);
  13554.     }
  13555.     protected void addToDatiDataElementStato_postBackViaPOST(List<DataElement> dati, String param, String label, boolean enabled, boolean postBackPOST, boolean withWarningOnly,
  13556.             boolean warningOnly, boolean hidden){
  13557.         this._addToDatiDataElementStato(dati, param, label, enabled, false, postBackPOST, withWarningOnly, warningOnly, hidden);
  13558.     }
  13559.    
  13560.     private void _addToDatiDataElementStato(List<DataElement> dati, String param, String label, boolean enabled, boolean postBack, boolean postBackPOST, boolean withWarningOnly,
  13561.             boolean warningOnly, boolean hidden){
  13562.         DataElement de = new DataElement();
  13563.         de.setName(param);
  13564.         de.setLabel(label);
  13565.         if(hidden) {
  13566.             de.setType(DataElementType.HIDDEN);
  13567.         }
  13568.         else {
  13569.             de.setType(DataElementType.SELECT);
  13570.             if(withWarningOnly){
  13571.                 de.setValues(ConfigurazioneCostanti.STATI_CON_WARNING);
  13572.             }
  13573.             else{
  13574.                 de.setValues(ConfigurazioneCostanti.STATI);
  13575.             }
  13576.             if(postBack) {
  13577.                 de.setPostBack(postBack);
  13578.             }
  13579.             if(postBackPOST) {
  13580.                 de.setPostBack_viaPOST(postBackPOST);
  13581.             }
  13582.         }
  13583.         if(enabled && (!withWarningOnly || !warningOnly) ){
  13584.             de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO);
  13585.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  13586.         }
  13587.         else if(warningOnly && withWarningOnly){
  13588.             de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_STATO_WARNING_ONLY);
  13589.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_WARNING_ONLY);
  13590.         }
  13591.         else{
  13592.             de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO);
  13593.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  13594.         }
  13595.         dati.add(de);
  13596.     }
  13597.     private void addToDatiDataElementStatoReadOnly(List<DataElement> dati, String param, String label, boolean enabled, boolean postBack,
  13598.             boolean withWarningOnly, boolean warningOnly){
  13599.         DataElement de = new DataElement();
  13600.         de.setName(param);
  13601.         de.setLabel(label);
  13602.         de.setType(DataElementType.HIDDEN);
  13603.         if(enabled && (!withWarningOnly || !warningOnly) ){
  13604.             de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO);
  13605.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  13606.         }
  13607.         else if(warningOnly && withWarningOnly){
  13608.             de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_STATO_WARNING_ONLY);
  13609.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_WARNING_ONLY);
  13610.         }
  13611.         else{
  13612.             de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO);
  13613.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  13614.         }
  13615.         dati.add(de);
  13616.        
  13617.         de = new DataElement();
  13618.         de.setName(param+"___LABEL");
  13619.         de.setLabel(label);
  13620.         de.setType(DataElementType.TEXT);
  13621.         if(enabled && (!withWarningOnly || !warningOnly) ){
  13622.             de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO);
  13623.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  13624.         }
  13625.         else if(warningOnly && withWarningOnly){
  13626.             de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_STATO_WARNING_ONLY);
  13627.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_WARNING_ONLY);
  13628.         }
  13629.         else{
  13630.             de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO);
  13631.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  13632.         }
  13633.         dati.add(de);
  13634.        
  13635.     }
  13636.    
  13637.     private void addToDatiAttivazioneFiltro(List<DataElement> dati, TipoOperazione tipoOperazione,AttivazionePolicy policy, String nomeSezione, InfoPolicy infoPolicy,
  13638.             RuoloPolicy ruoloPorta, String nomePorta, ServiceBinding serviceBinding,
  13639.             IDSoggetto idSoggettoProprietario, boolean tokenAbilitato,
  13640.             CredenzialeTipo tipoAutenticazione, Boolean appId, String tokenPolicy,
  13641.             PddTipologia pddTipologiaSoggettoAutenticati, boolean gestioneErogatori_soggettiAutenticati_escludiSoggettoErogatore) throws Exception {
  13642.    
  13643.         boolean delegata = false;
  13644.         boolean applicativa = false;
  13645.         boolean configurazione = false;
  13646.         if(ruoloPorta!=null) {
  13647.             if(RuoloPolicy.DELEGATA.equals(ruoloPorta)) {
  13648.                 delegata = (nomePorta!=null);
  13649.             }
  13650.             else if(RuoloPolicy.APPLICATIVA.equals(ruoloPorta)) {
  13651.                 applicativa = (nomePorta!=null);
  13652.             }
  13653.         }
  13654.         configurazione = !delegata && !applicativa;
  13655.        
  13656.         org.openspcoop2.core.config.constants.CredenzialeTipo tipoAutenticazioneConfig = null;
  13657.         if(tipoAutenticazione!=null) {
  13658.             tipoAutenticazioneConfig = org.openspcoop2.core.config.constants.CredenzialeTipo.toEnumConstant(tipoAutenticazione.getValue(), true);
  13659.         }
  13660.        
  13661.         boolean tokenPolicyOR = false;
  13662.         if(tokenPolicy!=null && !"".equals(tokenPolicy)) {
  13663.             if(tipoAutenticazione!=null && !org.openspcoop2.core.config.constants.CredenzialeTipo.TOKEN.equals(tipoAutenticazioneConfig)) {
  13664.                 tokenPolicyOR = true;
  13665.             }
  13666.             else {
  13667.                 tipoAutenticazioneConfig = org.openspcoop2.core.config.constants.CredenzialeTipo.TOKEN;
  13668.             }
  13669.         }
  13670.        
  13671.         boolean multitenant = this.confCore.isMultitenant();
  13672.        
  13673.        
  13674.         // Elaboro valori con dipendenze
  13675.        
  13676.         List<String> protocolliLabel = null;
  13677.         List<String> protocolliValue = null;
  13678.         String protocolloSelezionatoLabel = null;
  13679.         String protocolloSelezionatoValue = null;
  13680.        
  13681.         List<String> ruoliErogatoreLabel = null;
  13682.         List<String> ruoliErogatoreValue = null;
  13683.         String ruoloErogatoreSelezionatoLabel = null;
  13684.         String ruoloErogatoreSelezionatoValue = null;
  13685.        
  13686.         List<String> erogatoriLabel = null;
  13687.         List<String> erogatoriValue = null;
  13688.         String datiIdentificativiErogatoreSelezionatoLabel = null;
  13689.         String datiIdentificativiErogatoreSelezionatoValue = null;
  13690.        
  13691.         List<String> tagLabel = null;
  13692.         List<String> tagValue = null;
  13693.         @SuppressWarnings("unused")
  13694.         String datiIdentificativiTagSelezionatoLabel = null;
  13695.         String datiIdentificativiTagSelezionatoValue = null;
  13696.        
  13697.         List<String> serviziLabel = null;
  13698.         List<String> serviziValue = null;
  13699.         String datiIdentificativiServizioSelezionatoLabel = null;
  13700.         String datiIdentificativiServizioSelezionatoValue = null;
  13701.        
  13702.         List<String> azioniLabel = null;
  13703.         List<String> azioniValue = null;
  13704.         List<String> azioniSelezionataLabel = null;
  13705.         List<String> azioniSelezionataValue = null;
  13706.        
  13707.         List<String> serviziApplicativiErogatoreLabel = null;
  13708.         List<String> serviziApplicativiErogatoreValue = null;
  13709.         String servizioApplicativoErogatoreSelezionatoLabel = null;
  13710.         String servizioApplicativoErogatoreSelezionatoValue = null;
  13711.        
  13712.         List<String> ruoliFruitoreLabel = null;
  13713.         List<String> ruoliFruitoreValue = null;
  13714.         String ruoloFruitoreSelezionatoLabel = null;
  13715.         String ruoloFruitoreSelezionatoValue = null;
  13716.        
  13717.         List<String> fruitoriLabel = null;
  13718.         List<String> fruitoriValue = null;
  13719.         String datiIdentificativiFruitoreSelezionatoLabel = null;
  13720.         String datiIdentificativiFruitoreSelezionatoValue = null;
  13721.        
  13722.         List<String> serviziApplicativiFruitoreLabel = null;
  13723.         List<String> serviziApplicativiFruitoreValue = null;
  13724.         String servizioApplicativoFruitoreSelezionatoLabel = null;
  13725.         String servizioApplicativoFruitoreSelezionatoValue = null;
  13726.        
  13727.         String tokenClaims = null;
  13728.        
  13729.         boolean filtroByKey = false;
  13730.        
  13731.         // Cerco Ruoli con queste caratteristiche
  13732.         FiltroRicercaRuoli filtroRuoli = new FiltroRicercaRuoli();
  13733.         filtroRuoli.setTipologia(RuoloTipologia.INTERNO);
  13734.        
  13735.         boolean protocolloAssociatoFiltroNonSelezionatoUtente = false;
  13736.         if(policy.getFiltro().isEnabled()){
  13737.             protocolliValue = this.confCore.getProtocolli(this.request, this.session);
  13738.             if(policy.getFiltro().getProtocollo()!=null) {
  13739.                 // sara' sempre impostato, a meno della prima volta (create policy)
  13740.                 if(protocolliValue.contains(policy.getFiltro().getProtocollo())==false) {
  13741.                     protocolloAssociatoFiltroNonSelezionatoUtente = true;
  13742.                 }
  13743.             }
  13744.         }
  13745.        
  13746.         if(policy.getFiltro().isEnabled()){
  13747.            
  13748.             // protocollo
  13749.             if(configurazione) {
  13750.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  13751.                     protocolloSelezionatoValue = policy.getFiltro().getProtocollo();
  13752.                 }
  13753.                 else {
  13754.                     if(!protocolliValue.contains(policy.getFiltro().getProtocollo())){
  13755.                         policy.getFiltro().setProtocollo(null);
  13756.                     }
  13757.                     protocolloSelezionatoValue = policy.getFiltro().getProtocollo();
  13758.                     if(protocolloSelezionatoValue==null || protocolloSelezionatoValue.equals("")) {
  13759.                         if(protocolliValue.size()==1) {
  13760.                             protocolloSelezionatoValue = protocolliValue.get(0);
  13761.                         }
  13762.                         else {
  13763.                             protocolloSelezionatoValue = this.confCore.getProtocolloDefault(this.request, this.session, protocolliValue);
  13764.                         }
  13765.                     }
  13766.                     //protocolli = enrichListConQualsiasi(protocolli); NOTA: In questa versione un protocollo deve essere per forza selezionato.
  13767.                     protocolliLabel = new ArrayList<>();
  13768.                     for (String protocollo : protocolliValue) {
  13769.                         protocolliLabel.add(this.getLabelProtocollo(protocollo));
  13770.                     }
  13771.                 }
  13772.                 protocolloSelezionatoLabel = this.getLabelProtocollo(protocolloSelezionatoValue);
  13773.             }
  13774.             else {
  13775.                 protocolloSelezionatoValue = policy.getFiltro().getProtocollo();
  13776.                 if(protocolloSelezionatoValue==null) {
  13777.                     protocolloSelezionatoValue = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(idSoggettoProprietario.getTipo());
  13778.                 }
  13779.             }
  13780.            
  13781.             // ruolo erogatore
  13782.             if(configurazione) {
  13783.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  13784.                     ruoloErogatoreSelezionatoValue = policy.getFiltro().getRuoloErogatore();
  13785.                     ruoloErogatoreSelezionatoLabel = ruoloErogatoreSelezionatoValue!=null ? ruoloErogatoreSelezionatoValue :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  13786.                 }
  13787.                 else {
  13788.                     List<String> ruoliErogatore = this.core.getAllRuoli(filtroRuoli);
  13789.                    
  13790.                     if(policy.getFiltro().getRuoloErogatore()!=null) {
  13791.                         ruoloErogatoreSelezionatoValue = policy.getFiltro().getRuoloErogatore();
  13792.                     }
  13793.                     if(!ruoliErogatore.contains(ruoloErogatoreSelezionatoValue)){
  13794.                         policy.getFiltro().setRuoloErogatore(null);
  13795.                         ruoloErogatoreSelezionatoValue = null;
  13796.                     }
  13797.                     ruoliErogatoreLabel = enrichListConLabelQualsiasi(ruoliErogatore);
  13798.                     ruoliErogatoreValue = enrichListConValueQualsiasi(ruoliErogatore);
  13799.                 }
  13800.             }
  13801.            
  13802.             // erogatore
  13803.             if(configurazione) {
  13804.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  13805.                     IDSoggetto idSoggetto = null;
  13806.                     if(policy.getFiltro().getTipoErogatore()!=null && policy.getFiltro().getNomeErogatore()!=null){
  13807.                         datiIdentificativiErogatoreSelezionatoValue = policy.getFiltro().getTipoErogatore() + "/" + policy.getFiltro().getNomeErogatore();
  13808.                         idSoggetto = new IDSoggetto(policy.getFiltro().getTipoErogatore() , policy.getFiltro().getNomeErogatore());
  13809.                     }
  13810.                     datiIdentificativiErogatoreSelezionatoLabel = idSoggetto!=null ? this.getLabelNomeSoggetto(idSoggetto) :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  13811.                 }
  13812.                 else {
  13813.                     List<IDSoggetto> listErogatori = new ArrayList<>();

  13814.                     List<IDSoggetto> listSoggettiPreFilterMultitenant = this.confCore.getSoggettiErogatori(protocolloSelezionatoValue, protocolliValue);
  13815.                     if(policy.getFiltro().getRuoloPorta()!=null && !RuoloPolicy.ENTRAMBI.equals(policy.getFiltro().getRuoloPorta())) {
  13816.                         for (IDSoggetto idSoggetto : listSoggettiPreFilterMultitenant) {
  13817.                             Soggetto s = this.soggettiCore.getSoggettoRegistro(idSoggetto);
  13818.                             boolean isPddEsterna = this.pddCore.isPddEsterna(s.getPortaDominio());
  13819.                             if(RuoloPolicy.DELEGATA.equals(policy.getFiltro().getRuoloPorta())) {
  13820.                                 if(isPddEsterna) {
  13821.                                     listErogatori.add(idSoggetto);
  13822.                                 }  
  13823.                                 else {
  13824.                                     if(!PddTipologia.ESTERNO.equals(pddTipologiaSoggettoAutenticati)) {
  13825.                                         // multitenant abilitato
  13826.                                         listErogatori.add(idSoggetto);
  13827.                                     }
  13828.                                 }
  13829.                             }
  13830.                             else {
  13831.                                 if(!isPddEsterna) {
  13832.                                     listErogatori.add(idSoggetto);
  13833.                                 }
  13834.                             }
  13835.                         }
  13836.                     }
  13837.                     else {
  13838.                         listErogatori.addAll(listSoggettiPreFilterMultitenant);
  13839.                     }
  13840.                    
  13841.                     erogatoriLabel = new ArrayList<>();
  13842.                     erogatoriValue = new ArrayList<>();
  13843.                     for (IDSoggetto idSoggetto : listErogatori) {
  13844.                         erogatoriLabel.add(this.getLabelNomeSoggetto(idSoggetto));
  13845.                         erogatoriValue.add(idSoggetto.getTipo()+"/"+idSoggetto.getNome());
  13846.                     }
  13847.                     if(policy.getFiltro().getTipoErogatore()!=null && policy.getFiltro().getNomeErogatore()!=null){
  13848.                         datiIdentificativiErogatoreSelezionatoValue = policy.getFiltro().getTipoErogatore() + "/" + policy.getFiltro().getNomeErogatore();
  13849.                     }
  13850.                     if(!erogatoriValue.contains(datiIdentificativiErogatoreSelezionatoValue)){
  13851.                         policy.getFiltro().setTipoErogatore(null);
  13852.                         policy.getFiltro().setNomeErogatore(null);
  13853.                         datiIdentificativiErogatoreSelezionatoValue = null;
  13854.                     }
  13855.                     erogatoriLabel = enrichListConLabelQualsiasi(erogatoriLabel);
  13856.                     erogatoriValue = enrichListConValueQualsiasi(erogatoriValue);
  13857.                 }
  13858.             }
  13859.                    
  13860.             // tag
  13861.             if(configurazione) {
  13862.                 FiltroRicercaGruppi filtroRicerca = new FiltroRicercaGruppi();
  13863.                 List<String> elencoGruppi = this.gruppiCore.getAllGruppi(filtroRicerca);
  13864.                 tagLabel = enrichListConLabelQualsiasi(elencoGruppi);
  13865.                 tagValue = enrichListConValueQualsiasi(elencoGruppi);
  13866.                 datiIdentificativiTagSelezionatoValue=policy.getFiltro().getTag();
  13867.                 datiIdentificativiTagSelezionatoLabel=policy.getFiltro().getTag();
  13868.             }
  13869.            
  13870.             // servizio
  13871.             if(configurazione) {
  13872.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  13873.                     IDServizio idServizio = null;
  13874.                     if(policy.getFiltro().getTipoServizio()!=null && policy.getFiltro().getNomeServizio()!=null && policy.getFiltro().getVersioneServizio()!=null &&
  13875.                             policy.getFiltro().getTipoErogatore()!=null && policy.getFiltro().getNomeErogatore()!=null
  13876.                             ){
  13877.                         datiIdentificativiServizioSelezionatoValue = policy.getFiltro().getTipoServizio()+"/"+policy.getFiltro().getNomeServizio()+"/"+policy.getFiltro().getVersioneServizio().intValue();
  13878.                         if(this.core.isControlloTrafficoPolicyGlobaleFiltroApiSoggettoErogatore()) {
  13879.                             datiIdentificativiServizioSelezionatoValue = datiIdentificativiServizioSelezionatoValue+"/"+policy.getFiltro().getTipoErogatore()+"/"+policy.getFiltro().getNomeErogatore();
  13880.                             idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(policy.getFiltro().getTipoServizio(),
  13881.                                     policy.getFiltro().getNomeServizio(),
  13882.                                     policy.getFiltro().getTipoErogatore(),
  13883.                                     policy.getFiltro().getNomeErogatore(),
  13884.                                     policy.getFiltro().getVersioneServizio());
  13885.                         }
  13886.                         else {
  13887.                             idServizio = IDServizioFactory.getInstance().getIDServizioFromValuesWithoutCheck(policy.getFiltro().getTipoServizio(),
  13888.                                     policy.getFiltro().getNomeServizio(),
  13889.                                     null,
  13890.                                     null,
  13891.                                     policy.getFiltro().getVersioneServizio());
  13892.                         }
  13893.                     }
  13894.                     if(this.core.isControlloTrafficoPolicyGlobaleFiltroApiSoggettoErogatore()) {
  13895.                         datiIdentificativiServizioSelezionatoLabel = idServizio!=null ? this.getLabelIdServizio(idServizio) :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  13896.                     }
  13897.                     else {
  13898.                         datiIdentificativiServizioSelezionatoLabel = idServizio!=null ? this.getLabelIdServizioSenzaErogatore(idServizio) :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  13899.                     }
  13900.                 }
  13901.                 else {
  13902.                     List<IDServizio> listServizi = this.confCore.getServizi(protocolloSelezionatoValue, protocolliValue,
  13903.                             policy.getFiltro().getTipoErogatore(), policy.getFiltro().getNomeErogatore(), policy.getFiltro().getTag());
  13904.                     serviziLabel = new ArrayList<>();
  13905.                     serviziValue = new ArrayList<>();
  13906.                     for (IDServizio idServizio : listServizi) {
  13907.                        
  13908.                         String valueAPI = idServizio.getTipo()+"/"+idServizio.getNome()+"/"+idServizio.getVersione().intValue();
  13909.                         if(this.core.isControlloTrafficoPolicyGlobaleFiltroApiSoggettoErogatore()) {
  13910.                             valueAPI = valueAPI +"/"+ idServizio.getSoggettoErogatore().getTipo()+"/"+idServizio.getSoggettoErogatore().getNome();
  13911.                         }
  13912.                         if(serviziValue.contains(valueAPI)) {
  13913.                             continue;
  13914.                         }
  13915.                         serviziValue.add(valueAPI);
  13916.                        
  13917.                         String labelAPI = null;
  13918.                         if(this.core.isControlloTrafficoPolicyGlobaleFiltroApiSoggettoErogatore()) {
  13919.                             labelAPI = this.getLabelIdServizio(idServizio);
  13920.                         }
  13921.                         else {
  13922.                             labelAPI = this.getLabelIdServizioSenzaErogatore(idServizio);
  13923.                         }
  13924.                         serviziLabel.add(labelAPI);
  13925.                     }
  13926.                     boolean definedApi = policy.getFiltro().getTipoServizio()!=null && policy.getFiltro().getNomeServizio()!=null && policy.getFiltro().getVersioneServizio()!=null;
  13927.                     if(this.core.isControlloTrafficoPolicyGlobaleFiltroApiSoggettoErogatore()) {
  13928.                         definedApi = definedApi && policy.getFiltro().getTipoErogatore()!=null && policy.getFiltro().getNomeErogatore()!=null;
  13929.                     }
  13930.                     if( definedApi ){
  13931.                         datiIdentificativiServizioSelezionatoValue = policy.getFiltro().getTipoServizio()+"/"+policy.getFiltro().getNomeServizio()+"/"+policy.getFiltro().getVersioneServizio().intValue();
  13932.                         if(this.core.isControlloTrafficoPolicyGlobaleFiltroApiSoggettoErogatore()) {
  13933.                             datiIdentificativiServizioSelezionatoValue = datiIdentificativiServizioSelezionatoValue +"/"+policy.getFiltro().getTipoErogatore()+"/"+policy.getFiltro().getNomeErogatore();
  13934.                         }
  13935.                     }
  13936.                     if(!serviziValue.contains(datiIdentificativiServizioSelezionatoValue)){
  13937.                         policy.getFiltro().setTipoServizio(null);
  13938.                         policy.getFiltro().setNomeServizio(null);
  13939.                         policy.getFiltro().setVersioneServizio(null);
  13940.                         datiIdentificativiServizioSelezionatoValue = null;
  13941.                     }
  13942.                     serviziLabel = enrichListConLabelQualsiasi(serviziLabel);
  13943.                     serviziValue = enrichListConValueQualsiasi(serviziValue);
  13944.                 }
  13945.             }
  13946.            
  13947.             // azioni
  13948.             if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  13949.                 if(policy.getFiltro().getAzione()!=null && !"".equals(policy.getFiltro().getAzione())){
  13950.                     azioniSelezionataValue = new ArrayList<>();
  13951.                     if(policy.getFiltro().getAzione().contains(",")) {
  13952.                         String [] tmp = policy.getFiltro().getAzione().split(",");
  13953.                         for (String az : tmp) {
  13954.                             azioniSelezionataValue.add(az);
  13955.                         }
  13956.                     }
  13957.                     else {
  13958.                         azioniSelezionataValue.add(policy.getFiltro().getAzione());
  13959.                     }
  13960.                     if(!azioniSelezionataValue.isEmpty()) {
  13961.                         azioniSelezionataLabel = new ArrayList<>();
  13962.                         for (String az : azioniSelezionataValue) {
  13963.                             azioniSelezionataLabel.add(az);
  13964.                         }
  13965.                     }
  13966.                 }
  13967.                 if(azioniSelezionataLabel==null) {
  13968.                     azioniSelezionataLabel = new ArrayList<>();
  13969.                     azioniSelezionataLabel.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI);
  13970.                 }
  13971.             }
  13972.             else {
  13973.                 List<String> azioni = null;
  13974.                 Map<String,String> azioniConLabel = null;
  13975.                 if(configurazione && datiIdentificativiServizioSelezionatoValue!=null) {
  13976.                     if(StringUtils.isNotEmpty(policy.getFiltro().getTipoServizio()) &&
  13977.                             StringUtils.isNotEmpty(policy.getFiltro().getNomeServizio()) &&
  13978.                             policy.getFiltro().getVersioneServizio()!=null && policy.getFiltro().getVersioneServizio()>0) {
  13979.                         if(StringUtils.isNotEmpty(policy.getFiltro().getTipoErogatore()) &&
  13980.                                 StringUtils.isNotEmpty(policy.getFiltro().getNomeErogatore())) {
  13981.                             IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(policy.getFiltro().getTipoServizio(), policy.getFiltro().getNomeServizio(),
  13982.                                     policy.getFiltro().getTipoErogatore(), policy.getFiltro().getNomeErogatore(),
  13983.                                     policy.getFiltro().getVersioneServizio());
  13984.                             AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idServizio,false);
  13985.                             AccordoServizioParteComuneSintetico aspc = this.apcCore.getAccordoServizioSintetico(this.idAccordoFactory.getIDAccordoFromUri(asps.getAccordoServizioParteComune()));
  13986.                             azioniConLabel = this.porteDelegateCore.getAzioniConLabel(asps, aspc, false, true, null);
  13987.                         }
  13988.                         else {
  13989.                             List<IDServizio> listServizi = this.confCore.getServizi(protocolloSelezionatoValue, protocolliValue,
  13990.                                     policy.getFiltro().getTipoServizio(), policy.getFiltro().getNomeServizio(), policy.getFiltro().getVersioneServizio(), null);
  13991.                             List<String> uris = new ArrayList<>();
  13992.                             AccordoServizioParteSpecifica aspsRiferimento = null;
  13993.                             if(listServizi!=null && !listServizi.isEmpty()) {
  13994.                                 for (IDServizio idS : listServizi) {
  13995.                                     AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idS,false);
  13996.                                     if(!uris.contains(asps.getAccordoServizioParteComune())) {
  13997.                                         uris.add(asps.getAccordoServizioParteComune());
  13998.                                         if(aspsRiferimento==null) {
  13999.                                             aspsRiferimento = asps;
  14000.                                         }
  14001.                                     }
  14002.                                     if(uris.size()>1) {
  14003.                                         break;
  14004.                                     }
  14005.                                 }
  14006.                             }
  14007.                             if(uris.size()==1) {
  14008.                                 AccordoServizioParteComuneSintetico aspc = this.apcCore.getAccordoServizioSintetico(this.idAccordoFactory.getIDAccordoFromUri(uris.get(0)));
  14009.                                 azioniConLabel = this.porteDelegateCore.getAzioniConLabel(aspsRiferimento, aspc, false, true, null);
  14010.                             }
  14011.                         }
  14012.                     }
  14013.                     azioni = this.confCore.getAzioni(protocolloSelezionatoValue, protocolliValue,
  14014.                             policy.getFiltro().getTipoErogatore(), policy.getFiltro().getNomeErogatore(),
  14015.                             policy.getFiltro().getTipoServizio(), policy.getFiltro().getNomeServizio(), policy.getFiltro().getVersioneServizio());
  14016.                 }
  14017.                 else if(delegata) {
  14018.                     IDPortaDelegata idPD = new IDPortaDelegata();
  14019.                     idPD.setNome(policy.getFiltro().getNomePorta());
  14020.                     PortaDelegata pd = this.porteDelegateCore.getPortaDelegata(idPD);
  14021.                    
  14022.                     MappingFruizionePortaDelegata mappingPD = this.porteDelegateCore.getMappingFruizionePortaDelegata(pd);
  14023.                     IDServizio idServizio = mappingPD.getIdServizio();
  14024.                     AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idServizio,false);
  14025.                     AccordoServizioParteComuneSintetico aspc = this.apcCore.getAccordoServizioSintetico(this.idAccordoFactory.getIDAccordoFromUri(asps.getAccordoServizioParteComune()));
  14026.                    
  14027.                     if(pd.getAzione()!=null && pd.getAzione().sizeAzioneDelegataList()>0) {
  14028.                         azioni = pd.getAzione().getAzioneDelegataList();
  14029.                     }
  14030.                     else {
  14031.                         List<String> azioniAll = this.confCore.getAzioni(protocolloSelezionatoValue, protocolliValue,
  14032.                                 pd.getSoggettoErogatore().getTipo(), pd.getSoggettoErogatore().getNome(),
  14033.                                 pd.getServizio().getTipo(), pd.getServizio().getNome(), pd.getServizio().getVersione());
  14034.                        
  14035.                         IDSoggetto idSoggettoFruitore = mappingPD.getIdFruitore();
  14036.                         List<MappingFruizionePortaDelegata> listaMappingFruizione = this.apsCore.serviziFruitoriMappingList(idSoggettoFruitore, idServizio, null);
  14037.                         List<String> azioniOccupate = new ArrayList<>();
  14038.                         int listaMappingFruizioneSize = listaMappingFruizione != null ? listaMappingFruizione.size() : 0;
  14039.                         if(listaMappingFruizioneSize > 0) {
  14040.                             for (int i = 0; i < listaMappingFruizione.size(); i++) {
  14041.                                 MappingFruizionePortaDelegata mappingFruizionePortaDelegata = listaMappingFruizione.get(i);
  14042.                                 // colleziono le azioni gia' configurate
  14043.                                 PortaDelegata portaDelegataTmp = this.porteDelegateCore.getPortaDelegata(mappingFruizionePortaDelegata.getIdPortaDelegata());
  14044.                                 if(portaDelegataTmp.getAzione() != null && portaDelegataTmp.getAzione().getAzioneDelegataList() != null)
  14045.                                     azioniOccupate.addAll(portaDelegataTmp.getAzione().getAzioneDelegataList());
  14046.                             }
  14047.                         }
  14048.                        
  14049.                         azioni = new ArrayList<>();
  14050.                         for (int i = 0; i < azioniAll.size(); i++) {
  14051.                             String az = azioniAll.get(i);
  14052.                             if(azioniOccupate.contains(az)==false) {
  14053.                                 azioni.add(az);
  14054.                             }
  14055.                         }
  14056.                     }
  14057.                    
  14058.                     azioniConLabel = this.porteDelegateCore.getAzioniConLabel(asps, aspc, false, true, null);
  14059.                 }
  14060.                 else if(applicativa) {
  14061.                     IDPortaApplicativa idPA = new IDPortaApplicativa();
  14062.                     idPA.setNome(policy.getFiltro().getNomePorta());
  14063.                     PortaApplicativa pa = this.porteApplicativeCore.getPortaApplicativa(idPA);
  14064.                     MappingErogazionePortaApplicativa mappingPA = this.porteApplicativeCore.getMappingErogazionePortaApplicativa(pa);
  14065.                     IDServizio idServizio = mappingPA.getIdServizio();
  14066.                     AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idServizio,false);
  14067.                     AccordoServizioParteComuneSintetico aspc = this.apcCore.getAccordoServizioSintetico(this.idAccordoFactory.getIDAccordoFromUri(asps.getAccordoServizioParteComune()));
  14068.                    
  14069.                     if(pa.getAzione()!=null && pa.getAzione().sizeAzioneDelegataList()>0) {
  14070.                         azioni = pa.getAzione().getAzioneDelegataList();
  14071.                     }
  14072.                     else {
  14073.                         List<String> azioniAll = this.confCore.getAzioni(protocolloSelezionatoValue, protocolliValue,
  14074.                                 pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario(),
  14075.                                 pa.getServizio().getTipo(), pa.getServizio().getNome(), pa.getServizio().getVersione());
  14076.                        
  14077.                         List<MappingErogazionePortaApplicativa> listaMappingErogazione = this.apsCore.mappingServiziPorteAppList(idServizio, null);
  14078.                         List<String> azioniOccupate = new ArrayList<>();
  14079.                         int listaMappingErogazioneSize = listaMappingErogazione != null ? listaMappingErogazione.size() : 0;
  14080.                         if(listaMappingErogazioneSize > 0) {
  14081.                             for (int i = 0; i < listaMappingErogazione.size(); i++) {
  14082.                                 MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa = listaMappingErogazione.get(i);
  14083.                                 // colleziono le azioni gia' configurate
  14084.                                 PortaApplicativa portaApplicativaTmp = this.porteApplicativeCore.getPortaApplicativa(mappingErogazionePortaApplicativa.getIdPortaApplicativa());
  14085.                                 if(portaApplicativaTmp.getAzione() != null && portaApplicativaTmp.getAzione().getAzioneDelegataList() != null)
  14086.                                     azioniOccupate.addAll(portaApplicativaTmp.getAzione().getAzioneDelegataList());
  14087.                             }
  14088.                         }
  14089.                        
  14090.                         azioni = new ArrayList<>();
  14091.                         for (int i = 0; i < azioniAll.size(); i++) {
  14092.                             String az = azioniAll.get(i);
  14093.                             if(azioniOccupate.contains(az)==false) {
  14094.                                 azioni.add(az);
  14095.                             }
  14096.                         }
  14097.                     }
  14098.                    
  14099.                     azioniConLabel = this.porteApplicativeCore.getAzioniConLabel(asps, aspc, false, true, null);
  14100.                 }
  14101.                 else {
  14102.                     azioni = new ArrayList<>();
  14103.                 }
  14104.                 if(policy.getFiltro().getAzione()!=null && !"".equals(policy.getFiltro().getAzione())){
  14105.                     azioniSelezionataValue = new ArrayList<>();
  14106.                     if(policy.getFiltro().getAzione().contains(",")) {
  14107.                         String [] tmp = policy.getFiltro().getAzione().split(",");
  14108.                         for (String az : tmp) {
  14109.                             if(azioni.contains(az)){
  14110.                                 azioniSelezionataValue.add(az);
  14111.                             }
  14112.                         }
  14113.                     }
  14114.                     else {
  14115.                         if(azioni.contains(policy.getFiltro().getAzione())){
  14116.                             azioniSelezionataValue.add(policy.getFiltro().getAzione());
  14117.                         }
  14118.                     }
  14119.                 }
  14120.                 if(azioniSelezionataValue==null || azioniSelezionataValue.isEmpty()) {
  14121.                     azioniSelezionataValue = null;
  14122.                 }
  14123.                 if(azioniConLabel!=null && azioniConLabel.size()>0) {
  14124.                     azioniLabel = new ArrayList<>();
  14125.                     azioniValue = new ArrayList<>();

  14126.                     for (String idAzione : azioniConLabel.keySet()) {
  14127.                         if(azioni.contains(idAzione)) {
  14128.                             azioniValue.add(idAzione);
  14129.                             azioniLabel.add(azioniConLabel.get(idAzione));
  14130.                         }
  14131.                     }
  14132.                    
  14133. //                  azioniLabel = enrichListConLabelQualsiasi(azioniLabel);
  14134. //                  azioniValue = enrichListConValueQualsiasi(azioniValue);
  14135.                 }
  14136.                 else {
  14137. //                  azioniLabel = enrichListConLabelQualsiasi(azioni);
  14138. //                  azioniValue = enrichListConValueQualsiasi(azioni);
  14139.                     azioniLabel = azioni;
  14140.                     azioniValue = azioni;
  14141.                 }
  14142.             }
  14143.                
  14144.             // servizi applicativi erogatore
  14145.             if(configurazione) {
  14146.                 if(policy.getFiltro().getRuoloPorta()==null ||
  14147.                         RuoloPolicy.ENTRAMBI.equals(policy.getFiltro().getRuoloPorta()) ||
  14148.                         RuoloPolicy.APPLICATIVA.equals(policy.getFiltro().getRuoloPorta())){
  14149.                     if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  14150.                         if(policy.getFiltro().getServizioApplicativoErogatore()!=null){
  14151.                             servizioApplicativoErogatoreSelezionatoValue = policy.getFiltro().getServizioApplicativoErogatore();
  14152.                         }
  14153.                         servizioApplicativoErogatoreSelezionatoLabel = servizioApplicativoErogatoreSelezionatoValue!=null ? servizioApplicativoErogatoreSelezionatoValue :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  14154.                     }
  14155.                     else {
  14156.                         serviziApplicativiErogatoreLabel = new ArrayList<>();
  14157.                         serviziApplicativiErogatoreValue = new ArrayList<>();
  14158.                         if(datiIdentificativiErogatoreSelezionatoValue!=null) {
  14159.                             List<IDServizioApplicativo> listSA = this.confCore.getServiziApplicativiErogatori(protocolloSelezionatoValue, protocolliValue,
  14160.                                     policy.getFiltro().getTipoErogatore(), policy.getFiltro().getNomeErogatore(),
  14161.                                     policy.getFiltro().getTipoServizio(), policy.getFiltro().getNomeServizio(), policy.getFiltro().getVersioneServizio(),
  14162.                                     null);
  14163.                             for (IDServizioApplicativo idServizioApplicativo : listSA) {
  14164.                                 serviziApplicativiErogatoreLabel.add(idServizioApplicativo.getNome());
  14165.                                 serviziApplicativiErogatoreValue.add(idServizioApplicativo.getNome());
  14166.                             }
  14167.                         }
  14168.                        
  14169.                         if(policy.getFiltro().getServizioApplicativoErogatore()!=null){
  14170.                             servizioApplicativoErogatoreSelezionatoValue = policy.getFiltro().getServizioApplicativoErogatore();
  14171.                         }
  14172.                         if(!serviziApplicativiErogatoreValue.contains(servizioApplicativoErogatoreSelezionatoValue)){
  14173.                             policy.getFiltro().setServizioApplicativoErogatore(null);
  14174.                             servizioApplicativoErogatoreSelezionatoValue = null;
  14175.                         }
  14176.                         serviziApplicativiErogatoreLabel = enrichListConLabelQualsiasi(serviziApplicativiErogatoreLabel);
  14177.                         serviziApplicativiErogatoreValue = enrichListConValueQualsiasi(serviziApplicativiErogatoreValue);
  14178.                     }
  14179.                 }
  14180.             }
  14181.            
  14182.             // ruolo fruitore (diventa ruolo richiedente nel caso di porta)
  14183.             if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  14184.                 if(policy.getFiltro().getRuoloFruitore()!=null) {
  14185.                     ruoloFruitoreSelezionatoValue = policy.getFiltro().getRuoloFruitore();
  14186.                 }
  14187.                 ruoloFruitoreSelezionatoLabel = ruoloFruitoreSelezionatoValue!=null ? ruoloFruitoreSelezionatoValue :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  14188.             }
  14189.             else {
  14190.                 List<String> ruoliFruitore = this.core.getAllRuoli(filtroRuoli);
  14191.                 if(policy.getFiltro().getRuoloFruitore()!=null) {
  14192.                     ruoloFruitoreSelezionatoValue = policy.getFiltro().getRuoloFruitore();
  14193.                 }
  14194.                 if(!ruoliFruitore.contains(ruoloFruitoreSelezionatoValue)){
  14195.                     policy.getFiltro().setRuoloFruitore(null);
  14196.                     ruoloFruitoreSelezionatoValue = null;
  14197.                 }
  14198.                 ruoliFruitoreLabel = enrichListConLabelQualsiasi(ruoliFruitore);
  14199.                 ruoliFruitoreValue = enrichListConValueQualsiasi(ruoliFruitore);
  14200.             }
  14201.            
  14202.             // fruitore
  14203.             if(configurazione || applicativa) {
  14204.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  14205.                     IDSoggetto idSoggetto = null;
  14206.                     if(policy.getFiltro().getTipoFruitore()!=null && policy.getFiltro().getNomeFruitore()!=null){
  14207.                         datiIdentificativiFruitoreSelezionatoValue = policy.getFiltro().getTipoFruitore() + "/" + policy.getFiltro().getNomeFruitore();
  14208.                         idSoggetto = new IDSoggetto(policy.getFiltro().getTipoFruitore() , policy.getFiltro().getNomeFruitore());
  14209.                     }
  14210.                     datiIdentificativiFruitoreSelezionatoLabel = idSoggetto!=null ? this.getLabelNomeSoggetto(idSoggetto) :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  14211.                 }
  14212.                 else {
  14213. //                  List<IDSoggetto> listFruitori = this.confCore.getSoggettiFruitori(protocolloSelezionatoValue, protocolliValue,
  14214. //                          policy.getFiltro().getTipoErogatore(), policy.getFiltro().getNomeErogatore(),
  14215. //                          policy.getFiltro().getTipoServizio(), policy.getFiltro().getNomeServizio(), policy.getFiltro().getVersioneServizio());
  14216.                    
  14217.                     List<IDSoggetto> listSoggetti = new ArrayList<>();
  14218.                     if(configurazione) {
  14219.                         List<IDSoggetto> listSoggettiPreFilterMultitenant = this.confCore.getSoggetti(protocolloSelezionatoValue, protocolliValue);
  14220.                         if(policy.getFiltro().getRuoloPorta()!=null && !RuoloPolicy.ENTRAMBI.equals(policy.getFiltro().getRuoloPorta())) {
  14221.                             for (IDSoggetto idSoggetto : listSoggettiPreFilterMultitenant) {
  14222.                                 Soggetto s = this.soggettiCore.getSoggettoRegistro(idSoggetto);
  14223.                                 boolean isPddEsterna = this.pddCore.isPddEsterna(s.getPortaDominio());
  14224.                                 if(RuoloPolicy.APPLICATIVA.equals(policy.getFiltro().getRuoloPorta())) {
  14225.                                     if(isPddEsterna) {
  14226.                                         listSoggetti.add(idSoggetto);
  14227.                                     }  
  14228.                                     else {
  14229.                                         if(!PddTipologia.ESTERNO.equals(pddTipologiaSoggettoAutenticati)) {
  14230.                                             // multitenant abilitato
  14231.                                             listSoggetti.add(idSoggetto);
  14232.                                         }
  14233.                                     }
  14234.                                 }
  14235.                                 else {
  14236.                                     if(!isPddEsterna) {
  14237.                                         listSoggetti.add(idSoggetto);
  14238.                                     }
  14239.                                 }
  14240.                             }
  14241.                         }
  14242.                         else {
  14243.                             listSoggetti.addAll(listSoggettiPreFilterMultitenant);
  14244.                         }
  14245.                     }
  14246.                     else {
  14247.                    
  14248.                         User user = ServletUtils.getUserFromSession(this.request, this.session);
  14249.                         String userLogin = user.getLogin();
  14250.                        
  14251.                         List<String> tipiSoggettiGestitiProtocollo = this.soggettiCore.getTipiSoggettiGestitiProtocollo(protocolloSelezionatoValue);
  14252.                        
  14253.                         List<IDSoggettoDB> list = null;
  14254.                         if(this.core.isVisioneOggettiGlobale(userLogin)){
  14255.                             list = this.soggettiCore.getSoggettiFromTipoAutenticazione(tipiSoggettiGestitiProtocollo, null, tipoAutenticazione, appId, pddTipologiaSoggettoAutenticati);
  14256.                         }else{
  14257.                             list = this.soggettiCore.getSoggettiFromTipoAutenticazione(tipiSoggettiGestitiProtocollo, userLogin, tipoAutenticazione, appId, pddTipologiaSoggettoAutenticati);
  14258.                         }
  14259.                         if(list!=null && !list.isEmpty() && gestioneErogatori_soggettiAutenticati_escludiSoggettoErogatore) {
  14260.                             for (int i = 0; i < list.size(); i++) {
  14261.                                 IDSoggettoDB soggettoCheck = list.get(i);
  14262.                                 if(soggettoCheck.getTipo().equals(idSoggettoProprietario.getTipo()) && soggettoCheck.getNome().equals(idSoggettoProprietario.getNome())) {
  14263.                                     list.remove(i);
  14264.                                     break;
  14265.                                 }
  14266.                             }
  14267.                         }
  14268.                        
  14269.                         if(list==null) {
  14270.                             list = new ArrayList<>();
  14271.                         }
  14272.                        
  14273.                         // soggetti esterni
  14274.                         boolean isSupportatoAutenticazioneApplicativiEsterni = false;
  14275.                         if(protocolloSelezionatoValue!=null && !"".equals(protocolloSelezionatoValue)) {
  14276.                             isSupportatoAutenticazioneApplicativiEsterni = this.saCore.isSupportatoAutenticazioneApplicativiEsterniErogazione(protocolloSelezionatoValue);
  14277.                         }
  14278.                        
  14279.                         // multitenant: aggiungo soggetti operativi per poi poter selezionare un applicativo
  14280.                         // isSupportatoAutenticazioneApplicativiEsterni: aggiungo i soggettti che possiedono applicativi esterno
  14281.                         if(isSupportatoAutenticazioneApplicativiEsterni || multitenant) {
  14282.                             List<IDSoggetto> listSoggettiPreFilterMultitenant = this.confCore.getSoggetti(protocolloSelezionatoValue, protocolliValue);
  14283.                             for (IDSoggetto idSoggetto : listSoggettiPreFilterMultitenant) {
  14284.                                 Soggetto s = this.soggettiCore.getSoggettoRegistro(idSoggetto);
  14285.                                 boolean isPddEsterna = this.pddCore.isPddEsterna(s.getPortaDominio());
  14286.                                
  14287.                                 boolean found = false;
  14288.                                 if( (multitenant && !isPddEsterna)
  14289.                                         ||
  14290.                                     (isSupportatoAutenticazioneApplicativiEsterni && isPddEsterna)) {
  14291.                                     for (IDSoggettoDB sogg : list) {
  14292.                                         if(sogg.getTipo().equals(s.getTipo()) && sogg.getNome().equals(s.getNome())) {
  14293.                                             found = true;
  14294.                                             break;
  14295.                                         }
  14296.                                     }                                  
  14297.                                 }
  14298.                                
  14299.                                 boolean bothSslAndToken = false;
  14300.                                
  14301.                                 if(!found && multitenant && !isPddEsterna) {
  14302.                                     List<IDServizioApplicativoDB> listServiziApplicativiTmp = this.saCore.soggettiServizioApplicativoList(idSoggetto,userLogin,tipoAutenticazioneConfig, appId,
  14303.                                             CostantiConfigurazione.CLIENT,
  14304.                                             bothSslAndToken, tokenPolicy, tokenPolicyOR);
  14305.                                     if(listServiziApplicativiTmp!=null && !listServiziApplicativiTmp.isEmpty()) {
  14306.                                         IDSoggettoDB idSoggettoDB = new IDSoggettoDB();
  14307.                                         idSoggettoDB.setTipo(s.getTipo());
  14308.                                         idSoggettoDB.setNome(s.getNome());
  14309.                                         idSoggettoDB.setCodicePorta(s.getIdentificativoPorta());
  14310.                                         idSoggettoDB.setId(s.getId());
  14311.                                         list.add(idSoggettoDB);
  14312.                                     }
  14313.                                 }
  14314.                                
  14315.                                 if(!found && isSupportatoAutenticazioneApplicativiEsterni && isPddEsterna) {
  14316.                                     List<IDServizioApplicativoDB> listServiziApplicativiTmp = this.saCore.soggettiServizioApplicativoList(idSoggetto,userLogin,tipoAutenticazioneConfig, appId,
  14317.                                             CostantiConfigurazione.CLIENT,
  14318.                                             bothSslAndToken, tokenPolicy, tokenPolicyOR);
  14319.                                     if(listServiziApplicativiTmp!=null && !listServiziApplicativiTmp.isEmpty()) {
  14320.                                         IDSoggettoDB idSoggettoDB = new IDSoggettoDB();
  14321.                                         idSoggettoDB.setTipo(s.getTipo());
  14322.                                         idSoggettoDB.setNome(s.getNome());
  14323.                                         idSoggettoDB.setCodicePorta(s.getIdentificativoPorta());
  14324.                                         idSoggettoDB.setId(s.getId());
  14325.                                         list.add(idSoggettoDB);
  14326.                                     }
  14327.                                 }
  14328.                             }
  14329.                         }
  14330.                        
  14331.                         if(!list.isEmpty()) {
  14332.                             for (IDSoggettoDB soggetto : list) {
  14333.                                 listSoggetti.add(new IDSoggetto(soggetto.getTipo(), soggetto.getNome()));
  14334.                             }
  14335.                         }
  14336.                        
  14337.                     }
  14338.                    
  14339.                     fruitoriLabel = new ArrayList<>();
  14340.                     fruitoriValue = new ArrayList<>();
  14341.                     for (IDSoggetto idSoggetto : listSoggetti) {
  14342.                         fruitoriLabel.add(this.getLabelNomeSoggetto(idSoggetto));
  14343.                         fruitoriValue.add(idSoggetto.getTipo()+"/"+idSoggetto.getNome());
  14344.                     }
  14345.                     if(policy.getFiltro().getTipoFruitore()!=null && policy.getFiltro().getNomeFruitore()!=null){
  14346.                         datiIdentificativiFruitoreSelezionatoValue = policy.getFiltro().getTipoFruitore() + "/" + policy.getFiltro().getNomeFruitore();
  14347.                     }
  14348.                     if(!fruitoriValue.contains(datiIdentificativiFruitoreSelezionatoValue)){
  14349.                         policy.getFiltro().setTipoFruitore(null);
  14350.                         policy.getFiltro().setNomeFruitore(null);
  14351.                         datiIdentificativiFruitoreSelezionatoValue = null;
  14352.                     }
  14353.                     fruitoriLabel = enrichListConLabelQualsiasi(fruitoriLabel);
  14354.                     fruitoriValue = enrichListConValueQualsiasi(fruitoriValue);
  14355.                 }
  14356.             }
  14357.             else {
  14358.                 if(delegata) {
  14359.                     if(policy.getFiltro().getTipoFruitore()!=null && policy.getFiltro().getNomeFruitore()!=null){
  14360.                         datiIdentificativiFruitoreSelezionatoValue = policy.getFiltro().getTipoFruitore() + "/" + policy.getFiltro().getNomeFruitore();
  14361.                     }
  14362.                 }
  14363.             }
  14364.            
  14365.             // servizi applicativi fruitore
  14366.             if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  14367.                 if(policy.getFiltro().getServizioApplicativoFruitore()!=null){
  14368.                     servizioApplicativoFruitoreSelezionatoValue = policy.getFiltro().getServizioApplicativoFruitore();
  14369.                 }
  14370.                 servizioApplicativoFruitoreSelezionatoLabel = servizioApplicativoFruitoreSelezionatoValue!=null ? servizioApplicativoFruitoreSelezionatoValue :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  14371.             }
  14372.             else {
  14373.                
  14374.                 IDSoggetto soggettoProprietarioServiziApplicativi = null;
  14375.                 if(datiIdentificativiFruitoreSelezionatoValue!=null || !configurazione) {
  14376.                     String tipoFruitore = null;
  14377.                     String nomeFruitore = null;
  14378.                     if(datiIdentificativiFruitoreSelezionatoValue!=null) {
  14379.                         tipoFruitore = policy.getFiltro().getTipoFruitore();
  14380.                         nomeFruitore = policy.getFiltro().getNomeFruitore();
  14381.                     }
  14382.                     else {
  14383.                         tipoFruitore = idSoggettoProprietario.getTipo();
  14384.                         nomeFruitore = idSoggettoProprietario.getNome();
  14385.                     }
  14386.                     soggettoProprietarioServiziApplicativi = new IDSoggetto(tipoFruitore, nomeFruitore);
  14387.                 }
  14388.                
  14389.                 if(soggettoProprietarioServiziApplicativi!=null) {
  14390.                     serviziApplicativiFruitoreLabel = new ArrayList<>();
  14391.                     serviziApplicativiFruitoreValue = new ArrayList<>();

  14392.                     List<IDServizioApplicativo> listSA =null;
  14393.                     if(configurazione) {
  14394.                         listSA = this.confCore.getServiziApplicativiFruitore(protocolloSelezionatoValue, protocolliValue,
  14395.                                 soggettoProprietarioServiziApplicativi.getTipo(), soggettoProprietarioServiziApplicativi.getNome());
  14396.                     }
  14397.                     else {
  14398.                        
  14399.                         listSA = new ArrayList<>();
  14400.                        
  14401.                         User user = ServletUtils.getUserFromSession(this.request, this.session);
  14402.                         String userLogin = user.getLogin();
  14403.                        
  14404.                         // soggetti esterni
  14405.                         boolean isSupportatoAutenticazioneApplicativiEsterni = false;
  14406.                         if(protocolloSelezionatoValue!=null && !"".equals(protocolloSelezionatoValue)) {
  14407.                             isSupportatoAutenticazioneApplicativiEsterni = this.saCore.isSupportatoAutenticazioneApplicativiEsterniErogazione(protocolloSelezionatoValue);
  14408.                         }
  14409.                        
  14410.                         boolean bothSslAndToken = false;
  14411.                                                
  14412.                         List<IDServizioApplicativoDB> listServiziApplicativiTmp = null;
  14413.                         if(delegata || !multitenant) {
  14414.                             listServiziApplicativiTmp = this.saCore.soggettiServizioApplicativoList(idSoggettoProprietario,userLogin,tipoAutenticazioneConfig,appId,
  14415.                                     CostantiConfigurazione.CLIENT,
  14416.                                     bothSslAndToken, tokenPolicy, tokenPolicyOR);
  14417.                         }
  14418.                         else {
  14419.                             // sull'applicativa con multitenant deve essere stata selezionato un soggetto operativo.
  14420.                             if(policy.getFiltro().getTipoFruitore()!=null && policy.getFiltro().getNomeFruitore()!=null) {
  14421.                                 IDSoggetto idSoggettoSelezionato = new IDSoggetto(policy.getFiltro().getTipoFruitore(), policy.getFiltro().getNomeFruitore());
  14422.                                 Soggetto s = this.soggettiCore.getSoggettoRegistro(idSoggettoSelezionato);
  14423.                                 boolean isPddEsterna = this.pddCore.isPddEsterna(s.getPortaDominio());
  14424.                                 if(!isPddEsterna || isSupportatoAutenticazioneApplicativiEsterni) {
  14425.                                     listServiziApplicativiTmp = this.saCore.soggettiServizioApplicativoList(idSoggettoSelezionato,userLogin,tipoAutenticazioneConfig,appId,
  14426.                                             CostantiConfigurazione.CLIENT,
  14427.                                             bothSslAndToken, tokenPolicy, tokenPolicyOR);
  14428.                                 }                          
  14429.                             }
  14430.                         }
  14431.                        
  14432.                         if(listServiziApplicativiTmp!=null && !listServiziApplicativiTmp.isEmpty()) {
  14433.                             for (IDServizioApplicativoDB servizioApplicativo : listServiziApplicativiTmp) {
  14434.                                 IDServizioApplicativo idSA = new IDServizioApplicativo();
  14435.                                 idSA.setIdSoggettoProprietario(idSoggettoProprietario);
  14436.                                 idSA.setNome(servizioApplicativo.getNome());
  14437.                                 listSA.add(idSA);
  14438.                             }
  14439.                         }
  14440.                        
  14441.                     }
  14442.                     for (IDServizioApplicativo idServizioApplicativo : listSA) {
  14443.                         serviziApplicativiFruitoreLabel.add(idServizioApplicativo.getNome());
  14444.                         serviziApplicativiFruitoreValue.add(idServizioApplicativo.getNome());
  14445.                     }
  14446.                    
  14447.                     if(policy.getFiltro().getServizioApplicativoFruitore()!=null){
  14448.                         servizioApplicativoFruitoreSelezionatoValue = policy.getFiltro().getServizioApplicativoFruitore();
  14449.                     }
  14450.                     if(!serviziApplicativiFruitoreValue.contains(servizioApplicativoFruitoreSelezionatoValue)){
  14451.                         policy.getFiltro().setServizioApplicativoFruitore(null);
  14452.                         servizioApplicativoFruitoreSelezionatoValue = null;
  14453.                     }
  14454.                     serviziApplicativiFruitoreLabel = enrichListConLabelQualsiasi(serviziApplicativiFruitoreLabel);
  14455.                     serviziApplicativiFruitoreValue = enrichListConValueQualsiasi(serviziApplicativiFruitoreValue);
  14456.                 }
  14457.             }
  14458.            
  14459.             tokenClaims = policy.getFiltro().getTokenClaims();
  14460.            
  14461.             // filtro by key se non sono richiesti campionamenti statistici
  14462.             // NON è vero. Il filtro ci può sempre essere
  14463.             //if(infoPolicy!=null && infoPolicy.isUtilizzoRisorseStatistiche()==false){
  14464.             if(infoPolicy!=null){
  14465.                 filtroByKey = true;
  14466.             }
  14467.         }

  14468.        
  14469.        
  14470.        
  14471.         DataElement de = new DataElement();
  14472.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILTRO);
  14473.         de.setType(DataElementType.TITLE);
  14474.         dati.add(de);
  14475.        
  14476.         boolean filtroAbilitatoAPI = false;
  14477.         if(ruoloPorta!=null) {
  14478.             boolean first = this.isFirstTimeFromHttpParameters(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_FIRST_TIME);
  14479.             if(first) {
  14480.                 String filtro = this.toStringCompactFilter(policy.getFiltro(),ruoloPorta,nomePorta,serviceBinding);
  14481.                 filtroAbilitatoAPI = filtro!=null && !"".equals(filtro) && !CostantiControlStation.LABEL_STATO_DISABILITATO.equals(filtro);
  14482.             }
  14483.             else {
  14484.                 String filtro = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_ENABLED_CONSOLE_ONLY);
  14485.                 filtroAbilitatoAPI = ServletUtils.isCheckBoxEnabled(filtro);
  14486.             }
  14487.         }
  14488.        
  14489.         // stato
  14490.         if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  14491.            
  14492.             addToDatiDataElementStatoReadOnly(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_ENABLED,
  14493.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_ENABLED, policy.getFiltro().isEnabled(), true,
  14494.                     false, false);
  14495.            
  14496.             if(policy.getFiltro().isEnabled()){
  14497.                 de = new DataElement();
  14498.                 de.setType(DataElementType.NOTE);
  14499.                 de.setValue("Filtro non modificabile poichè definito per un "+CostantiControlStation.LABEL_PARAMETRO_PROTOCOLLO_DI.toLowerCase()+" non attivo nella console");
  14500.                 dati.add(de);
  14501.             }
  14502.         }
  14503.         else {
  14504.             boolean hidden = ruoloPorta!=null;
  14505.             addToDatiDataElementStato_postBackViaPOST(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_ENABLED,
  14506.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_ENABLED, policy.getFiltro().isEnabled(), true,
  14507.                     false, false, hidden);
  14508.            
  14509.             if(ruoloPorta!=null) {
  14510.                 addToDatiDataElementStato_postBackViaPOST(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_ENABLED_CONSOLE_ONLY,
  14511.                         ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_ENABLED, filtroAbilitatoAPI, true,
  14512.                         false, false, false);
  14513.             }
  14514.            
  14515.         }
  14516.        
  14517.         boolean filtroEnabled = policy.getFiltro().isEnabled();
  14518.         if(ruoloPorta!=null) {
  14519.             filtroEnabled = filtroAbilitatoAPI;
  14520.         }
  14521.        
  14522.         if(!filtroEnabled && ruoloPorta!=null) {
  14523.             // Protocollo
  14524.             de = new DataElement();
  14525.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO);
  14526.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO);
  14527.             de.setValue(protocolloSelezionatoValue); // un protocollo e' sempre selezionato
  14528.             de.setType(DataElementType.HIDDEN);
  14529.             dati.add(de);
  14530.         }
  14531.        
  14532.         if(filtroEnabled){
  14533.        
  14534.             // Ruolo PdD
  14535.             de = new DataElement();
  14536.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_PDD);
  14537.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_PDD);
  14538.             if(policy.getFiltro().getRuoloPorta()!=null){
  14539.                 de.setValue(policy.getFiltro().getRuoloPorta().getValue());
  14540.             }
  14541.             if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  14542.                 de.setType(DataElementType.HIDDEN);
  14543.                 dati.add(de);
  14544.                
  14545.                 if(configurazione) {
  14546.                     de = new DataElement();
  14547.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_PDD+"___LABEL");
  14548.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_PDD);
  14549.                     if(policy.getFiltro().getRuoloPorta()!=null){
  14550.                         de.setValue(policy.getFiltro().getRuoloPorta().getValue());
  14551.                     }
  14552.                     else {
  14553.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI);
  14554.                     }
  14555.                     de.setType(DataElementType.TEXT);
  14556.                 }
  14557.             }
  14558.             else {
  14559.                 de.setValues(ConfigurazioneCostanti.TIPI_RUOLO_PDD);
  14560.                 de.setLabels(ConfigurazioneCostanti.LABEL_TIPI_RUOLO_PDD);
  14561.                 if(policy.getFiltro().getRuoloPorta()!=null){
  14562.                     de.setSelected(policy.getFiltro().getRuoloPorta().getValue());
  14563.                 }
  14564.                 de.setType(DataElementType.SELECT);
  14565.                 de.setPostBack_viaPOST(true);
  14566.             }
  14567.             dati.add(de);
  14568.            
  14569.    
  14570.             // Protocollo
  14571.             de = new DataElement();
  14572.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO);
  14573.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO);
  14574.             de.setValue(protocolloSelezionatoValue); // un protocollo e' sempre selezionato
  14575.             if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  14576.                 de.setType(DataElementType.HIDDEN);
  14577.                 dati.add(de);
  14578.                
  14579.                 if(configurazione) {
  14580.                     de = new DataElement();
  14581.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO+"___LABEL");
  14582.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO);
  14583.                     de.setValue(protocolloSelezionatoLabel); // un protocollo e' sempre selezionato
  14584.                     de.setType(DataElementType.TEXT);
  14585.                 }
  14586.             }
  14587.             else if(protocolliValue!=null && protocolliValue.size()>1){
  14588.                 de.setValues(protocolliValue);
  14589.                 de.setLabels(protocolliLabel);
  14590.                 de.setSelected(protocolloSelezionatoValue);
  14591.                 de.setType(DataElementType.SELECT);
  14592.                 de.setPostBack_viaPOST(true);
  14593.             }
  14594.             else{
  14595.                 de.setType(DataElementType.HIDDEN);
  14596.                 if(protocolliValue!=null && protocolliValue.size()>0) {
  14597.                     dati.add(de);
  14598.                    
  14599.                     // Si è deciso cmq di farlo vedere
  14600.                     de = new DataElement();
  14601.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO+"___LABEL");
  14602.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO);
  14603.                     de.setValue(this.getLabelProtocollo(protocolliValue.get(0))); // un protocollo e' sempre selezionato
  14604.                     de.setType(DataElementType.TEXT);
  14605.                 }
  14606.             }
  14607.             dati.add(de);
  14608.            
  14609.             // Ruolo Erogatore
  14610.             de = new DataElement();
  14611.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_EROGATORE);
  14612.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_EROGATORE);
  14613.             if(datiIdentificativiErogatoreSelezionatoValue!=null) {
  14614.                 de.setType(DataElementType.HIDDEN);
  14615.             }
  14616.             else {
  14617.                 de.setValue(ruoloErogatoreSelezionatoValue);
  14618.                 if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  14619.                     de.setType(DataElementType.HIDDEN);
  14620.                     dati.add(de);
  14621.                    
  14622.                     if(configurazione) {
  14623.                         de = new DataElement();
  14624.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_EROGATORE+"___LABEL");
  14625.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_EROGATORE);
  14626.                         de.setValue(ruoloErogatoreSelezionatoLabel);
  14627.                         de.setType(DataElementType.TEXT);
  14628.                     }
  14629.                 }
  14630.                 else {
  14631.                     de.setLabels(ruoliErogatoreLabel);
  14632.                     de.setValues(ruoliErogatoreValue);
  14633.                     de.setSelected(ruoloErogatoreSelezionatoValue);
  14634.                     de.setType(DataElementType.SELECT);
  14635.                     de.setPostBack_viaPOST(true);
  14636.                 }
  14637.             }
  14638.             dati.add(de);
  14639.            
  14640.             // Erogatore
  14641.             de = new DataElement();
  14642.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_EROGATORE);
  14643.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_EROGATORE);
  14644.             if(ruoloErogatoreSelezionatoValue!=null) {
  14645.                 de.setType(DataElementType.HIDDEN);
  14646.             }
  14647.             else {
  14648.                 de.setValue(datiIdentificativiErogatoreSelezionatoValue);
  14649.                 if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  14650.                     de.setType(DataElementType.HIDDEN);
  14651.                     dati.add(de);
  14652.                    
  14653.                     if(configurazione) {
  14654.                         de = new DataElement();
  14655.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_EROGATORE+"___LABEL");
  14656.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_EROGATORE);
  14657.                         de.setValue(datiIdentificativiErogatoreSelezionatoLabel);
  14658.                         de.setType(DataElementType.TEXT);
  14659.                     }
  14660.                 }
  14661.                 else {
  14662.                     de.setLabels(erogatoriLabel);
  14663.                     de.setValues(erogatoriValue);
  14664.                     de.setSelected(datiIdentificativiErogatoreSelezionatoValue);
  14665.                     de.setType(DataElementType.SELECT);
  14666.                     de.setPostBack_viaPOST(true);
  14667.                 }
  14668.             }
  14669.             dati.add(de);
  14670.            
  14671.             // Tag
  14672.             de = new DataElement();
  14673.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TAG);
  14674.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TAG);
  14675.             de.setValue(datiIdentificativiTagSelezionatoValue);
  14676.             if(!configurazione) {
  14677.                 de.setType(DataElementType.HIDDEN);
  14678.                 dati.add(de);
  14679.             }
  14680.             else {
  14681.                 de.setValue(datiIdentificativiTagSelezionatoValue);
  14682.                 if(this.core.isControlloTrafficoPolicyGlobaleFiltroApi() && datiIdentificativiServizioSelezionatoValue==null ) {
  14683.                     de.setLabels(tagLabel);
  14684.                     de.setValues(tagValue);
  14685.                     de.setSelected(datiIdentificativiTagSelezionatoValue);
  14686.                     de.setType(DataElementType.SELECT);
  14687.                     de.setPostBack_viaPOST(true);
  14688.                 }
  14689.                 else {
  14690.                     de.setType(DataElementType.HIDDEN);
  14691.                 }
  14692.             }
  14693.             dati.add(de);
  14694.            
  14695.             // Servizio
  14696.             de = new DataElement();
  14697.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SERVIZIO);
  14698.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SERVIZIO);
  14699.             de.setValue(datiIdentificativiServizioSelezionatoValue);
  14700.             if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  14701.                 de.setType(DataElementType.HIDDEN);
  14702.                 dati.add(de);
  14703.                
  14704.                 if(configurazione) {
  14705.                     de = new DataElement();
  14706.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SERVIZIO+"___LABEL");
  14707.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SERVIZIO);
  14708.                     de.setValue(datiIdentificativiServizioSelezionatoLabel);
  14709.                     if(this.core.isControlloTrafficoPolicyGlobaleFiltroApi()) {
  14710.                         de.setType(DataElementType.TEXT);
  14711.                     }
  14712.                     else {
  14713.                         de.setType(DataElementType.HIDDEN);
  14714.                     }
  14715.                 }
  14716.             }
  14717.             else {
  14718.                 de.setValue(datiIdentificativiServizioSelezionatoValue);
  14719.                 if(this.core.isControlloTrafficoPolicyGlobaleFiltroApi()) {
  14720.                     de.setLabels(serviziLabel);
  14721.                     de.setValues(serviziValue);
  14722.                     de.setSelected(datiIdentificativiServizioSelezionatoValue);
  14723.                     de.setType(DataElementType.SELECT);
  14724.                     de.setPostBack_viaPOST(true);
  14725.                 }
  14726.                 else {
  14727.                     de.setType(DataElementType.HIDDEN);
  14728.                 }
  14729.             }
  14730.             dati.add(de);
  14731.            
  14732.             // Azione
  14733.             boolean showAzione = true;
  14734.             if(configurazione) {
  14735.                 if(datiIdentificativiServizioSelezionatoValue==null) {
  14736.                     showAzione = false;
  14737.                 }
  14738.             }
  14739.             if(showAzione) {
  14740.                
  14741.                 boolean azioniAll = false;
  14742.                 boolean first = this.isFirstTimeFromHttpParameters(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_FIRST_TIME);
  14743.                 if(first) {
  14744.                     azioniAll = azioniSelezionataValue==null || azioniSelezionataValue.isEmpty();
  14745.                 }
  14746.                 else if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SERVIZIO.equals(this.getPostBackElementName()) ||
  14747.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_ENABLED_CONSOLE_ONLY.equals(this.getPostBackElementName())) {
  14748.                     azioniAll = true;
  14749.                 }
  14750.                 else {
  14751.                     String azioniAllPart = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE_PUNTUALE);
  14752.                     azioniAll = ServletUtils.isCheckBoxEnabled(azioniAllPart);
  14753.                 }
  14754.                
  14755.                 if(!protocolloAssociatoFiltroNonSelezionatoUtente) {
  14756.                     de = new DataElement();
  14757.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE_PUNTUALE);
  14758.                     de.setPostBack_viaPOST(true);
  14759.                     de.setValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE_PUNTUALE_ALL_VALUES);
  14760.                     if(ServiceBinding.REST.equals(serviceBinding)) {
  14761.                         de.setLabels(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE_PUNTUALE_RISORSE_ALL_VALUES);
  14762.                     }
  14763.                     else {
  14764.                         de.setLabels(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE_PUNTUALE_ALL_VALUES);
  14765.                     }
  14766.                     if(azioniAll) {
  14767.                         de.setSelected(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE_PUNTUALE_ALL_VALUE_TRUE);
  14768.                     }
  14769.                     else {
  14770.                         de.setSelected(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE_PUNTUALE_ALL_VALUE_FALSE);
  14771.                     }
  14772.                     if(serviceBinding!=null) {
  14773.                         de.setLabel(this.getLabelAzioni(serviceBinding));
  14774.                     }
  14775.                     else {
  14776.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE);
  14777.                     }
  14778.                     de.setType(DataElementType.SELECT);
  14779.                     dati.add(de);
  14780.                 }
  14781.                
  14782.                 de = new DataElement();
  14783.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE);
  14784.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  14785.                     if(serviceBinding!=null) {
  14786.                         de.setLabel(this.getLabelAzioni(serviceBinding));
  14787.                     }
  14788.                     else {
  14789.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE);
  14790.                     }
  14791.                 }
  14792.                 else {
  14793.                     de.setLabel("");
  14794.                 }
  14795.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  14796.                     de.setValue(policy.getFiltro().getAzione());
  14797.                     de.setType(DataElementType.HIDDEN);
  14798.                     dati.add(de);
  14799.                    
  14800.                     de = new DataElement();
  14801.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE+"___LABEL");
  14802.                     if(serviceBinding!=null) {
  14803.                         de.setLabel(this.getLabelAzioni(serviceBinding));
  14804.                     }
  14805.                     else {
  14806.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE);
  14807.                     }
  14808.                     if(azioniSelezionataLabel!=null && !azioniSelezionataLabel.isEmpty()) {
  14809.                         if(azioniSelezionataLabel.size()==1) {
  14810.                             de.setValue(azioniSelezionataLabel.get(0));
  14811.                         }
  14812.                         else {
  14813.                             de.setValue(azioniSelezionataLabel.toString());
  14814.                         }
  14815.                     }
  14816.                     de.setType(DataElementType.TEXT);
  14817.                 }
  14818.                 else {
  14819.                     if(!azioniAll) {
  14820.                         de.setLabels(azioniLabel);
  14821.                         de.setValues(azioniValue);
  14822.                         de.setSelezionati(azioniSelezionataValue);
  14823.                         de.setType(DataElementType.MULTI_SELECT);
  14824.                         if(azioniValue!=null && azioniValue.size()<=10) {
  14825.                             if(azioniValue.size()<=3) {
  14826.                                 de.setRows(3);
  14827.                             }
  14828.                             else {
  14829.                                 de.setRows(azioniValue.size());
  14830.                             }
  14831.                         }
  14832.                         else {
  14833.                             de.setRows(10);
  14834.                         }
  14835.                         de.setPostBack_viaPOST(true);
  14836.                     }
  14837.                     else {
  14838.                         de.setType(DataElementType.HIDDEN);
  14839.                     }
  14840.                 }
  14841.                 dati.add(de);
  14842.             }
  14843.            
  14844.             // Servizio Applicativo Erogatore
  14845.             if(serviziApplicativiErogatoreValue!=null){
  14846.                 de = new DataElement();
  14847.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_EROGATORE);
  14848.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_EROGATORE);
  14849.                 de.setValue(servizioApplicativoErogatoreSelezionatoValue);
  14850.                 if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  14851.                     de.setType(DataElementType.HIDDEN);
  14852.                     dati.add(de);
  14853.                    
  14854.                     if(configurazione) {
  14855.                         de = new DataElement();
  14856.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_EROGATORE+"___LABEL");
  14857.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_EROGATORE);
  14858.                         de.setValue(servizioApplicativoErogatoreSelezionatoLabel);
  14859.                         //de.setType(DataElementType.TEXT);
  14860.                         de.setType(DataElementType.HIDDEN);
  14861.                     }
  14862.                 }
  14863.                 else {
  14864.                     de.setLabels(serviziApplicativiErogatoreLabel);
  14865.                     de.setValues(serviziApplicativiErogatoreValue);
  14866.                     de.setSelected(servizioApplicativoErogatoreSelezionatoValue);
  14867.                     de.setValue(servizioApplicativoErogatoreSelezionatoValue);
  14868.                     //de.setType(DataElementType.SELECT);
  14869.                     de.setType(DataElementType.HIDDEN);
  14870.                     de.setPostBack_viaPOST(true);
  14871.                 }
  14872.                 dati.add(de);
  14873.             }
  14874.            
  14875.             // Ruolo Fruitore
  14876.             boolean showRuoloRichiedente = false;
  14877.             if(configurazione) {
  14878.                 showRuoloRichiedente = true;
  14879.                 if(infoPolicy!=null && TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(infoPolicy.getTipoRisorsa())) {
  14880.                     showRuoloRichiedente=false;
  14881.                 }
  14882.             }
  14883.             else {
  14884.                 if(infoPolicy!=null && TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(infoPolicy.getTipoRisorsa())) {
  14885.                     showRuoloRichiedente=false;
  14886.                 }
  14887.                 else if(serviziApplicativiFruitoreValue!=null && serviziApplicativiFruitoreValue.size()>1){
  14888.                     showRuoloRichiedente = true;
  14889.                 }
  14890.                 else if(fruitoriValue!=null && fruitoriValue.size()>1){
  14891.                     showRuoloRichiedente = true;
  14892.                 }
  14893.             }
  14894.             de = new DataElement();
  14895.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_FRUITORE);
  14896. //          if(configurazione) {
  14897. //              de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_FRUITORE);
  14898. //          }
  14899. //          else {
  14900.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_RICHIEDENTE);
  14901.             //}
  14902.             if((datiIdentificativiFruitoreSelezionatoValue!=null && !delegata) || servizioApplicativoFruitoreSelezionatoValue!=null || !showRuoloRichiedente) {
  14903.                 de.setType(DataElementType.HIDDEN);
  14904.             }
  14905.             else {
  14906.                 de.setValue(ruoloFruitoreSelezionatoValue);
  14907.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  14908.                     de.setType(DataElementType.HIDDEN);
  14909.                     dati.add(de);
  14910.                    
  14911.                     if(configurazione) {
  14912.                         de = new DataElement();
  14913.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_FRUITORE+"___LABEL");
  14914. //                      if(configurazione) {
  14915. //                          de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_FRUITORE);
  14916. //                      }
  14917. //                      else {
  14918.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_RICHIEDENTE);
  14919.                         //}
  14920.                         de.setValue(ruoloFruitoreSelezionatoLabel);
  14921.                         de.setType(DataElementType.TEXT);
  14922.                     }
  14923.                 }
  14924.                 else {
  14925.                     de.setLabels(ruoliFruitoreLabel);
  14926.                     de.setValues(ruoliFruitoreValue);
  14927.                     de.setSelected(ruoloFruitoreSelezionatoValue);
  14928.                     de.setType(DataElementType.SELECT);
  14929.                     de.setPostBack_viaPOST(true);
  14930.                 }
  14931.             }
  14932.             dati.add(de);
  14933.            
  14934.             // Fruitore
  14935.             if(fruitoriValue!=null && fruitoriValue.size()>1 &&
  14936.                     (infoPolicy==null || !TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(infoPolicy.getTipoRisorsa()))
  14937.                 ){
  14938.                 de = new DataElement();
  14939.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_FRUITORE);
  14940.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_FRUITORE);
  14941.                 if(ruoloFruitoreSelezionatoValue!=null) {
  14942.                     de.setType(DataElementType.HIDDEN);
  14943.                 }
  14944.                 else {
  14945.                     de.setValue(datiIdentificativiFruitoreSelezionatoValue);
  14946.                     if(protocolloAssociatoFiltroNonSelezionatoUtente || delegata) {
  14947.                         de.setType(DataElementType.HIDDEN);
  14948.                         dati.add(de);
  14949.                        
  14950.                         if(configurazione) {
  14951.                             de = new DataElement();
  14952.                             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_FRUITORE+"___LABEL");
  14953.                             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_FRUITORE);
  14954.                             de.setValue(datiIdentificativiFruitoreSelezionatoLabel);
  14955.                             de.setType(DataElementType.TEXT);
  14956.                         }
  14957.                     }
  14958.                     else {
  14959.                         de.setLabels(fruitoriLabel);
  14960.                         de.setValues(fruitoriValue);
  14961.                         de.setSelected(datiIdentificativiFruitoreSelezionatoValue);
  14962.                         de.setType(DataElementType.SELECT);
  14963.                         de.setPostBack_viaPOST(true);
  14964.                     }
  14965.                 }
  14966.                 dati.add(de);
  14967.             }
  14968.            
  14969.             // Servizio Applicativo Fruitore
  14970.             if(serviziApplicativiFruitoreValue!=null && serviziApplicativiFruitoreValue.size()>1 &&
  14971.                     (infoPolicy==null || !TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(infoPolicy.getTipoRisorsa()))
  14972.                 ){
  14973.                 de = new DataElement();
  14974.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE);
  14975.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE);
  14976.                 if(ruoloFruitoreSelezionatoValue!=null) {
  14977.                     de.setType(DataElementType.HIDDEN);
  14978.                 }
  14979.                 else {
  14980.                     de.setValue(servizioApplicativoFruitoreSelezionatoValue);
  14981.                     if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  14982.                         de.setType(DataElementType.HIDDEN);
  14983.                         dati.add(de);
  14984.                        
  14985.                         if(configurazione) {
  14986.                             de = new DataElement();
  14987.                             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE+"___LABEL");
  14988.                             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE);
  14989.                             de.setValue(servizioApplicativoFruitoreSelezionatoLabel);
  14990.                             de.setType(DataElementType.TEXT);
  14991.                         }
  14992.                     }
  14993.                     else {
  14994.                         de.setLabels(serviziApplicativiFruitoreLabel);
  14995.                         de.setValues(serviziApplicativiFruitoreValue);
  14996.                         de.setSelected(servizioApplicativoFruitoreSelezionatoValue);
  14997.                         de.setType(DataElementType.SELECT);
  14998.                         de.setPostBack_viaPOST(true);
  14999.                     }
  15000.                 }
  15001.                 dati.add(de);
  15002.             }
  15003.            
  15004.             if(tokenAbilitato) {
  15005.                 de = new DataElement();
  15006.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TOKEN_CLAIMS);
  15007.                 de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TOKEN_CLAIMS_NOTE);
  15008.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TOKEN_CLAIMS);
  15009.                 de.setValue(tokenClaims);
  15010.                 de.setType(DataElementType.TEXT_AREA);
  15011.                 de.setRows(6);
  15012.                 de.setCols(55);
  15013.                 dati.add(de);
  15014.             }
  15015.            
  15016.             if(filtroByKey){
  15017.                
  15018.                 // per chiave
  15019.                
  15020.                 if(policy.getFiltro().isInformazioneApplicativaEnabled()){
  15021.                     de = new DataElement();
  15022.                     de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED);
  15023.                     de.setType(DataElementType.NOTE);
  15024.                     dati.add(de);
  15025.                 }
  15026.                
  15027.                 de = new DataElement();
  15028.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED);
  15029.                 if(policy.getFiltro().isInformazioneApplicativaEnabled()){
  15030.                     de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO);
  15031.                 }
  15032.                 else{
  15033.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED_COMPACT);
  15034.                 }
  15035.                 de.setValue(policy.getFiltro().isInformazioneApplicativaEnabled()+"");
  15036.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  15037.                     de.setType(DataElementType.HIDDEN);
  15038.                     dati.add(de);
  15039.                    
  15040.                     de = new DataElement();
  15041.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED+"___LABEL");
  15042.                     if(policy.getFiltro().isInformazioneApplicativaEnabled()){
  15043.                         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO);
  15044.                     }
  15045.                     else{
  15046.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED);
  15047.                     }
  15048.                     if(policy.getFiltro().isInformazioneApplicativaEnabled()){
  15049.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  15050.                     }
  15051.                     else {
  15052.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  15053.                     }
  15054.                     de.setType(DataElementType.TEXT);
  15055.                 }
  15056.                 else {
  15057.                     de.setType(DataElementType.CHECKBOX);
  15058.                     de.setSelected(policy.getFiltro().isInformazioneApplicativaEnabled());
  15059.                     de.setPostBack_viaPOST(true);
  15060.                 }
  15061.                 dati.add(de);
  15062.                
  15063.                 if(policy.getFiltro().isInformazioneApplicativaEnabled()){
  15064.                    
  15065.                     TipoFiltroApplicativo tipoFiltro = null;
  15066.                     if(policy.getFiltro().getInformazioneApplicativaTipo()!=null && !"".equals(policy.getFiltro().getInformazioneApplicativaTipo())){
  15067.                         tipoFiltro = TipoFiltroApplicativo.toEnumConstant(policy.getFiltro().getInformazioneApplicativaTipo());
  15068.                     }
  15069.                     if(tipoFiltro==null){
  15070.                         tipoFiltro = TipoFiltroApplicativo.toEnumConstant(ConfigurazioneCostanti.CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO_DEFAULT);
  15071.                     }
  15072.                    
  15073.                     de = new DataElement();
  15074.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO);
  15075.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO);
  15076.                     de.setValue(policy.getFiltro().getInformazioneApplicativaTipo());
  15077.                     if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  15078.                         de.setType(DataElementType.HIDDEN);
  15079.                         dati.add(de);
  15080.                        
  15081.                         de = new DataElement();
  15082.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO+"___LABEL");
  15083.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO);
  15084.                         de.setValue(policy.getFiltro().getInformazioneApplicativaTipo());
  15085.                         de.setType(DataElementType.TEXT);
  15086.                     }
  15087.                     else {
  15088.                         if(infoPolicy!=null && TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(infoPolicy.getTipoRisorsa())){
  15089.                             String [] arr = TipoFiltroApplicativo.toStringArray();
  15090.                             List<String> values = new ArrayList<>();
  15091.                             for (String v : arr) {
  15092.                                 if(TipoFiltroApplicativo.CONTENT_BASED.equals(v)) {
  15093.                                     continue;
  15094.                                 }
  15095.                                 values.add(v);
  15096.                             }
  15097.                             de.setValues(values);
  15098.                             de.setLabels(ConfigurazioneCostanti.LABEL_RATE_LIMITING_FILTRO_APPLICATIVO_SENZA_CONTENUTO);
  15099.                         }
  15100.                         else {
  15101.                             de.setValues(TipoFiltroApplicativo.toStringArray());
  15102.                             de.setLabels(ConfigurazioneCostanti.LABEL_RATE_LIMITING_FILTRO_APPLICATIVO);
  15103.                         }
  15104.                         de.setSelected(policy.getFiltro().getInformazioneApplicativaTipo());
  15105.                         de.setType(DataElementType.SELECT);
  15106.                         de.setPostBack_viaPOST(true);
  15107.                     }
  15108.                     dati.add(de);
  15109.                    
  15110.                     if(TipoFiltroApplicativo.PLUGIN_BASED.equals(tipoFiltro)) {
  15111.                         this.addCustomField(TipoPlugin.RATE_LIMITING,
  15112.                                 null,
  15113.                                 null,
  15114.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO,
  15115.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_NOME,
  15116.                                 this.getLabelTipoInformazioneApplicativaFiltro(policy.getFiltro().getInformazioneApplicativaTipo()),
  15117.                                 policy.getFiltro().getInformazioneApplicativaNome(), false, dati,
  15118.                                 true);  
  15119.                     }
  15120.                     else {
  15121.                         de = new DataElement();
  15122.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_NOME);
  15123.                         de.setLabel(this.getLabelTipoInformazioneApplicativaFiltro(policy.getFiltro().getInformazioneApplicativaTipo()));
  15124.                         de.setValue(policy.getFiltro().getInformazioneApplicativaNome());
  15125.                         if(tipoFiltro==null ||
  15126.                                 TipoFiltroApplicativo.SOAPACTION_BASED.equals(tipoFiltro) ||
  15127.                                 TipoFiltroApplicativo.INDIRIZZO_IP.equals(tipoFiltro) ||
  15128.                                 TipoFiltroApplicativo.INDIRIZZO_IP_FORWARDED.equals(tipoFiltro)){
  15129.                             de.setType(DataElementType.HIDDEN);
  15130.                         }
  15131.                         else{
  15132.                             if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  15133.                                 de.setType(DataElementType.TEXT);
  15134.                             }
  15135.                             else {
  15136.                                 de.setRequired(true);
  15137.                                 if(TipoFiltroApplicativo.URLBASED.equals(tipoFiltro) ||
  15138.                                         TipoFiltroApplicativo.CONTENT_BASED.equals(tipoFiltro)) {
  15139.                                     de.setType(DataElementType.TEXT_AREA);
  15140.                                 }
  15141.                                 else {
  15142.                                     de.setType(DataElementType.TEXT_EDIT);
  15143.                                 }
  15144.                             }
  15145.                         }
  15146.                         dati.add(de);
  15147.                     }
  15148.                
  15149.                     de = new DataElement();
  15150.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_VALORE);
  15151.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_VALORE);
  15152.                     de.setValue(StringEscapeUtils.escapeHtml(policy.getFiltro().getInformazioneApplicativaValore())); // il valore può contenere ""
  15153.                     if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  15154.                         de.setType(DataElementType.HIDDEN);
  15155.                         dati.add(de);
  15156.                        
  15157.                         de = new DataElement();
  15158.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_VALORE+"___LABEL");
  15159.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_VALORE);
  15160.                         de.setValue(StringEscapeUtils.escapeHtml(policy.getFiltro().getInformazioneApplicativaValore())); // il valore può contenere ""
  15161.                         de.setType(DataElementType.TEXT);
  15162.                     }
  15163.                     else {
  15164.                         de.setRequired(true);
  15165.                         de.setType(DataElementType.TEXT_EDIT);
  15166.                     }
  15167.                     dati.add(de);
  15168.                    
  15169.                     // se sono richiesti campionamenti statistici
  15170.                     if(infoPolicy!=null && infoPolicy.isIntervalloUtilizzaRisorseStatistiche()){
  15171.                         de = new DataElement();
  15172.                         de.setType(DataElementType.NOTE);
  15173.                         de.setBold(true);
  15174.                         de.setLabel("Nota");
  15175.                         de.setValue("Il filtro per chiave, su campionamento statistico, serve solamente a filtrare l'applicabilità della policy.<BR/>Verranno conteggiate anche le richieste che non hanno un match con il filtro per chiave indicato.");
  15176.                         dati.add(de);
  15177.                     }
  15178.                 }
  15179.                
  15180.             }
  15181.            
  15182.         }
  15183.     }
  15184.    
  15185.     private void addToDatiAttivazioneGroupBy(List<DataElement> dati, TipoOperazione tipoOperazione,AttivazionePolicy policy, String nomeSezione,    
  15186.             InfoPolicy infoPolicy, RuoloPolicy ruoloPorta, String nomePorta, ServiceBinding serviceBinding,
  15187.             boolean tokenAbilitato) throws Exception {
  15188.    
  15189.         boolean delegata = false;
  15190.         boolean applicativa = false;
  15191.         boolean configurazione = false;
  15192.         if(ruoloPorta!=null) {
  15193.             if(RuoloPolicy.DELEGATA.equals(ruoloPorta)) {
  15194.                 delegata = (nomePorta!=null);
  15195.             }
  15196.             else if(RuoloPolicy.APPLICATIVA.equals(ruoloPorta)) {
  15197.                 applicativa = (nomePorta!=null);
  15198.             }
  15199.         }
  15200.         configurazione = !delegata && !applicativa;
  15201.        
  15202.        
  15203.                
  15204.         List<String> protocolli = null;
  15205.         boolean groupByKey = false;
  15206.        
  15207.         if(policy!=null && policy.getGroupBy()!=null && policy.getGroupBy().isEnabled()){
  15208.            
  15209.             // protocollo
  15210.             protocolli = this.confCore.getProtocolli();
  15211.            
  15212.             // group by by key se non sono richiesti campionamenti statistici
  15213.             if(infoPolicy!=null && !infoPolicy.isIntervalloUtilizzaRisorseStatistiche() &&
  15214.                     !infoPolicy.isDegradoPrestazionaleUtilizzaRisorseStatistiche()){
  15215.                 groupByKey = true;
  15216.             }
  15217.         }

  15218. //
  15219.         DataElement de = new DataElement();
  15220.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RAGGRUPPAMENTO);
  15221.         de.setType(DataElementType.SUBTITLE);
  15222.         dati.add(de);
  15223.        
  15224.         de = new DataElement();
  15225.         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RAGGRUPPAMENTO_NOTE);
  15226.         de.setType(DataElementType.NOTE);
  15227.         dati.add(de);
  15228.        
  15229.         boolean policyGropuByEnabled = policy!=null && policy.getGroupBy()!=null && policy.getGroupBy().isEnabled();
  15230.        
  15231.         // stato
  15232.         addToDatiDataElementStato_postBackViaPOST(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_ENABLED,
  15233.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_ENABLED_STATO,
  15234.                 policyGropuByEnabled,
  15235.                 true, false, false, false);
  15236.        
  15237.         /**
  15238.         de = new DataElement();
  15239.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_ENABLED);
  15240.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_ENABLED);
  15241.         de.setType(DataElementType.SELECT);
  15242.         de.setValues(ConfigurazioneCostanti.CONFIGURAZIONE_STATI_COLLEZIONAMENTO);
  15243.         if(policyGropuByEnabled){
  15244.             de.setSelected(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_COLLEZIONAMENTO_ABILITATO);
  15245.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_COLLEZIONAMENTO_ABILITATO);
  15246.         }
  15247.         else{
  15248.             de.setSelected(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_COLLEZIONAMENTO_DISABILITATO);
  15249.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_COLLEZIONAMENTO_DISABILITATO);
  15250.         }
  15251.         de.setPostBack_viaPOST(true);
  15252.         dati.add(de);
  15253.         */
  15254.        
  15255.         if(policyGropuByEnabled){
  15256.        
  15257.            
  15258.             // --- GENERALI ---
  15259.            
  15260.             if(configurazione) {
  15261.                
  15262.                 boolean showRuoloPdD = policy.getFiltro()==null ||
  15263.                         policy.getFiltro().isEnabled()==false ||
  15264.                         policy.getFiltro().getRuoloPorta()==null ||
  15265.                         RuoloPolicy.ENTRAMBI.equals(policy.getFiltro().getRuoloPorta());
  15266.                
  15267.                 boolean showProtocollo = protocolli.size()>1 && (policy.getFiltro()==null ||
  15268.                         policy.getFiltro().isEnabled()==false ||
  15269.                         policy.getFiltro().getProtocollo()==null);
  15270.                
  15271.                 boolean showErogatore = policy.getFiltro()==null ||
  15272.                         policy.getFiltro().isEnabled()==false ||
  15273.                         policy.getFiltro().getTipoErogatore()==null ||
  15274.                         policy.getFiltro().getNomeErogatore()==null;
  15275.                
  15276.                 if(showRuoloPdD || showProtocollo || showErogatore) {
  15277. //                  de = new DataElement();
  15278. //                  de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_DATI_GENERALI);
  15279. //                  de.setType(DataElementType.NOTE);
  15280. //                  dati.add(de);
  15281.                 }
  15282.                
  15283.                 // Ruolo PdD
  15284.                 if( showRuoloPdD ){
  15285.                     de = new DataElement();
  15286.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_RUOLO_PDD);
  15287.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_RUOLO_PDD_LABEL);
  15288.                     //de.setLabelRight(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_RUOLO_PDD_NOTE);
  15289.                     de.setType(DataElementType.CHECKBOX);
  15290.                     de.setSelected(policy.getGroupBy().isRuoloPorta());
  15291.                     de.setValue(policy.getGroupBy().isRuoloPorta()+"");
  15292.                     dati.add(de);
  15293.                 }
  15294.            
  15295.                 // Protocollo
  15296.                 de = new DataElement();
  15297.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PROTOCOLLO);
  15298.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PROTOCOLLO);
  15299.                 if(showProtocollo){
  15300.                     de.setType(DataElementType.CHECKBOX);
  15301.                     de.setSelected(policy.getGroupBy().isProtocollo());
  15302.                     de.setValue(policy.getGroupBy().isProtocollo()+"");
  15303.                 }
  15304.                 else{
  15305.                     de.setType(DataElementType.HIDDEN);
  15306.                     if(protocolli.size()==1){
  15307.                         de.setValue("false");
  15308.                     }
  15309.                 }
  15310.                 dati.add(de);
  15311.                
  15312.                 // Erogatore
  15313.                 if( showErogatore ){
  15314.                     de = new DataElement();
  15315.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_EROGATORE);
  15316.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_EROGATORE);
  15317.                     de.setType(DataElementType.CHECKBOX);
  15318.                     de.setSelected(policy.getGroupBy().isErogatore());
  15319.                     de.setValue(policy.getGroupBy().isErogatore()+"");
  15320.                     dati.add(de);
  15321.                 }
  15322.                                
  15323.             }

  15324.            
  15325.             // --- API ---
  15326.            
  15327.             boolean showServizio = false;
  15328.            
  15329.             boolean showAzione = policy.getFiltro()==null ||
  15330.                     policy.getFiltro().isEnabled()==false ||
  15331.                     policy.getFiltro().getAzione()==null ||
  15332.                     "".equals(policy.getFiltro().getAzione()) ||
  15333.                     policy.getFiltro().getAzione().contains(",");
  15334.            
  15335.             boolean showSAErogatore = false;
  15336.            
  15337.             if(configurazione) {
  15338.            
  15339.                 if(this.core.isControlloTrafficoPolicyGlobaleGroupByApi()) {
  15340.                     showServizio = policy.getFiltro()==null ||
  15341.                             policy.getFiltro().isEnabled()==false ||
  15342.                             policy.getFiltro().getTipoServizio()==null ||
  15343.                             policy.getFiltro().getNomeServizio()==null;
  15344.                 }

  15345.                 if(showAzione) {
  15346.                     showAzione = showServizio && policy.getGroupBy().isServizio(); // l'azione la scelgo se ho prima selezionato una API
  15347.                 }
  15348.                
  15349.                 showSAErogatore = policy.getFiltro()==null ||
  15350.                         policy.getFiltro().isEnabled()==false ||
  15351.                         policy.getFiltro().getRuoloPorta()==null ||
  15352.                         RuoloPolicy.ENTRAMBI.equals(policy.getFiltro().getRuoloPorta()) ||
  15353.                         RuoloPolicy.APPLICATIVA.equals(policy.getFiltro().getRuoloPorta());
  15354.                 if(showSAErogatore) {
  15355.                     showSAErogatore = policy.getFiltro()==null ||
  15356.                             policy.getFiltro().isEnabled()==false ||
  15357.                             policy.getFiltro().getServizioApplicativoErogatore()==null;
  15358.                 }
  15359.                
  15360.                 if(showServizio || showAzione || showSAErogatore) {
  15361.                     if(configurazione) {
  15362. //                      de = new DataElement();
  15363. //                      de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_API);
  15364. //                      de.setType(DataElementType.NOTE);
  15365. //                      dati.add(de);
  15366.                     }
  15367.                 }
  15368.                        
  15369.                 // Servizio
  15370.                 if( showServizio ){
  15371.                     de = new DataElement();
  15372.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SERVIZIO);
  15373.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SERVIZIO);
  15374.                     de.setType(DataElementType.CHECKBOX);
  15375.                     de.setSelected(policy.getGroupBy().isServizio());
  15376.                     de.setValue(policy.getGroupBy().isServizio()+"");
  15377.                     de.setPostBack_viaPOST(true);
  15378.                     dati.add(de);
  15379.                 }
  15380.             }
  15381.                
  15382.             // Azione
  15383.             de = new DataElement();
  15384.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_AZIONE);
  15385.             if(serviceBinding!=null) {
  15386.                 de.setLabel(getLabelAzione(serviceBinding));
  15387.             }
  15388.             else {
  15389.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_AZIONE);
  15390.             }
  15391.             if( showAzione ){
  15392.                 de.setType(DataElementType.CHECKBOX);
  15393.                 de.setSelected(policy.getGroupBy().isAzione());
  15394.             }
  15395.             else {
  15396.                 de.setType(DataElementType.HIDDEN);
  15397.             }
  15398.             de.setValue(policy.getGroupBy().isAzione()+"");
  15399.             dati.add(de);
  15400.            
  15401.            
  15402.             // Servizio Applicativo Erogatore
  15403.             if(configurazione) {
  15404.                 if( showSAErogatore ){
  15405.                     de = new DataElement();
  15406.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SA_EROGATORE);
  15407.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SA_EROGATORE);
  15408.                     //de.setType(DataElementType.CHECKBOX);
  15409.                     de.setType(DataElementType.HIDDEN);
  15410.                     de.setSelected(policy.getGroupBy().isServizioApplicativoErogatore());
  15411.                     de.setValue(policy.getGroupBy().isServizioApplicativoErogatore()+"");
  15412.                     dati.add(de);
  15413.                 }
  15414.             }
  15415.                

  15416.            
  15417.             // --- RICHIEDENTI ---
  15418.            
  15419.             if(configurazione) {
  15420. //              de = new DataElement();
  15421. //              de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_MITTENTE);
  15422. //              de.setType(DataElementType.NOTE);
  15423. //              dati.add(de);
  15424.             }
  15425.            
  15426.             // Fruitore
  15427.            
  15428.             if(configurazione) {
  15429.                
  15430.                 boolean showFruitore = policy.getFiltro()==null ||
  15431.                         policy.getFiltro().isEnabled()==false ||
  15432.                         policy.getFiltro().getTipoFruitore()==null ||
  15433.                         policy.getFiltro().getNomeFruitore()==null;
  15434.                
  15435.                 // Fruitore
  15436.                 if( showFruitore ){
  15437.                     de = new DataElement();
  15438.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_FRUITORE);
  15439.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_FRUITORE);
  15440.                     de.setType(DataElementType.CHECKBOX);
  15441.                     de.setSelected(policy.getGroupBy().isFruitore());
  15442.                     de.setValue(policy.getGroupBy().isFruitore()+"");
  15443.                     dati.add(de);
  15444.                 }
  15445.                
  15446.                
  15447.                 boolean showRichiedenteApplicativo = policy.getFiltro()==null ||
  15448.                         policy.getFiltro().isEnabled()==false ||
  15449.                         policy.getFiltro().getRuoloPorta()==null ||
  15450.                         policy.getFiltro().getServizioApplicativoFruitore()==null;
  15451.                
  15452.                 // Applicativo Fruitore
  15453.                 if( showRichiedenteApplicativo ){
  15454.                     de = new DataElement();
  15455.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SA_FRUITORE);
  15456.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_SA_FRUITORE);
  15457.                     de.setType(DataElementType.CHECKBOX);
  15458.                     de.setSelected(policy.getGroupBy().isServizioApplicativoFruitore());
  15459.                     de.setValue(policy.getGroupBy().isServizioApplicativoFruitore()+"");
  15460.                     dati.add(de);
  15461.                 }
  15462.                
  15463.             }
  15464.             else {
  15465.            
  15466.                 // Richiedente API (Significa SoggettoMittente per le erogazioni, Applicativo e Identificativo Autenticato sia per le erogazioni che per le fruizioni)
  15467.                 de = new DataElement();
  15468.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_RICHIEDENTE);
  15469.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_RICHIEDENTE);
  15470.                 de.setType(DataElementType.CHECKBOX);
  15471.                 de.setSelected(policy.getGroupBy().isIdentificativoAutenticato()); // uso isIdentificativoAutenticato come informazione equivalente a isServizioApplicativoFruitore e isSoggettoFruitore
  15472.                 de.setValue(policy.getGroupBy().isIdentificativoAutenticato()+"");
  15473.                 dati.add(de);
  15474.            
  15475.             }
  15476.            

  15477.             // Token
  15478.            
  15479.             if(tokenAbilitato) {
  15480.            
  15481.                 boolean first = this.isFirstTimeFromHttpParameters(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_FIRST_TIME);
  15482.                 String token = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_TOKEN);
  15483.                
  15484.                 String [] tokenSelezionatiDB = null;
  15485.                 if(policy.getGroupBy().getToken()!=null && !"".equals(policy.getGroupBy().getToken())) {
  15486.                     tokenSelezionatiDB = policy.getGroupBy().getToken().split(",");
  15487.                 }
  15488.                 String [] tokenSelezionatiSenzaIssuer = null;
  15489.                 if(tokenSelezionatiDB!=null && tokenSelezionatiDB.length>0) {
  15490.                     List<String> l = new ArrayList<>();
  15491.                     for (int i = 0; i < tokenSelezionatiDB.length; i++) {
  15492.                         TipoCredenzialeMittente tipo = TipoCredenzialeMittente.toEnumConstant(tokenSelezionatiDB[i], true);
  15493.                         if(!TipoCredenzialeMittente.TOKEN_ISSUER.equals(tipo)) {
  15494.                             l.add(tokenSelezionatiDB[i]);
  15495.                         }
  15496.                     }
  15497.                     if(!l.isEmpty()) {
  15498.                         tokenSelezionatiSenzaIssuer = l.toArray(new String[1]);
  15499.                     }
  15500.                 }
  15501.                 boolean groupByToken = false;
  15502.                 if(first) {
  15503.                     groupByToken = (tokenSelezionatiDB!=null && tokenSelezionatiDB.length>0);
  15504.                 }
  15505.                 else {
  15506.                     groupByToken = ServletUtils.isCheckBoxEnabled(token);
  15507.                 }
  15508.                
  15509.                 de = new DataElement();
  15510.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_TOKEN);
  15511.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_TOKEN);
  15512.                 de.setType(DataElementType.CHECKBOX);
  15513.                 de.setSelected(groupByToken); // uso isIdentificativoAutenticato come informazione equivalente a isServizioApplicativoFruitore e isSoggettoFruitore
  15514.                 de.setValue(groupByToken+"");
  15515.                 de.setPostBack_viaPOST(true);
  15516.                 dati.add(de);
  15517.                
  15518.                 if(groupByToken) {
  15519.                     de = new DataElement();
  15520.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_TOKEN_CLAIMS);
  15521.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_TOKEN_CLAIMS);
  15522.                    
  15523.                     boolean modiPdnd = applicativa && policy.getFiltro()!=null &&
  15524.                             org.openspcoop2.protocol.engine.constants.Costanti.MODIPA_PROTOCOL_NAME.equals(policy.getFiltro().getProtocollo());
  15525.                     if(modiPdnd) {
  15526.                         de.setValues(CostantiControlStation.TOKEN_VALUES_WITHOUT_ISSUER_CON_PDND_INFO);
  15527.                         de.setLabels(CostantiControlStation.LABEL_TOKEN_VALUES_WITHOUT_ISSUER_CON_PDND);
  15528.                     }
  15529.                     else {
  15530.                         de.setValues(CostantiControlStation.TOKEN_VALUES_WITHOUT_ISSUER);
  15531.                         de.setLabels(CostantiControlStation.LABEL_TOKEN_VALUES_WITHOUT_ISSUER);
  15532.                     }
  15533.                     de.setSelezionati(tokenSelezionatiSenzaIssuer);
  15534.                     de.setType(DataElementType.MULTI_SELECT);
  15535.                     if(modiPdnd) {
  15536.                         de.setRows(5);
  15537.                     }
  15538.                     else {
  15539.                         de.setRows(4);
  15540.                     }
  15541.                     de.setRequired(true);
  15542.                     dati.add(de);
  15543.                 }
  15544.                
  15545.             }
  15546.            
  15547.             if(groupByKey){
  15548.            
  15549.                 // per chiave
  15550.                
  15551.                 if(policy.getGroupBy().isInformazioneApplicativaEnabled()){
  15552.                     de = new DataElement();
  15553.                     de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_ENABLED_NOTE);
  15554.                     de.setType(DataElementType.NOTE);
  15555.                     dati.add(de);
  15556.                 }
  15557.                
  15558.                 de = new DataElement();
  15559.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_ENABLED);
  15560.                 if(policy.getGroupBy().isInformazioneApplicativaEnabled()){
  15561.                     de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO);
  15562.                 }
  15563.                 else{
  15564.                     //de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_ENABLED_LABEL);
  15565.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_ENABLED_LABEL);
  15566.                     //de.setLabelRight(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_ENABLED_NOTE);
  15567.                 }
  15568.                 de.setType(DataElementType.CHECKBOX);
  15569.                 de.setSelected(policy.getGroupBy().isInformazioneApplicativaEnabled());
  15570.                 de.setValue(policy.getGroupBy().isInformazioneApplicativaEnabled()+"");
  15571.                 de.setPostBack_viaPOST(true);
  15572.                 dati.add(de);
  15573.                
  15574.                 if(policy.getGroupBy().isInformazioneApplicativaEnabled()){
  15575.                    
  15576.                     TipoFiltroApplicativo tipoChiaveGroupBy = null;
  15577.                     if(policy.getGroupBy().getInformazioneApplicativaTipo()!=null && !"".equals(policy.getGroupBy().getInformazioneApplicativaTipo())){
  15578.                         tipoChiaveGroupBy = TipoFiltroApplicativo.toEnumConstant(policy.getGroupBy().getInformazioneApplicativaTipo());
  15579.                     }
  15580.                     if(tipoChiaveGroupBy==null){
  15581.                         tipoChiaveGroupBy = TipoFiltroApplicativo.toEnumConstant(ConfigurazioneCostanti.CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_TIPO_DEFAULT);
  15582.                     }
  15583.                    
  15584.                     de = new DataElement();
  15585.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_TIPO);
  15586.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_TIPO);
  15587.                     de.setValues(TipoFiltroApplicativo.toStringArray());
  15588.                     de.setLabels(ConfigurazioneCostanti.LABEL_RATE_LIMITING_FILTRO_APPLICATIVO);
  15589.                     de.setSelected(policy.getGroupBy().getInformazioneApplicativaTipo());
  15590.                     de.setValue(policy.getGroupBy().getInformazioneApplicativaTipo());
  15591.                     de.setType(DataElementType.SELECT);
  15592.                     de.setPostBack_viaPOST(true);
  15593.                     dati.add(de);
  15594.                    
  15595.                     if(TipoFiltroApplicativo.PLUGIN_BASED.equals(tipoChiaveGroupBy)) {
  15596.                         this.addCustomField(TipoPlugin.RATE_LIMITING,
  15597.                                 null,
  15598.                                 null,
  15599.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_TIPO,
  15600.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_NOME,
  15601.                                 this.getLabelTipoInformazioneApplicativaGroupBy(policy.getGroupBy().getInformazioneApplicativaTipo()),
  15602.                                 policy.getGroupBy().getInformazioneApplicativaNome(), false, dati,
  15603.                                 true);  
  15604.                     }
  15605.                     else {
  15606.                         de = new DataElement();
  15607.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_NOME);
  15608.                         de.setLabel(this.getLabelTipoInformazioneApplicativaGroupBy(policy.getGroupBy().getInformazioneApplicativaTipo()));
  15609.                         de.setValue(policy.getGroupBy().getInformazioneApplicativaNome());
  15610.                         if(tipoChiaveGroupBy==null ||
  15611.                                 TipoFiltroApplicativo.SOAPACTION_BASED.equals(tipoChiaveGroupBy)  ||
  15612.                                 TipoFiltroApplicativo.INDIRIZZO_IP.equals(tipoChiaveGroupBy) ||
  15613.                                 TipoFiltroApplicativo.INDIRIZZO_IP_FORWARDED.equals(tipoChiaveGroupBy)){
  15614.                             de.setType(DataElementType.HIDDEN);
  15615.                         }
  15616.                         else if(TipoFiltroApplicativo.URLBASED.equals(tipoChiaveGroupBy) ||
  15617.                                 TipoFiltroApplicativo.CONTENT_BASED.equals(tipoChiaveGroupBy)) {
  15618.                             de.setRequired(true);
  15619.                             de.setType(DataElementType.TEXT_AREA);
  15620.                         }
  15621.                         else{
  15622.                             de.setRequired(true);
  15623.                             de.setType(DataElementType.TEXT_EDIT);
  15624.                         }
  15625.                         dati.add(de);
  15626.                     }
  15627.                 }
  15628.                
  15629.             }
  15630.         }
  15631.     }
  15632.    
  15633.     private List<String> enrichListConLabelQualsiasi(List<String> l){
  15634.         List<String> newList = new ArrayList<>();
  15635.         newList.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI);
  15636.         if(l!=null && l.size()>0){
  15637.             newList.addAll(l);
  15638.         }
  15639.         return newList;
  15640.     }
  15641.     private List<String> enrichListConValueQualsiasi(List<String> l){
  15642.         List<String> newList = new ArrayList<>();
  15643.         newList.add(ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI);
  15644.         if(l!=null && l.size()>0){
  15645.             newList.addAll(l);
  15646.         }
  15647.         return newList;
  15648.     }
  15649.    
  15650.     public String getLabelTipoInformazioneApplicativaFiltro(String tipoInformazioneApplicativa){
  15651.         TipoFiltroApplicativo tipo = TipoFiltroApplicativo.toEnumConstant(ConfigurazioneCostanti.CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO_DEFAULT);
  15652.         if(tipoInformazioneApplicativa!=null){
  15653.             tipo = TipoFiltroApplicativo.toEnumConstant(tipoInformazioneApplicativa);
  15654.         }
  15655.         switch (tipo) {
  15656.         case HEADER_BASED:
  15657.             return ModalitaIdentificazione.HEADER_BASED.getLabelParametro();
  15658.         case FORM_BASED:
  15659.             return ModalitaIdentificazione.FORM_BASED.getLabelParametro();
  15660.         case CONTENT_BASED:
  15661.             return ModalitaIdentificazione.CONTENT_BASED.getLabelParametro();
  15662.         case URLBASED:
  15663.             return ModalitaIdentificazione.URL_BASED.getLabelParametro();
  15664.         case SOAPACTION_BASED:
  15665.             return ModalitaIdentificazione.SOAP_ACTION_BASED.getLabelParametro();
  15666.         case INDIRIZZO_IP:
  15667.             return ModalitaIdentificazione.INDIRIZZO_IP_BASED.getLabelParametro();
  15668.         case INDIRIZZO_IP_FORWARDED:
  15669.             return ModalitaIdentificazione.X_FORWARD_FOR_BASED.getLabelParametro();
  15670.         case PLUGIN_BASED:
  15671.             return ModalitaIdentificazione.PLUGIN_BASED.getLabelParametro();
  15672.         }
  15673.         return null;
  15674.     }
  15675.    
  15676.     public String getLabelTipoInformazioneApplicativaGroupBy(String tipoInformazioneApplicativa){
  15677.         TipoFiltroApplicativo tipo = TipoFiltroApplicativo.toEnumConstant(ConfigurazioneCostanti.CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_TIPO_DEFAULT);
  15678.         if(tipoInformazioneApplicativa!=null){
  15679.             tipo = TipoFiltroApplicativo.toEnumConstant(tipoInformazioneApplicativa);
  15680.         }
  15681.         switch (tipo) {
  15682.         case HEADER_BASED:
  15683.             return ModalitaIdentificazione.HEADER_BASED.getLabelParametro();
  15684.         case FORM_BASED:
  15685.             return ModalitaIdentificazione.FORM_BASED.getLabelParametro();
  15686.         case CONTENT_BASED:
  15687.             return ModalitaIdentificazione.CONTENT_BASED.getLabelParametro();
  15688.         case URLBASED:
  15689.             return ModalitaIdentificazione.URL_BASED.getLabelParametro();
  15690.         case SOAPACTION_BASED:
  15691.             return ModalitaIdentificazione.SOAP_ACTION_BASED.getLabelParametro();
  15692.         case INDIRIZZO_IP:
  15693.             return ModalitaIdentificazione.INDIRIZZO_IP_BASED.getLabelParametro();
  15694.         case INDIRIZZO_IP_FORWARDED:
  15695.             return ModalitaIdentificazione.X_FORWARD_FOR_BASED.getLabelParametro();
  15696.         case PLUGIN_BASED:
  15697.             return ModalitaIdentificazione.PLUGIN_BASED.getLabelParametro();
  15698.         }
  15699.         return null;
  15700.     }

  15701.     public boolean attivazionePolicyCheckData(StringBuilder sbParsingError, TipoOperazione tipoOperazione, ConfigurazioneGenerale configurazioneControlloTraffico,
  15702.             AttivazionePolicy policy, InfoPolicy infoPolicy, RuoloPolicy ruoloPorta, String nomePorta, ServiceBinding serviceBinding, String modalita) throws Exception {
  15703.    
  15704.         // errori di parsing letti durante la read della richiesta
  15705.         if(sbParsingError.length() >0){
  15706.             this.pd.setMessage(sbParsingError.toString());
  15707.             return false;
  15708.         }
  15709.        
  15710.         boolean check = this.checkAttivazionePolicy(configurazioneControlloTraffico,policy,infoPolicy,
  15711.                 serviceBinding);
  15712.         if(!check) {
  15713.             return false;
  15714.         }
  15715.        
  15716.         StringBuilder existsMessage = new StringBuilder();
  15717.        
  15718.         boolean alreadyExists = ConfigurazioneUtilities.alreadyExists(tipoOperazione, this.confCore, this,
  15719.                 policy, infoPolicy, ruoloPorta, nomePorta, serviceBinding,
  15720.                 existsMessage, org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE, modalita);
  15721.        
  15722.         if(alreadyExists) {
  15723.             this.pd.setMessage(existsMessage.toString());
  15724.             return false;
  15725.         }
  15726.        
  15727.         return true;
  15728.     }
  15729.    
  15730.     public boolean checkAttivazionePolicy(ConfigurazioneGenerale c,AttivazionePolicy policy,InfoPolicy infoPolicy,
  15731.             ServiceBinding serviceBinding) throws Exception{
  15732.        
  15733.         // IdPolicy
  15734.         if(policy.getIdPolicy()==null || "".equals(policy.getIdPolicy()) || "-".equals(policy.getIdPolicy())){
  15735.             String messaggio = "Deve essere selezionata una policy in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ID+"'";
  15736.             this.pd.setMessage(messaggio);
  15737.             return false;
  15738.         }
  15739.        
  15740.         if(policy.getAlias()!=null && !"".equals(policy.getAlias())) {
  15741.             if(this.checkLength255(policy.getAlias(), ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ALIAS)==false) {
  15742.                 return false;
  15743.             }
  15744.             if(this.checkNCName(policy.getAlias(), ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ALIAS)==false) {
  15745.                 return false;
  15746.             }
  15747.         }
  15748.         else {
  15749.             String messaggio = "Deve essere indicato un nome";
  15750.             this.pd.setMessage(messaggio);
  15751.             return false;
  15752.         }
  15753.        
  15754.         if(policy.isRidefinisci()){
  15755.        
  15756.             // Valori di Soglia
  15757.             if(infoPolicy!=null){
  15758.                 TipoRisorsa tipoRisorsa = infoPolicy.getTipoRisorsa();
  15759.                 String name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_NUMERO_RICHIESTE;
  15760.                 if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)){
  15761.                     name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RISPOSTA_LABEL;
  15762.                 }
  15763.                 else if(TipoRisorsa.OCCUPAZIONE_BANDA.equals(tipoRisorsa)){
  15764.                     name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_OCCUPAZIONE_DI_BANDA_LABEL;
  15765.                 }
  15766.                 else if(TipoRisorsa.TEMPO_MEDIO_RISPOSTA.equals(tipoRisorsa)){
  15767.                     name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_TEMPO_MEDIO_LABEL;
  15768.                 }
  15769.                 else if(TipoRisorsa.TEMPO_COMPLESSIVO_RISPOSTA.equals(tipoRisorsa)){
  15770.                     name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_TEMPO_COMPLESSIVO_LABEL;
  15771.                 }
  15772.                 if(policy.getValore()==null){
  15773.                     String messaggio = "Deve essere indicato un valore in '"+name+"'";
  15774.                     this.pd.setMessage(messaggio);
  15775.                     return false;
  15776.                 }
  15777.                 long l = policy.getValore();
  15778.                 try{
  15779.                     if(l<=0){
  15780.                         throw new DriverControlStationException("Valore non nell'intervallo");
  15781.                     }
  15782.                 }catch(Exception e){
  15783.                     String max = Long.MAX_VALUE+"";
  15784.                     if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)) {
  15785.                         max = Integer.MAX_VALUE+"";
  15786.                     }
  15787.                     String messaggio = "Il valore ("+policy.getValore()+") indicato in '"+name+"' deve essere un numero intero maggiore di 0 e minore di "+max;
  15788.                     this.pd.setMessage(messaggio);
  15789.                     return false;
  15790.                 }
  15791.                 if(TipoRisorsa.NUMERO_RICHIESTE.equals(tipoRisorsa) && infoPolicy.isCheckRichiesteSimultanee()){
  15792.                     if(c.getControlloTraffico().isControlloMaxThreadsEnabled()) {
  15793.                         if(l > c.getControlloTraffico().getControlloMaxThreadsSoglia()){
  15794.                             String messaggio = "Deve essere indicato un valore in '"+name+
  15795.                                     "' minore di quanto indicato nella configurazione generale alla voce '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_NUM_MASSIMO_RICHIESTE_SIMULTANEE_SOGLIA+"'";
  15796.                             this.pd.setMessage(messaggio);
  15797.                             return false;
  15798.                         }
  15799.                     }
  15800.                 }
  15801.            
  15802.                 if(TipoRisorsa.DIMENSIONE_MASSIMA_MESSAGGIO.equals(tipoRisorsa)) {
  15803.                     name = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_SOGLIA_VALORE_DIMENSIONE_MASSIMA_RICHIESTA_LABEL;
  15804.                     if(policy.getValore2()==null){
  15805.                         String messaggio = "Deve essere indicato un valore in '"+name+"'";
  15806.                         this.pd.setMessage(messaggio);
  15807.                         return false;
  15808.                     }
  15809.                     l = policy.getValore2();
  15810.                     try{
  15811.                         if(l<=0){
  15812.                             throw new DriverControlStationException("Valore non nell'intervallo");
  15813.                         }
  15814.                     }catch(Exception e){
  15815.                         String messaggio = "Il valore ("+policy.getValore2()+") indicato in '"+name+"' deve essere un numero intero maggiore di 0 e minore di "+Integer.MAX_VALUE;
  15816.                         this.pd.setMessage(messaggio);
  15817.                         return false;
  15818.                     }
  15819.                 }
  15820.             }
  15821.            

  15822.         }
  15823.        
  15824.         if(policy.getFiltro().isEnabled()){
  15825.            
  15826.             if( (policy.getFiltro().getRuoloPorta()==null || RuoloPolicy.ENTRAMBI.equals(policy.getFiltro().getRuoloPorta()))
  15827.                     &&
  15828.                     policy.getFiltro().getProtocollo()==null &&
  15829.                     policy.getFiltro().getRuoloFruitore()==null &&
  15830.                     policy.getFiltro().getTipoFruitore()==null &&
  15831.                     policy.getFiltro().getNomeFruitore()==null &&
  15832.                     policy.getFiltro().getServizioApplicativoFruitore()==null &&
  15833.                     policy.getFiltro().getRuoloErogatore()==null &&
  15834.                     policy.getFiltro().getTipoErogatore()==null &&
  15835.                     policy.getFiltro().getNomeErogatore()==null &&
  15836.                     policy.getFiltro().getServizioApplicativoErogatore()==null &&
  15837.                     policy.getFiltro().getTag()==null &&
  15838.                     policy.getFiltro().getTipoServizio()==null &&
  15839.                     policy.getFiltro().getNomeServizio()==null &&
  15840.                     policy.getFiltro().getAzione()==null &&
  15841.                     policy.getFiltro().getTokenClaims()==null &&
  15842.                     policy.getFiltro().isInformazioneApplicativaEnabled()==false){
  15843.                 String messaggio = "Se si abilita il filtro deve essere selezionato almeno un criterio";
  15844.                 this.pd.setMessage(messaggio);
  15845.                 return false;
  15846.             }
  15847.            
  15848.             if(policy.getFiltro().getTokenClaims()!=null && !"".equals(policy.getFiltro().getTokenClaims())) {
  15849.                 Scanner scanner = new Scanner(policy.getFiltro().getTokenClaims());
  15850.                 try {
  15851.                     while (scanner.hasNextLine()) {
  15852.                         String line = scanner.nextLine();
  15853.                         if(line==null || line.trim().equals("")) {
  15854.                             continue;
  15855.                         }
  15856.                         if(line.contains("=")==false) {
  15857.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_TOKEN);
  15858.                             return false;
  15859.                         }
  15860.                     }
  15861.                 }finally {
  15862.                     scanner.close();
  15863.                 }
  15864.             }
  15865.            
  15866.             if(policy.getFiltro().isInformazioneApplicativaEnabled()){
  15867.                
  15868.                 TipoFiltroApplicativo tipo = TipoFiltroApplicativo.toEnumConstant(ConfigurazioneCostanti.CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO_DEFAULT);
  15869.                 if(policy.getFiltro().getInformazioneApplicativaTipo()!=null){
  15870.                     tipo = TipoFiltroApplicativo.toEnumConstant(policy.getFiltro().getInformazioneApplicativaTipo());
  15871.                 }
  15872.                
  15873.                 if(!TipoFiltroApplicativo.SOAPACTION_BASED.equals(tipo) &&
  15874.                         !TipoFiltroApplicativo.INDIRIZZO_IP.equals(tipo) &&
  15875.                         !TipoFiltroApplicativo.INDIRIZZO_IP_FORWARDED.equals(tipo)){
  15876.                    
  15877.                     String label = "'"+
  15878.                             ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED
  15879.                             +" - "+getLabelTipoInformazioneApplicativaFiltro(policy.getFiltro().getInformazioneApplicativaTipo())+"'";
  15880.                    
  15881.                     if(policy.getFiltro().getInformazioneApplicativaNome()==null ||
  15882.                             CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_VALORE_UNDEFINED.equals(policy.getFiltro().getInformazioneApplicativaNome())){
  15883.                         String messaggio = null;
  15884.                         if(TipoFiltroApplicativo.PLUGIN_BASED.equals(tipo) && this.confCore.isConfigurazionePluginsEnabled()) {
  15885.                             messaggio = ConfigurazioneCostanti.MESSAGGIO_ERRORE_RATE_LIMITING_PLUGIN_FILTRO_NON_SELEZIONATO;
  15886.                         }
  15887.                         else {
  15888.                             messaggio = "Deve essere indicato un valore in "+label;
  15889.                         }
  15890.                         this.pd.setMessage(messaggio);
  15891.                         return false;
  15892.                     }
  15893.                    
  15894.                     if (TipoFiltroApplicativo.URLBASED.equals(tipo)) {
  15895.                         if(this.checkRegexp(policy.getFiltro().getInformazioneApplicativaNome(),label)==false){
  15896.                             return false;
  15897.                         }
  15898.                     }
  15899.                     if (TipoFiltroApplicativo.CONTENT_BASED.equals(tipo)) {
  15900.                         if(ServiceBinding.SOAP.equals(serviceBinding)) {
  15901.                             if(this.checkXPath(policy.getFiltro().getInformazioneApplicativaNome(),label)==false){
  15902.                                 return false;
  15903.                             }
  15904.                         }
  15905.                         else {
  15906.                             if(this.checkXPathOrJsonPath(policy.getFiltro().getInformazioneApplicativaNome(),label)==false){
  15907.                                 return false;
  15908.                             }
  15909.                         }
  15910.                     }
  15911.                 }
  15912.                            
  15913.                 // Puo' essere anche una jsonPath
  15914. //              if(TipoFiltroApplicativo.CONTENT_BASED.equals(tipo)){
  15915. //                  XPathExpressionEngine xPathEngine = new XPathExpressionEngine();
  15916. //                  try{
  15917. //                      xPathEngine.validate(policy.getFiltro().getInformazioneApplicativaNome());
  15918. //                  }catch(XPathNotValidException notValidException){
  15919. //                      String messaggio = "L'espressione fornita in '"+
  15920. //                              ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED
  15921. //                              +" - "+getLabelTipoInformazioneApplicativaFiltro(policy.getFiltro().getInformazioneApplicativaTipo())+"' non è valida: "+
  15922. //                              notValidException.getMessage();
  15923. //                      this.pd.setMessage(messaggio);
  15924. //                      return false;
  15925. //                  }
  15926. //              }
  15927.                
  15928.                 if(policy.getFiltro().getInformazioneApplicativaValore()==null){
  15929.                     String messaggio = "Deve essere indicato un valore in '"+
  15930.                             ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED+
  15931.                             " - "+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_VALORE+"'";
  15932.                     this.pd.setMessage(messaggio);
  15933.                     return false;
  15934.                 }
  15935.                
  15936.             }
  15937.            
  15938.         }
  15939.        
  15940.         if(policy.getGroupBy().isEnabled()){
  15941.            
  15942.             // token
  15943.             String token = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_TOKEN);
  15944.             if(ServletUtils.isCheckBoxEnabled(token)) {
  15945.                 String [] tokenSelezionati = this.getParameterValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_TOKEN_CLAIMS);
  15946.                 if(tokenSelezionati==null || tokenSelezionati.length<=0) {
  15947.                     String messaggio = "Se si abilita il raggruppamento per token deve essere selezionato almeno un claim";
  15948.                     this.pd.setMessage(messaggio);
  15949.                     return false;
  15950.                 }
  15951.             }
  15952.            
  15953.             if( !policy.getGroupBy().isRuoloPorta() &&
  15954.                     !policy.getGroupBy().getProtocollo() &&
  15955.                     !policy.getGroupBy().getFruitore() &&
  15956.                     !policy.getGroupBy().getServizioApplicativoFruitore() &&
  15957.                     !policy.getGroupBy().getIdentificativoAutenticato() &&
  15958.                     (policy.getGroupBy().getToken()==null || "".equals(policy.getGroupBy().getToken())) &&
  15959.                     !policy.getGroupBy().getErogatore() &&
  15960.                     !policy.getGroupBy().getServizioApplicativoErogatore() &&
  15961.                     !policy.getGroupBy().getServizio() &&
  15962.                     !policy.getGroupBy().getAzione() &&
  15963.                     !policy.getGroupBy().isInformazioneApplicativaEnabled()){
  15964.                 String messaggio = "Se si abilita il collezionamento dei dati deve essere selezionato almeno un criterio di raggruppamento";
  15965.                 this.pd.setMessage(messaggio);
  15966.                 return false;
  15967.             }
  15968.                        
  15969.             if(policy.getGroupBy().isInformazioneApplicativaEnabled()){
  15970.                
  15971.                 TipoFiltroApplicativo tipo = TipoFiltroApplicativo.toEnumConstant(ConfigurazioneCostanti.CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_TIPO_DEFAULT);
  15972.                 if(policy.getGroupBy().getInformazioneApplicativaTipo()!=null){
  15973.                     tipo = TipoFiltroApplicativo.toEnumConstant(policy.getGroupBy().getInformazioneApplicativaTipo());
  15974.                 }
  15975.                
  15976.                 if(!TipoFiltroApplicativo.SOAPACTION_BASED.equals(tipo) &&
  15977.                         !TipoFiltroApplicativo.INDIRIZZO_IP.equals(tipo) &&
  15978.                         !TipoFiltroApplicativo.INDIRIZZO_IP_FORWARDED.equals(tipo)){
  15979.                
  15980.                     if(policy.getGroupBy().getInformazioneApplicativaNome()==null ||
  15981.                             CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_VALORE_UNDEFINED.equals(policy.getGroupBy().getInformazioneApplicativaNome())){
  15982.                         String messaggio = null;
  15983.                         if(TipoFiltroApplicativo.PLUGIN_BASED.equals(tipo)) {
  15984.                             messaggio = ConfigurazioneCostanti.MESSAGGIO_ERRORE_RATE_LIMITING_PLUGIN_GROUP_BY_NON_SELEZIONATO;
  15985.                         }
  15986.                         else {
  15987.                             messaggio = "Deve essere indicato un valore in '"+
  15988.                                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_ENABLED_NOTE
  15989.                                 +" - "+getLabelTipoInformazioneApplicativaGroupBy(policy.getGroupBy().getInformazioneApplicativaTipo())+"'";
  15990.                         }
  15991.                         this.pd.setMessage(messaggio);
  15992.                         return false;
  15993.                     }
  15994.                    
  15995.                 }
  15996.                
  15997.                 // Puo' essere anche una jsonPath
  15998. //              if(TipoFiltroApplicativo.CONTENT_BASED.equals(tipo)){
  15999. //                  XPathExpressionEngine xPathEngine = new XPathExpressionEngine();
  16000. //                  try{
  16001. //                      xPathEngine.validate(policy.getGroupBy().getInformazioneApplicativaNome());
  16002. //                  }catch(XPathNotValidException notValidException){
  16003. //                      String messaggio = "L'espressione fornita in '"+
  16004. //                              ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_GROUPBY_PER_CHIAVE_ENABLED_NOTE
  16005. //                              +" - "+getLabelTipoInformazioneApplicativaGroupBy(policy.getGroupBy().getInformazioneApplicativaTipo())+"' non è valida: "+
  16006. //                              notValidException.getMessage();
  16007. //                      this.pd.setMessage(messaggio);
  16008. //                      return false;
  16009. //                  }
  16010. //              }
  16011.                
  16012.             }
  16013.            
  16014.         }
  16015.         return true;
  16016.     }
  16017.    
  16018.     public String toStringFilter(AttivazionePolicyFiltro filtro, RuoloPolicy ruoloPorta, String nomePorta) throws NotFoundException {

  16019.         boolean delegata = false;
  16020.         boolean applicativa = false;
  16021.         boolean configurazione = false;
  16022.         if(ruoloPorta!=null) {
  16023.             if(RuoloPolicy.DELEGATA.equals(ruoloPorta)) {
  16024.                 delegata = (nomePorta!=null);
  16025.             }
  16026.             else if(RuoloPolicy.APPLICATIVA.equals(ruoloPorta)) {
  16027.                 applicativa = (nomePorta!=null);
  16028.             }
  16029.         }
  16030.         configurazione = !delegata && !applicativa;
  16031.        
  16032.         StringBuilder bf = new StringBuilder("Filtro");
  16033.         if(filtro.isEnabled()){

  16034.             bf.append(" abilitato con le seguenti impostazioni:");
  16035.            
  16036.             if(configurazione) {
  16037.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16038.                 if( (filtro.getRuoloPorta()==null || RuoloPolicy.ENTRAMBI.equals(filtro.getRuoloPorta())) ){
  16039.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_PDD+": Qualsiasi");
  16040.                 }
  16041.                 else{
  16042.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_PDD+":"+filtro.getRuoloPorta().getValue());
  16043.                 }
  16044.             }
  16045.            
  16046.             if(configurazione) {
  16047.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16048.                 if( (filtro.getProtocollo()==null || "".equals(filtro.getProtocollo())) ){
  16049.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO+": Qualsiasi");
  16050.                 }
  16051.                 else{
  16052.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PROTOCOLLO+": "+filtro.getProtocollo());
  16053.                 }
  16054.             }
  16055.            
  16056.             if(configurazione) {
  16057.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16058.                 if(filtro.getRuoloErogatore()!=null) {
  16059.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_EROGATORE+": "+filtro.getRuoloErogatore());
  16060.                 }
  16061.                 else if( (filtro.getTipoErogatore()==null || "".equals(filtro.getTipoErogatore()))
  16062.                         ||
  16063.                         (filtro.getNomeErogatore()==null || "".equals(filtro.getNomeErogatore()))){
  16064.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_EROGATORE+": Qualsiasi");
  16065.                 }
  16066.                 else{
  16067.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_EROGATORE+": "+filtro.getTipoErogatore()+"/"+filtro.getNomeErogatore());
  16068.                 }
  16069.             }
  16070.            
  16071.             if(configurazione) {
  16072.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16073.                 if( filtro.getTag()==null || "".equals(filtro.getTag()) ){
  16074.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TAG+": Qualsiasi");
  16075.                 }
  16076.                 else{
  16077.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_TAG+": "+filtro.getTag());
  16078.                 }
  16079.             }
  16080.            
  16081.             if(configurazione) {
  16082.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16083.                 if( (filtro.getTipoServizio()==null || "".equals(filtro.getTipoServizio()))
  16084.                         ||
  16085.                         (filtro.getNomeServizio()==null || "".equals(filtro.getNomeServizio()))){
  16086.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SERVIZIO+": Qualsiasi");
  16087.                 }
  16088.                 else{
  16089.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SERVIZIO+": "+filtro.getTipoServizio()+"/"+filtro.getNomeServizio());
  16090.                 }
  16091.             }
  16092.            
  16093.             bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16094.             if( (filtro.getAzione()==null || "".equals(filtro.getAzione())) ){
  16095.                 bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE+": Qualsiasi");
  16096.             }
  16097.             else{
  16098.                 bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_AZIONE+": "+filtro.getAzione());
  16099.             }
  16100.            
  16101.             if(configurazione) {
  16102.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16103.                 if( (filtro.getServizioApplicativoErogatore()==null || "".equals(filtro.getServizioApplicativoErogatore())) ){
  16104.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_EROGATORE+": Qualsiasi");
  16105.                 }
  16106.                 else{
  16107.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_EROGATORE+": "+filtro.getServizioApplicativoErogatore());
  16108.                 }
  16109.             }
  16110.            
  16111.             if(configurazione || applicativa) {
  16112.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16113.                 if(filtro.getRuoloFruitore()!=null) {
  16114.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_FRUITORE+": "+filtro.getRuoloFruitore());
  16115.                 }
  16116.                 else if( (filtro.getTipoFruitore()==null || "".equals(filtro.getTipoFruitore()))
  16117.                         ||
  16118.                         (filtro.getNomeFruitore()==null || "".equals(filtro.getNomeFruitore()))){
  16119.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_FRUITORE+": Qualsiasi");
  16120.                 }
  16121.                 else{
  16122.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_FRUITORE+": "+filtro.getTipoFruitore()+"/"+filtro.getNomeFruitore());
  16123.                 }
  16124.                
  16125.                 if(configurazione) {
  16126.                     bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16127.                     if( (filtro.getServizioApplicativoFruitore()==null || "".equals(filtro.getServizioApplicativoFruitore())) ){
  16128.                         bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE+": Qualsiasi");
  16129.                     }
  16130.                     else{
  16131.                         bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE+": "+filtro.getServizioApplicativoFruitore());
  16132.                     }
  16133.                 }
  16134.             }
  16135.             else if(delegata) {
  16136.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16137.                 if(filtro.getRuoloFruitore()!=null) {
  16138.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_RUOLO_FRUITORE+": "+filtro.getRuoloFruitore());
  16139.                 }
  16140.                 else if( (filtro.getServizioApplicativoFruitore()==null || "".equals(filtro.getServizioApplicativoFruitore())) ){
  16141.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE+": Qualsiasi");
  16142.                 }
  16143.                 else{
  16144.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_SA_FRUITORE+": "+filtro.getServizioApplicativoFruitore());
  16145.                 }
  16146.             }
  16147.            
  16148.             if(filtro.isInformazioneApplicativaEnabled()){
  16149.                
  16150.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16151.                 bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED+": Abilitato");
  16152.                
  16153.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16154.                 bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_TIPO+": "+filtro.getInformazioneApplicativaTipo());
  16155.                
  16156.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16157.                 bf.append(getLabelTipoInformazioneApplicativaFiltro(filtro.getInformazioneApplicativaTipo())).append(": ").append(filtro.getInformazioneApplicativaNome());
  16158.                
  16159.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16160.                 bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_VALORE+": "+filtro.getInformazioneApplicativaValore());
  16161.             }
  16162.             else{
  16163.                
  16164.                 bf.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16165.                 bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_FILTRO_PER_CHIAVE_ENABLED+": Disabilitato");
  16166.                
  16167.             }
  16168.            
  16169.         }
  16170.         else{
  16171.             bf.append(": Disabilitato");
  16172.         }
  16173.         return bf.toString();
  16174.     }
  16175.    
  16176.     public String eseguiResetJmx(TipoOperazione tipoOperazione, RuoloPolicy ruoloPorta, String nomePorta) throws Exception{
  16177.         try{
  16178.             List<String> aliases = this.core.getJmxPdDAliases();
  16179.             if(aliases==null || aliases.size()<=0){
  16180.                 throw new DriverControlStationException("Pagina non prevista, la sezione configurazione non permette di accedere a questa pagina, se la configurazione non e' corretta");
  16181.             }
  16182.             for (String alias : aliases) {
  16183.                
  16184.                 String resultReset = null;
  16185.                 String idAllPolicy = null;
  16186.                 try{
  16187.                     if(nomePorta!=null && !"".equals(nomePorta)) {
  16188.                         idAllPolicy = ConfigurazionePdD.getKeyMethodElencoIdPolicyAttiveAPI(RuoloPolicy.DELEGATA.equals(ruoloPorta)?TipoPdD.DELEGATA : TipoPdD.APPLICATIVA, nomePorta);
  16189.                     }
  16190.                     else {
  16191.                         idAllPolicy = ConfigurazionePdD.getKeyMethodElencoIdPolicyAttiveGlobali();
  16192.                     }
  16193.                     resultReset = this.core.getInvoker().invokeJMXMethod(alias,JMXConstants.JMX_TYPE, CostantiPdD.JMX_CONFIGURAZIONE_PDD, JMXUtils.CACHE_METHOD_NAME_REMOVE_OBJECT, idAllPolicy);
  16194.                     this.log.debug("reset["+idAllPolicy+"] "+resultReset);
  16195.                 }catch(Exception e){
  16196.                     String errorMessage = "Errore durante l'invocazione dell'operazione ["+JMXUtils.CACHE_METHOD_NAME_REMOVE_OBJECT+"] sulla risorsa ["+
  16197.                             CostantiPdD.JMX_CONFIGURAZIONE_PDD+"] (param:"+idAllPolicy+"): "+e.getMessage();
  16198.                     this.logError(errorMessage,e);
  16199.                     resultReset = errorMessage;
  16200.                 }
  16201.                
  16202.                 try{
  16203.                     if(nomePorta!=null && !"".equals(nomePorta)) {
  16204.                         idAllPolicy = ConfigurazionePdD.getKeyMethodElencoIdPolicyAttiveAPIDimensioneMessaggio(RuoloPolicy.DELEGATA.equals(ruoloPorta)?TipoPdD.DELEGATA : TipoPdD.APPLICATIVA, nomePorta);
  16205.                     }
  16206.                     else {
  16207.                         idAllPolicy = ConfigurazionePdD.getKeyMethodElencoIdPolicyAttiveGlobaliDimensioneMessaggio();
  16208.                     }
  16209.                     resultReset = this.core.getInvoker().invokeJMXMethod(alias,JMXConstants.JMX_TYPE, CostantiPdD.JMX_CONFIGURAZIONE_PDD, JMXUtils.CACHE_METHOD_NAME_REMOVE_OBJECT, idAllPolicy);
  16210.                     this.log.debug("reset["+idAllPolicy+"] "+resultReset);
  16211.                 }catch(Exception e){
  16212.                     String errorMessage = "Errore durante l'invocazione dell'operazione ["+JMXUtils.CACHE_METHOD_NAME_REMOVE_OBJECT+"] sulla risorsa ["+
  16213.                             CostantiPdD.JMX_CONFIGURAZIONE_PDD+"] (param:"+idAllPolicy+"): "+e.getMessage();
  16214.                     this.logError(errorMessage,e);
  16215.                     resultReset = errorMessage;
  16216.                 }
  16217.                
  16218.                 boolean resetSinglePolicy = false; // le policy attive contengono anche la data quindi non e' possibile resettarle singolarmente.
  16219.                 if(resetSinglePolicy) {
  16220.                     resultReset = null;
  16221.                     String idPolicy = null;
  16222.                     String tmpIdPolicy = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_ACTIVE_POLICY_ID);
  16223.                     try{
  16224.                         idPolicy = ConfigurazionePdD._getKey_AttivazionePolicy(tmpIdPolicy);
  16225.                         resultReset = this.core.getInvoker().invokeJMXMethod(alias,JMXConstants.JMX_TYPE, CostantiPdD.JMX_CONFIGURAZIONE_PDD, JMXUtils.CACHE_METHOD_NAME_REMOVE_OBJECT, idPolicy);
  16226.                         this.log.debug("reset["+idPolicy+"] "+resultReset);
  16227.                     }catch(Exception e){
  16228.                         String errorMessage = "Errore durante l'invocazione dell'operazione ["+JMXUtils.CACHE_METHOD_NAME_REMOVE_OBJECT+"] sulla risorsa ["+
  16229.                                 CostantiPdD.JMX_CONFIGURAZIONE_PDD+"] (param:"+idPolicy+"): "+e.getMessage();
  16230.                         this.logError(errorMessage,e);
  16231.                         resultReset = errorMessage;
  16232.                     }
  16233.                 }
  16234.                
  16235.                 String risorsa = null;
  16236.                 String methodName = null;
  16237.                 String params = null;
  16238.                 try{
  16239.                     TipoPdD tipoPdD = null;
  16240.                     risorsa = this.core.getJmxPdDConfigurazioneSistemaNomeRisorsaDatiRichieste(alias);
  16241.                     if(nomePorta!=null && !"".equals(nomePorta)) {
  16242.                         methodName = this.core.getJmxPdDConfigurazioneSistemaNomeMetodoRemoveRateLimitingAPIConfigCache(alias);
  16243.                         tipoPdD = RuoloPolicy.DELEGATA.equals(ruoloPorta)?TipoPdD.DELEGATA : TipoPdD.APPLICATIVA;
  16244.                         params = tipoPdD.getTipo() + ", " + nomePorta;
  16245.                         resultReset = this.core.getInvoker().invokeJMXMethod(alias,JMXConstants.JMX_TYPE,
  16246.                                 risorsa,
  16247.                                 methodName,
  16248.                                 tipoPdD.getTipo(), nomePorta);
  16249.                     }
  16250.                     else {
  16251.                         methodName = this.core.getJmxPdDConfigurazioneSistemaNomeMetodoRemoveRateLimitingGlobalConfigCache(alias);
  16252.                         params = "non sono previsti parametri";
  16253.                         resultReset = this.core.getInvoker().invokeJMXMethod(alias,JMXConstants.JMX_TYPE,
  16254.                                 risorsa,
  16255.                                 methodName);
  16256.                     }
  16257.                     this.log.debug("reset["+idAllPolicy+"] "+resultReset);
  16258.                 }catch(Exception e){
  16259.                     String errorMessage = "Errore durante l'invocazione dell'operazione ["+methodName+"] sulla risorsa ["+
  16260.                             risorsa+"] (params:"+params+"): "+e.getMessage();
  16261.                     this.logError(errorMessage,e);
  16262.                     resultReset = errorMessage;
  16263.                 }
  16264.                
  16265.             }
  16266.         }catch(Exception e){
  16267.             this.logError("ResetCache:"+e.getMessage(), e);
  16268.         }
  16269.        
  16270.         return ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO_MODIFICATA_CON_SUCCESSO_SENZA_RIAVVIO_RICHIESTO;
  16271.     }

  16272.     public void prepareGestorePolicyTokenList(ConsoleSearch ricerca, List<GenericProperties> lista, int idLista) throws Exception{
  16273.         try {
  16274.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN);

  16275.             String infoType = this.getParameter(ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE);
  16276.             if(infoType==null) {
  16277.                 infoType = ServletUtils.getObjectFromSession(this.request, this.session, String.class, ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE);
  16278.             }
  16279.             Parameter pInfoType = new Parameter(ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE, infoType);
  16280.             boolean attributeAuthority = ConfigurazioneCostanti.isConfigurazioneAttributeAuthority(infoType);
  16281.            
  16282.             // decido la vista custom da mostrare
  16283.             if(attributeAuthority) {
  16284.                 this.pd.setCustomListViewName(ConfigurazioneCostanti.CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_NOME_VISTA_CUSTOM_LISTA_ATTRIBUTE_AUTHORITY);
  16285.             } else {
  16286.                 this.pd.setCustomListViewName(ConfigurazioneCostanti.CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_NOME_VISTA_CUSTOM_LISTA_TOKEN_POLICIY);
  16287.             }
  16288.            
  16289.             int limit = ricerca.getPageSize(idLista);
  16290.             int offset = ricerca.getIndexIniziale(idLista);
  16291.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);
  16292.            
  16293.             PropertiesSourceConfiguration propertiesSourceConfiguration = attributeAuthority ?
  16294.                     this.confCore.getAttributeAuthorityPropertiesSourceConfiguration() :
  16295.                     this.confCore.getPolicyGestioneTokenPropertiesSourceConfiguration();
  16296.             ConfigManager configManager = ConfigManager.getinstance(ControlStationCore.getLog());
  16297.             configManager.leggiConfigurazioni(propertiesSourceConfiguration, true);
  16298.             List<String> nomiConfigurazioniPolicyGestioneToken = configManager.getNomiConfigurazioni(propertiesSourceConfiguration);
  16299.             List<String> labelConfigurazioniPolicyGestioneToken = configManager.convertToLabel(propertiesSourceConfiguration, nomiConfigurazioniPolicyGestioneToken);
  16300.            
  16301.             if(!attributeAuthority) {
  16302.                 String filterTipoTokenPolicy = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_TIPO_TOKEN_POLICY);
  16303.                 addFilterTipoTokenPolicy(filterTipoTokenPolicy, false, nomiConfigurazioniPolicyGestioneToken, labelConfigurazioniPolicyGestioneToken);
  16304.             }
  16305.            
  16306.             this.pd.setIndex(offset);
  16307.             this.pd.setPageSize(limit);
  16308.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  16309.            
  16310.             // setto la barra del titolo
  16311.             List<Parameter> lstParam = new ArrayList<>();

  16312.             String label = attributeAuthority ?
  16313.                     ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ATTRIBUTE_AUTHORITY :
  16314.                     ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN;
  16315.            
  16316.             lstParam.add(new Parameter(label, null));
  16317.            
  16318.             this.pd.setSearchLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_NOME);
  16319.             if(search.equals("")){
  16320.                 this.pd.setSearchDescription("");
  16321.             }else{
  16322.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  16323.             }

  16324.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  16325.            
  16326.             // controllo eventuali risultati ricerca
  16327.             if (!search.equals("")) {
  16328.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_NOME, search);
  16329.             }
  16330.            
  16331.             List<String> lstLabels = new ArrayList<>();
  16332.            
  16333.             boolean forceId = attributeAuthority ?
  16334.                     this.core.isAttributeAuthorityForceIdEnabled() :
  16335.                     this.core.isTokenPolicyForceIdEnabled();
  16336.            
  16337.             lstLabels.add(label);
  16338.            
  16339.             // setto le label delle colonne
  16340.             String[] labels = lstLabels.toArray(new String[lstLabels.size()]);
  16341.            
  16342.             this.pd.setLabels(labels);
  16343.        
  16344.             // preparo i dati
  16345.             List<List<DataElement>> dati = new ArrayList<>();

  16346.             if (lista != null) {
  16347.                 for (int i = 0; i < lista.size(); i++) {
  16348.                     List<DataElement> e = creaEntryTokenPolicyCustom(lista, pInfoType, attributeAuthority,
  16349.                             nomiConfigurazioniPolicyGestioneToken, labelConfigurazioniPolicyGestioneToken, forceId, i);
  16350.                    
  16351.                     dati.add(e);
  16352.                 }
  16353.             }

  16354.             this.pd.setDati(dati);
  16355.             this.pd.setAddButton(true);
  16356.            
  16357.             // preparo bottoni
  16358.             if(lista!=null && !lista.isEmpty() &&
  16359.                 (this.core.isShowPulsantiImportExport())
  16360.                 ){

  16361.                 ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);
  16362.                 org.openspcoop2.protocol.sdk.constants.ArchiveType archiveType = attributeAuthority ?
  16363.                         org.openspcoop2.protocol.sdk.constants.ArchiveType.CONFIGURAZIONE_ATTRIBUTE_AUTHORITY :
  16364.                         org.openspcoop2.protocol.sdk.constants.ArchiveType.CONFIGURAZIONE_TOKEN_POLICY;
  16365.                 if(exporterUtils.existsAtLeastOneExportMode(archiveType, this.request, this.session)){

  16366.                     List<AreaBottoni> bottoni = new ArrayList<>();

  16367.                     AreaBottoni ab = new AreaBottoni();
  16368.                     List<DataElement> otherbott = new ArrayList<>();
  16369.                     DataElement de = new DataElement();
  16370.                     if(attributeAuthority) {
  16371.                         de.setValue(ConfigurazioneCostanti.LABEL_ATTRIBUTE_AUTHORITY_ESPORTA_SELEZIONATI);
  16372.                         de.setOnClick(ConfigurazioneCostanti.LABEL_ATTRIBUTE_AUTHORITY_ESPORTA_SELEZIONATI_ONCLICK);
  16373.                     }
  16374.                     else {
  16375.                         de.setValue(ConfigurazioneCostanti.LABEL_TOKEN_POLICY_ESPORTA_SELEZIONATI);
  16376.                         de.setOnClick(ConfigurazioneCostanti.LABEL_TOKEN_POLICY_ESPORTA_SELEZIONATI_ONCLICK);
  16377.                     }
  16378.                     de.setDisabilitaAjaxStatus();
  16379.                     otherbott.add(de);
  16380.                     ab.setBottoni(otherbott);
  16381.                     bottoni.add(ab);

  16382.                     this.pd.setAreaBottoni(bottoni);

  16383.                 }

  16384.             }
  16385.            
  16386.         } catch (Exception e) {
  16387.             this.logError("Exception: " + e.getMessage(), e);
  16388.             throw new DriverControlStationException(e);
  16389.         }
  16390.     }
  16391.    
  16392.     public List<DataElement> creaEntryTokenPolicy(List<GenericProperties> lista, Parameter pInfoType,
  16393.             boolean attributeAuthority, List<String> nomiConfigurazioniPolicyGestioneToken,
  16394.             List<String> labelConfigurazioniPolicyGestioneToken, boolean forceId, int i) {
  16395.         List<DataElement> e = new ArrayList<>();
  16396.         GenericProperties policy = lista.get(i);
  16397.        
  16398.         Parameter pPolicyId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_ID, policy.getId() + "");

  16399.         DataElement de = new DataElement();
  16400.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_CHANGE, pInfoType, pPolicyId);
  16401.         de.setValue(policy.getNome());
  16402.         de.setIdToRemove(""+policy.getId());
  16403.         e.add(de);
  16404.        
  16405.         de = new DataElement();
  16406.         de.setValue(policy.getDescrizione());
  16407.         e.add(de);
  16408.        
  16409.         if(!forceId) {
  16410.             de = new DataElement();
  16411.             if(nomiConfigurazioniPolicyGestioneToken!=null && nomiConfigurazioniPolicyGestioneToken.contains(policy.getTipo())) {
  16412.                 boolean found = false;
  16413.                 for (int j = 0; j < nomiConfigurazioniPolicyGestioneToken.size(); j++) {
  16414.                     String nome = nomiConfigurazioniPolicyGestioneToken.get(j);
  16415.                     if(nome.equals(policy.getTipo())) {
  16416.                         de.setValue(labelConfigurazioniPolicyGestioneToken.get(j));
  16417.                         found = true;
  16418.                         break;
  16419.                     }
  16420.                 }
  16421.                 if(!found) {
  16422.                     de.setValue(policy.getTipo());
  16423.                 }
  16424.             }
  16425.             else {
  16426.                 de.setValue(policy.getTipo());
  16427.             }
  16428.             e.add(de);
  16429.         }
  16430.        
  16431.         InUsoType inUsoType = attributeAuthority ? InUsoType.ATTRIBUTE_AUTHORITY : InUsoType.TOKEN_POLICY;
  16432.         this.addInUsoButtonVisualizzazioneClassica(e, policy.getNome(), policy.getId()+"", inUsoType);
  16433.         return e;
  16434.     }
  16435.    
  16436.     private List<DataElement> creaEntryTokenPolicyCustom(List<GenericProperties> lista, Parameter pInfoType,
  16437.             boolean attributeAuthority, List<String> nomiConfigurazioniPolicyGestioneToken,
  16438.             List<String> labelConfigurazioniPolicyGestioneToken, boolean forceId, int i) {
  16439.         List<DataElement> e = new ArrayList<>();
  16440.         GenericProperties policy = lista.get(i);
  16441.        
  16442.         Parameter pPolicyId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_ID, policy.getId() + "");
  16443.        
  16444.         List<Parameter> listaParametriChange = new ArrayList<>();
  16445.         listaParametriChange.add(pInfoType);
  16446.         listaParametriChange.add(pPolicyId);
  16447.        
  16448.         // TITOLO nome
  16449.         DataElement de = new DataElement();
  16450.         de.setValue(policy.getNome());
  16451.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_CHANGE, pInfoType, pPolicyId);
  16452.         de.setSize(this.core.getElenchiMenuIdentificativiLunghezzaMassima());
  16453.         de.setIdToRemove(""+policy.getId());
  16454.         de.setType(DataElementType.TITLE);
  16455.         e.add(de);
  16456.        
  16457.         // seconda riga
  16458.         boolean visualizzaSecondaRiga = StringUtils.isNotBlank(policy.getDescrizione()) || !forceId || attributeAuthority;
  16459.        
  16460.         boolean verificaConnettivita = true;
  16461.        
  16462.         if(visualizzaSecondaRiga) {
  16463.             de = new DataElement();
  16464.             de.setValue(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_DESCRIZIONE, policy.getDescrizione()));
  16465.            
  16466.             if(!forceId) {
  16467.                
  16468.                 boolean validazione = ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN.equals(policy.getTipologia());
  16469.                 boolean negoziazione = ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_RETRIEVE_POLICY_TOKEN.equals(policy.getTipologia());
  16470.                
  16471.                 String labelTipo = policy.getTipo();
  16472.                 if(nomiConfigurazioniPolicyGestioneToken!=null && nomiConfigurazioniPolicyGestioneToken.contains(policy.getTipo())) {
  16473.                     boolean found = false;
  16474.                     for (int j = 0; j < nomiConfigurazioniPolicyGestioneToken.size(); j++) {
  16475.                         String nome = nomiConfigurazioniPolicyGestioneToken.get(j);
  16476.                         if(nome.equals(policy.getTipo())) {
  16477.                             labelTipo = labelConfigurazioniPolicyGestioneToken.get(j);
  16478.                             found = true;
  16479.                             break;
  16480.                         }
  16481.                     }
  16482.                     if(!found) {
  16483.                         labelTipo = policy.getTipo();
  16484.                     }
  16485.                 }
  16486.                 else {
  16487.                      labelTipo = policy.getTipo();
  16488.                 }
  16489.                
  16490.                 StringBuilder sb = new StringBuilder();
  16491.                 sb.append(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_TOKEN_POLICY_TIPO, labelTipo));
  16492.                 if(validazione) {
  16493.                    
  16494.                     GestioneToken gestioneToken = new GestioneToken();
  16495.                     gestioneToken.setIntrospection(StatoFunzionalitaConWarning.ABILITATO);
  16496.                     gestioneToken.setUserInfo(StatoFunzionalitaConWarning.ABILITATO);
  16497.                     gestioneToken.setValidazione(StatoFunzionalitaConWarning.ABILITATO);
  16498.                     gestioneToken.setForward(StatoFunzionalita.ABILITATO);
  16499.                     try {
  16500.                         PolicyGestioneToken policyGestioneToken = TokenUtilities.convertTo(policy, gestioneToken);
  16501.    
  16502.                         String labelToken = policyGestioneToken.getLabelTipoToken();
  16503.                         sb.append(ConfigurazioneCostanti.MESSAGE_METADATI_SEPARATORE);
  16504.                         sb.append(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_TOKEN_POLICY_TOKEN, labelToken));
  16505.                        
  16506.                         String labelValidazione = policyGestioneToken.getAzioniGestioneToken();
  16507.                         labelValidazione = labelValidazione.replace("JWT", "ValidazioneJWT");
  16508.                         labelValidazione = labelValidazione.replace(",", " - ").trim();
  16509.                        
  16510.                         sb.append(ConfigurazioneCostanti.MESSAGE_METADATI_SEPARATORE);
  16511.                         sb.append(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_TOKEN_POLICY_MODALITA, labelValidazione));
  16512.                    
  16513.                         String labelForward = policyGestioneToken.getAzioniForwardToken();
  16514.                         labelForward = labelForward.replace(",", " - ").trim();
  16515.                         sb.append(ConfigurazioneCostanti.MESSAGE_METADATI_SEPARATORE);
  16516.                         sb.append(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_TOKEN_POLICY_FORWARD, labelForward));
  16517.                        
  16518.                         if(!policyGestioneToken.isDynamicDiscovery() && !policyGestioneToken.isIntrospection() && !policyGestioneToken.isUserInfo()) {
  16519.                             if(policyGestioneToken.isValidazioneJWT()) {
  16520.                                 verificaConnettivita = policyGestioneToken.isValidazioneJWTLocationHttp();
  16521.                             }
  16522.                             else {
  16523.                                 verificaConnettivita = false;
  16524.                             }
  16525.                         }
  16526.                        
  16527.                     }catch(Exception t) {
  16528.                         this.logError(t.getMessage(),t);
  16529.                     }
  16530.                
  16531.                     if(StringUtils.isNotBlank(policy.getDescrizione())) {
  16532.                         sb.append(ConfigurazioneCostanti.MESSAGE_METADATI_SEPARATORE);
  16533.                         sb.append(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_TOKEN_POLICY_DESCRIZIONE, labelTipo, policy.getDescrizione()));
  16534.                     }
  16535.                 }
  16536.                 else if(negoziazione) {
  16537.                
  16538.                     try {
  16539.                         PolicyNegoziazioneToken policyNegoziazione = TokenUtilities.convertTo(policy);
  16540.                        
  16541.                         String labelModalita = policyNegoziazione.getLabelGrant();
  16542.                         sb.append(ConfigurazioneCostanti.MESSAGE_METADATI_SEPARATORE);
  16543.                         sb.append(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_TOKEN_POLICY_MODALITA, labelModalita));
  16544.                     }catch(Exception t) {
  16545.                         this.logError(t.getMessage(),t);
  16546.                     }
  16547.                    
  16548.                     if(StringUtils.isNotBlank(policy.getDescrizione())) {
  16549.                         sb.append(ConfigurazioneCostanti.MESSAGE_METADATI_SEPARATORE);
  16550.                         sb.append(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_TOKEN_POLICY_DESCRIZIONE, labelTipo, policy.getDescrizione()));
  16551.                     }
  16552.                 }
  16553.                 else {
  16554.                     if(StringUtils.isNotBlank(policy.getDescrizione())) {
  16555.                         sb.append(ConfigurazioneCostanti.MESSAGE_METADATI_SEPARATORE);
  16556.                         sb.append(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_TOKEN_POLICY_DESCRIZIONE, labelTipo, policy.getDescrizione()));
  16557.                     }
  16558.                 }
  16559.                
  16560.                 de.setValue(sb.toString());

  16561.             }
  16562.             else {
  16563.                 if(attributeAuthority) {
  16564.                     String tipoRisposta = null;
  16565.                     String attributi = null;
  16566.                     for (Property p : policy.getPropertyList()) {
  16567.                         if(org.openspcoop2.pdd.core.token.attribute_authority.Costanti.AA_RESPONSE_TYPE.equals(p.getNome())){
  16568.                             tipoRisposta = p.getValore();
  16569.                         }
  16570.                         else if(org.openspcoop2.pdd.core.token.attribute_authority.Costanti.AA_RESPONSE_ATTRIBUTES.equals(p.getNome())){
  16571.                             attributi = p.getValore();
  16572.                         }
  16573.                     }
  16574.                     TipologiaResponseAttributeAuthority tipologiaResponse = null;
  16575.                     if(tipoRisposta!=null) {
  16576.                         tipologiaResponse = TipologiaResponseAttributeAuthority.valueOf(tipoRisposta);
  16577.                     }
  16578.                     if(!TipologiaResponseAttributeAuthority.custom.equals(tipologiaResponse)) {
  16579.                         if(attributi==null || StringUtils.isBlank(attributi)) {
  16580.                             attributi = "qualsiasi";
  16581.                         }
  16582.                     }
  16583.                     if(StringUtils.isNotBlank(policy.getDescrizione()) && StringUtils.isNotBlank(attributi)) {
  16584.                         de.setValue(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_ATTRIBUTE_AUTHORITY_ATTRIBUTI_E_DESCRIZIONE, attributi, policy.getDescrizione()));
  16585.                     }
  16586.                     else if(StringUtils.isNotBlank(attributi)) {
  16587.                         de.setValue(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_ATTRIBUTE_AUTHORITY_SOLO_ATTRIBUTI, attributi));
  16588.                     }
  16589.                     else if(StringUtils.isNotBlank(policy.getDescrizione())) {
  16590.                         de.setValue(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_DESCRIZIONE, policy.getDescrizione()));
  16591.                     }
  16592.                     else {
  16593.                         visualizzaSecondaRiga = false;
  16594.                     }
  16595.                 }
  16596.             }
  16597.            
  16598.             if(visualizzaSecondaRiga) {
  16599.                 de.setType(DataElementType.SUBTITLE);
  16600.                 e.add(de);
  16601.             }
  16602.         }
  16603.        
  16604.         listaParametriChange.add(new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CERTIFICATI_FROM_LISTA, "true"));
  16605.         listaParametriChange.add(new Parameter(CostantiControlStation.PARAMETRO_RESET_CACHE_FROM_LISTA, "true"));
  16606.        
  16607.         // in uso
  16608.         InUsoType inUsoType = attributeAuthority ? InUsoType.ATTRIBUTE_AUTHORITY : InUsoType.TOKEN_POLICY;
  16609.         this.addInUsoButton(e, policy.getNome(), policy.getId()+"", inUsoType);
  16610.                
  16611.         // validazione certificati
  16612.         boolean visualizzaValidazioneCertificati = attributeAuthority ? this.core.isAttributeAuthorityVerificaCertificati() : this.core.isPolicyGestioneTokenVerificaCertificati();
  16613.         if(visualizzaValidazioneCertificati) {
  16614.             this.addVerificaCertificatiButton(e, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_VERIFICA_CERTIFICATI, listaParametriChange);
  16615.         }
  16616.        
  16617.         // verifica connettivita
  16618.         if(verificaConnettivita) {
  16619.             List<Parameter> listaParametriVerificaConnettivitaChange = new ArrayList<>();
  16620.             listaParametriVerificaConnettivitaChange.addAll(listaParametriChange);
  16621.             listaParametriVerificaConnettivitaChange.add(new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTIVITA, "true"));
  16622.             this.addVerificaConnettivitaButton(e, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_VERIFICA_CERTIFICATI, listaParametriVerificaConnettivitaChange);
  16623.         }
  16624.                
  16625.         // se e' abilitata l'opzione reset cache per elemento, visualizzo il comando nell'elenco dei comandi disponibili nella lista
  16626.         if(this.core.isElenchiVisualizzaComandoResetCacheSingoloElemento()){
  16627.             this.addComandoResetCacheButton(e,policy.getNome(), ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_CHANGE, listaParametriChange);
  16628.         }
  16629.        
  16630.         // Proprieta Button
  16631.         /**if(this.existsProprietaOggetto(policy.getProprietaOggetto(), policy.getDescrizione())) {
  16632.          * la lista non riporta le proprietà. Ma esistono e poi sarà la servlet a gestirlo
  16633.          */
  16634.         this.addProprietaOggettoButton(e, policy.getNome(), policy.getId()+"", inUsoType);
  16635.        
  16636.         return e;
  16637.        
  16638.     }

  16639.     public List<DataElement> addPolicyGestioneTokenToDati(TipoOperazione tipoOperazione, List<DataElement> dati, String id, String nome, String descrizione, String tipo, String[] propConfigPolicyGestioneTokenLabelList, String[] propConfigPolicyGestioneTokenList,
  16640.             boolean attributeAuthority, GenericProperties genericProperties) throws Exception {
  16641.        
  16642.         if(TipoOperazione.CHANGE.equals(tipoOperazione)){
  16643.            
  16644.             Parameter pPolicyId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_ID, id);
  16645.            
  16646.             String infoType = this.getParameter(ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE);
  16647.             if(infoType==null) {
  16648.                 infoType = ServletUtils.getObjectFromSession(this.request, this.session, String.class, ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE);
  16649.             }
  16650.             Parameter pInfoType = new Parameter(ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE, infoType);
  16651.            
  16652.             List<Parameter> listaParametriChange = new ArrayList<>();
  16653.             listaParametriChange.add(pInfoType);
  16654.             listaParametriChange.add(pPolicyId);
  16655.            
  16656.             boolean verificaConnettivita = true;
  16657.             boolean validazione = ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN.equals(genericProperties.getTipologia());
  16658.             if(validazione) {
  16659.                 GestioneToken gestioneToken = new GestioneToken();
  16660.                 gestioneToken.setIntrospection(StatoFunzionalitaConWarning.ABILITATO);
  16661.                 gestioneToken.setUserInfo(StatoFunzionalitaConWarning.ABILITATO);
  16662.                 gestioneToken.setValidazione(StatoFunzionalitaConWarning.ABILITATO);
  16663.                 gestioneToken.setForward(StatoFunzionalita.ABILITATO);
  16664.                 try {
  16665.                     PolicyGestioneToken policyGestioneToken = TokenUtilities.convertTo(genericProperties, gestioneToken);
  16666.                     if(!policyGestioneToken.isIntrospection() && !policyGestioneToken.isUserInfo()) {
  16667.                         verificaConnettivita = false;
  16668.                     }
  16669.                 }catch(Exception t) {
  16670.                     this.logError(t.getMessage(),t);
  16671.                 }
  16672.             }
  16673.            
  16674.             // In Uso Button
  16675.             InUsoType inUsoType = attributeAuthority ? InUsoType.ATTRIBUTE_AUTHORITY : InUsoType.TOKEN_POLICY;
  16676.             this.addComandoInUsoButton(nome,
  16677.                     id,
  16678.                     inUsoType);
  16679.            
  16680.             // Verifica Certificati
  16681.             boolean visualizzaValidazioneCertificati = attributeAuthority ? this.core.isAttributeAuthorityVerificaCertificati() : this.core.isPolicyGestioneTokenVerificaCertificati();
  16682.             if(visualizzaValidazioneCertificati) {
  16683.                 this.pd.addComandoVerificaCertificatiElementoButton(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_VERIFICA_CERTIFICATI, listaParametriChange);
  16684.             }
  16685.            
  16686.             // verifica connettivita
  16687.             if(verificaConnettivita) {
  16688.                 List<Parameter> listaParametriVerificaConnettivitaChange = new ArrayList<>();
  16689.                 listaParametriVerificaConnettivitaChange.addAll(listaParametriChange);
  16690.                 listaParametriVerificaConnettivitaChange.add(new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTIVITA, "true"));
  16691.                 this.pd.addComandoVerificaConnettivitaElementoButton(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_VERIFICA_CERTIFICATI, listaParametriVerificaConnettivitaChange);
  16692.             }
  16693.                
  16694.             // se e' abilitata l'opzione reset cache per elemento, visualizzo il comando nell'elenco dei comandi disponibili nella lista
  16695.             if(this.core.isElenchiVisualizzaComandoResetCacheSingoloElemento()){
  16696.                 listaParametriChange.add(new Parameter(CostantiControlStation.PARAMETRO_ELIMINA_ELEMENTO_DALLA_CACHE, "true"));
  16697.                 this.pd.addComandoResetCacheElementoButton(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_CHANGE, listaParametriChange);
  16698.             }
  16699.            
  16700.             // Proprieta Button
  16701.             if(this.existsProprietaOggetto(genericProperties.getProprietaOggetto(), genericProperties.getDescrizione())) {
  16702.                 this.addComandoProprietaOggettoButton(nome,
  16703.                         id,
  16704.                         inUsoType);
  16705.             }
  16706.         }
  16707.        

  16708.        
  16709.        
  16710.         boolean forceIdEnabled = attributeAuthority ?
  16711.                 this.confCore.isAttributeAuthorityForceIdEnabled() :
  16712.                 this.confCore.isTokenPolicyForceIdEnabled() ;
  16713.        
  16714.         DataElement de = new DataElement();
  16715.         de.setLabel(attributeAuthority ?
  16716.                 ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ATTRIBUTE_AUTHORITY :
  16717.                 ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN);
  16718.         de.setType(DataElementType.TITLE);
  16719.         dati.add(de);
  16720.        
  16721.         // id
  16722.         de = new DataElement();
  16723.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_ID);
  16724.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_ID);
  16725.         de.setType(DataElementType.HIDDEN);
  16726.         de.setValue(id);
  16727.         dati.add(de);

  16728.         // tipo
  16729.        
  16730.         de = new DataElement();
  16731.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPO);
  16732.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPO);
  16733.         if(!forceIdEnabled) {
  16734.             if(tipoOperazione.equals(TipoOperazione.ADD)) {
  16735.                 de.setType(DataElementType.SELECT);
  16736.                 de.setPostBack(true);
  16737.                 de.setValues(propConfigPolicyGestioneTokenList);
  16738.                 de.setLabels(propConfigPolicyGestioneTokenLabelList);
  16739.                 de.setSelected(tipo);
  16740.                 de.setRequired(true);
  16741.             }else {
  16742.                 de.setType(DataElementType.HIDDEN);
  16743.                 de.setValue(tipo);
  16744.                 dati.add(de);
  16745.                
  16746.                 de = new DataElement();
  16747.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPO);
  16748.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  16749.                 de.setType(DataElementType.TEXT);
  16750.                 if(propConfigPolicyGestioneTokenList!=null && propConfigPolicyGestioneTokenList.length>0) {
  16751.                     boolean found = false;
  16752.                     for (int j = 0; j < propConfigPolicyGestioneTokenList.length; j++) {
  16753.                         String nomeP = propConfigPolicyGestioneTokenList[j];
  16754.                         if(nomeP.equals(tipo)) {
  16755.                             de.setValue(propConfigPolicyGestioneTokenLabelList[j]);
  16756.                             found = true;
  16757.                             break;
  16758.                         }
  16759.                     }
  16760.                     if(!found) {
  16761.                         de.setValue(tipo);
  16762.                     }
  16763.                 }
  16764.                 else {
  16765.                     de.setValue(tipo);
  16766.                 }
  16767.             }
  16768.         } else {
  16769.             de.setType(DataElementType.HIDDEN);
  16770.             de.setValue(tipo);
  16771.         }
  16772.         dati.add(de);
  16773.        
  16774.         // nome
  16775.         de = new DataElement();
  16776.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_NOME);
  16777.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_NOME);
  16778.         if(tipoOperazione.equals(TipoOperazione.ADD)) {
  16779.             de.setType(DataElementType.TEXT_EDIT);
  16780.             de.setRequired(true);
  16781.         } else {
  16782.             de.setType(DataElementType.TEXT);
  16783.         }
  16784.         de.setValue(nome);
  16785.         dati.add(de);
  16786.        
  16787.         // descrizione
  16788.         de = new DataElement();
  16789.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_DESCRIZIONE);
  16790.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_DESCRIZIONE);
  16791.         de.setType(DataElementType.TEXT_AREA);
  16792.         de.setRows(2);
  16793.         de.setValue(descrizione);
  16794.         dati.add(de);

  16795.        
  16796.         return dati;
  16797.     }

  16798.     public boolean policyGestioneTokenCheckData(TipoOperazione tipoOperazione, String nome, String descrizione, String tipo,String tipologia) throws DriverControlStationException {
  16799.        
  16800.         if(tipoOperazione.equals(TipoOperazione.ADD)) {
  16801.             // Nome
  16802.             if(StringUtils.isEmpty(nome)){
  16803.                 String messaggio = "Deve essere indicato un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_NOME+"'";
  16804.                 this.pd.setMessage(messaggio);
  16805.                 return false;
  16806.             }
  16807.             if(nome.contains(" ")){
  16808.                 String messaggio = "Deve essere indicato un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_NOME+"' senza spazi";
  16809.                 this.pd.setMessage(messaggio);
  16810.                 return false;
  16811.             }
  16812.            
  16813.            
  16814.             // Tipo
  16815.             if(StringUtils.isEmpty(tipo)  || CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(tipo)){
  16816.                 String messaggio = "Deve essere indicato un valore in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPO+"'";
  16817.                 this.pd.setMessage(messaggio);
  16818.                 return false;
  16819.             }
  16820.        
  16821.             // Lunghezze
  16822.             if(!this.checkLength255(nome, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_NOME)) {
  16823.                 return false;
  16824.             }
  16825.            
  16826.             try {
  16827.                 // check duplicati per tipologia
  16828.                 this.confCore.getGenericProperties(nome, tipologia,false);
  16829.                 String messaggio = "&Egrave; gi&agrave; presente un Policy, del tipo indicato, con nome " + nome ;
  16830.                 this.pd.setMessage(messaggio);
  16831.                 return false;
  16832.             } catch(DriverConfigurazioneNotFound e) {
  16833.                 // ok
  16834.             } catch(Exception e) {
  16835.                 throw new DriverControlStationException(e.getMessage(),e);
  16836.             }
  16837.         }
  16838.        
  16839.         // Anche in change
  16840.         if(descrizione!=null && !"".equals(descrizione) &&
  16841.                 !this.checkLength4000(descrizione, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_DESCRIZIONE)) {
  16842.             return false;
  16843.         }
  16844.        
  16845.         if(tipoOperazione.equals(TipoOperazione.ADD)) {
  16846.             // nop
  16847.         }
  16848.        
  16849.         return true;
  16850.     }
  16851.    
  16852.     public String replaceToHtmlSeparator(String value) {
  16853.         return this.replaceSeparator(value, "\n", org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  16854.     }
  16855.     public String replaceSeparator(String value, String originale,String destinazione) {
  16856.         if(value!=null) {
  16857.             while(value.contains(originale)) {
  16858.                 value = value.replace(originale, destinazione);
  16859.             }
  16860.         }
  16861.         return value;
  16862.     }
  16863.    
  16864.     // Prepara la lista delle regole di configurazione proxy pass
  16865.     public void prepareProxyPassConfigurazioneRegolaList(ISearch ricerca, List<ConfigurazioneUrlInvocazioneRegola> lista) throws Exception {
  16866.         try {
  16867.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_PROXY_PASS_REGOLA);

  16868.             int idLista = Liste.CONFIGURAZIONE_PROXY_PASS_REGOLA;
  16869.             int limit = ricerca.getPageSize(idLista);
  16870.             int offset = ricerca.getIndexIniziale(idLista);
  16871.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  16872.             this.pd.setIndex(offset);
  16873.             this.pd.setPageSize(limit);
  16874.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  16875.            
  16876.             // setto la barra del titolo
  16877.             List<Parameter> lstParam = new ArrayList<>();

  16878.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  16879.            
  16880.            
  16881.             this.pd.setSearchLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_NOME);
  16882.             if(search.equals("")){
  16883.                 this.pd.setSearchDescription("");
  16884.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROXY_PASS_REGOLE, null));
  16885.             }else{
  16886.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PROXY_PASS_REGOLE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PROXY_PASS_REGOLA_LIST));
  16887.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  16888.             }

  16889.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  16890.            
  16891.             // controllo eventuali risultati ricerca
  16892.             if (!search.equals("")) {
  16893.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_NOME, search);
  16894.             }

  16895.             // setto le label delle colonne
  16896.             List<String> lstLabels = new ArrayList<>();
  16897.             if(lista != null && lista.size() > 1)
  16898.                 lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_POSIZIONE);
  16899.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_STATO);
  16900.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_NOME);
  16901.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_DESCRIZIONE);
  16902.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  16903.             // preparo i dati
  16904.             List<List<DataElement>> dati = new ArrayList<>();

  16905.             if (lista != null) {
  16906.                 Iterator<ConfigurazioneUrlInvocazioneRegola> it = lista.iterator();
  16907.                 int numeroElementi = lista.size();
  16908.                 int i = 0;
  16909.                 while (it.hasNext()) {
  16910.                     ConfigurazioneUrlInvocazioneRegola regola = it.next();

  16911.                     List<DataElement> e = new ArrayList<>();
  16912.                     Parameter pIdRegola = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_ID_REGOLA, regola.getId() + "");
  16913.                    
  16914.                     // Posizione
  16915.                     if(lista.size() > 1) {
  16916.                         DataElement de = new DataElement();
  16917.                         de.setWidthPx(48);
  16918.                         de.setType(DataElementType.IMAGE);
  16919.                         DataElementImage imageUp = new DataElementImage();
  16920.                         Parameter pDirezioneSu = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_POSIZIONE,
  16921.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SU);
  16922.                         Parameter pDirezioneGiu = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_POSIZIONE,
  16923.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_GIU);
  16924.                                
  16925.                         if(i > 0) {
  16926.                             imageUp.setImage(CostantiControlStation.ICONA_FRECCIA_SU);
  16927.                             imageUp.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_SU);
  16928.                             imageUp.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PROXY_PASS_REGOLA_LIST, pIdRegola, pDirezioneSu);
  16929.                         }
  16930.                         else {
  16931.                             imageUp.setImage(CostantiControlStation.ICONA_PLACEHOLDER);
  16932.                         }
  16933.                         de.addImage(imageUp);
  16934.                        
  16935.                         if(i < numeroElementi -1) {
  16936.                             DataElementImage imageDown = new DataElementImage();
  16937.                             imageDown.setImage(CostantiControlStation.ICONA_FRECCIA_GIU);
  16938.                             imageDown.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_GIU);
  16939.                             imageDown.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PROXY_PASS_REGOLA_LIST, pIdRegola, pDirezioneGiu);
  16940.                             de.addImage(imageDown);
  16941.                         }
  16942.                         de.setValue(regola.getPosizione()+"");
  16943.                         e.add(de);
  16944.                     }
  16945.                    
  16946.                     // Stato
  16947.                     DataElement de = new DataElement();
  16948.                     de.setWidthPx(10);
  16949.                     de.setType(DataElementType.CHECKBOX);
  16950.                     if(regola.getStato()==null // backward compatibility
  16951.                             ||
  16952.                             StatoFunzionalita.ABILITATO.equals(regola.getStato())){
  16953.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  16954.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  16955.                         de.setSelected(CheckboxStatusType.CONFIG_ENABLE);
  16956.                     }
  16957.                     else{
  16958.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  16959.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  16960.                         de.setSelected(CheckboxStatusType.CONFIG_DISABLE);
  16961.                     }
  16962.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PROXY_PASS_REGOLA_CHANGE, pIdRegola);
  16963.                     e.add(de);
  16964.                    
  16965.                    
  16966.                     // Nome
  16967.                     de = new DataElement();
  16968.                     de.setIdToRemove(regola.getId() + "");
  16969.                     de.setValue(regola.getNome());
  16970.                     de.setToolTip(regola.getNome());
  16971.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PROXY_PASS_REGOLA_CHANGE, pIdRegola);
  16972.                     e.add(de);
  16973.                    
  16974.                     de = new DataElement();
  16975.                     if(regola.getDescrizione() != null && regola.getDescrizione().length() > 100) {
  16976.                         de.setValue(regola.getDescrizione().substring(0, 97)+"...");
  16977.                         de.setToolTip(regola.getDescrizione());
  16978.                     } else {
  16979.                         de.setValue(regola.getDescrizione());
  16980.                     }
  16981.                    
  16982.                     e.add(de);

  16983.                     dati.add(e);
  16984.                     i++;
  16985.                 }
  16986.             }

  16987.             this.pd.setDati(dati);
  16988.             this.pd.setAddButton(true);
  16989.            
  16990.             // preparo bottoni
  16991.             if(lista!=null && lista.size()>0){
  16992.                 if (this.core.isShowPulsantiImportExport()) {

  16993.                     ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);
  16994.                     if(exporterUtils.existsAtLeastOneExportMode(org.openspcoop2.protocol.sdk.constants.ArchiveType.CONFIGURAZIONE_URL_INVOCAZIONE_REGOLA, this.request, this.session)){

  16995.                         List<AreaBottoni> bottoni = new ArrayList<>();

  16996.                         AreaBottoni ab = new AreaBottoni();
  16997.                         List<DataElement> otherbott = new ArrayList<>();
  16998.                         DataElement de = new DataElement();
  16999.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_URL_INVOCAZIONE_REGOLA_ESPORTA_SELEZIONATI);
  17000.                         de.setOnClick(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_URL_INVOCAZIONE_REGOLA_ESPORTA_SELEZIONATI_ONCLICK);
  17001.                         de.setDisabilitaAjaxStatus();
  17002.                         otherbott.add(de);
  17003.                         ab.setBottoni(otherbott);
  17004.                         bottoni.add(ab);

  17005.                         this.pd.setAreaBottoni(bottoni);

  17006.                     }

  17007.                 }
  17008.             }
  17009.            
  17010.         } catch (Exception e) {
  17011.             this.logError("Exception: " + e.getMessage(), e);
  17012.             throw new DriverControlStationException(e);
  17013.         }
  17014.     }
  17015.    
  17016.     // Controlla i dati del registro
  17017.     public boolean proxyPassConfigurazioneRegolaCheckData(TipoOperazione tipoOp, String oldNome) throws Exception {

  17018.         try{
  17019.            
  17020.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_NOME);
  17021.            
  17022.             if(StringUtils.isEmpty(nome)){
  17023.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_NOME));
  17024.                 return false;
  17025.             }
  17026.            
  17027.             if(!this.checkLength(nome, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_NOME, 1, 255)) {
  17028.                 return false;
  17029.             }
  17030.            
  17031.             String stato = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_STATO);
  17032.            
  17033.             if(StringUtils.isEmpty(stato)){
  17034.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_STATO));
  17035.                 return false;
  17036.             } else {
  17037.                 if(!stato.equals(StatoFunzionalita.ABILITATO.getValue()) && !stato.equals(StatoFunzionalita.DISABILITATO.getValue())) {
  17038.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_NON_VALIDO,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_STATO));
  17039.                     return false;
  17040.                 }
  17041.             }
  17042.            
  17043.             String regolaText = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_REGOLA_TEXT);
  17044.            
  17045.             if(StringUtils.isEmpty(regolaText)){
  17046.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_REGOLA_TEXT));
  17047.                 return false;
  17048.             }
  17049.            
  17050.             if(!this.checkLength(regolaText, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_REGOLA_TEXT, 1, 255)) {
  17051.                 return false;
  17052.             }
  17053.            
  17054.             String contestoEsterno = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_CONTESTO_ESTERNO);
  17055.            
  17056.             /*
  17057.             if(StringUtils.isEmpty(contestoEsterno)){
  17058.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_CONTESTO_ESTERNO));
  17059.                 return false;
  17060.             }
  17061.             */
  17062.            
  17063.             if(!StringUtils.isEmpty(contestoEsterno)){
  17064.                 if(contestoEsterno.contains(" ")) {
  17065.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_SPAZI_BIANCHI_NON_AMMESSI, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_CONTESTO_ESTERNO));  
  17066.                     return false;
  17067.                 }
  17068.                
  17069.                 if(!this.checkLength(contestoEsterno, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_CONTESTO_ESTERNO, 1, 255)) {
  17070.                     return false;
  17071.                 }
  17072.             }
  17073.            
  17074.             String baseUrl = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_BASE_URL);
  17075.            
  17076.             if(!StringUtils.isEmpty(baseUrl)){
  17077.                 if(baseUrl.contains(" ")) {
  17078.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_SPAZI_BIANCHI_NON_AMMESSI, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_BASE_URL));  
  17079.                     return false;
  17080.                 }
  17081.                
  17082.                 if(!this.checkLength(baseUrl, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_BASE_URL, 1, 255)) {
  17083.                     return false;
  17084.                 }
  17085.                
  17086.                 try{
  17087.                     org.openspcoop2.utils.regexp.RegExpUtilities.validateUrl(baseUrl, true);
  17088.                 }catch(Exception e){
  17089.                     this.pd.setMessage(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_BASE_URL + " non correttamente formata: "+e.getMessage());
  17090.                     return false;
  17091.                 }
  17092.             }
  17093.            
  17094. //          String protocollo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_PROFILO);
  17095. //          
  17096. //          if(!StringUtils.isEmpty(protocollo)){
  17097. //              
  17098. //              // valida protocollo
  17099. //              
  17100. //              String soggetto = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_SOGGETTO);
  17101. //              
  17102. //              if(!StringUtils.isEmpty(soggetto)){
  17103. //                  // valida id soggetto
  17104. //              }
  17105. //          }
  17106.            
  17107.             String ruolo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_RUOLO);
  17108.             if(!StringUtils.isEmpty(ruolo)){
  17109.                 if(!ruolo.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PROXY_PASS_REGOLA_RUOLO_EROGAZIONE) && !ruolo.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PROXY_PASS_REGOLA_RUOLO_FRUIZIONE)){
  17110.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_NON_VALIDO,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_RUOLO));
  17111.                     return false;
  17112.                 }
  17113.             }
  17114.             String serviceBinding = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_SERVICE_BINDING);
  17115.            
  17116.             if(!StringUtils.isEmpty(serviceBinding)){
  17117.                 if(!serviceBinding.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_SOAP) && !serviceBinding.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_REST)) {
  17118.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_NON_VALIDO,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_SERVICE_BINDING));
  17119.                     return false;
  17120.                 }
  17121.             }
  17122.            

  17123.             // Se tipoOp = add, controllo che la regola non sia gia' stata registrata
  17124.             if (tipoOp.equals(TipoOperazione.ADD)) {
  17125.                 boolean giaRegistrato = this.confCore.existsProxyPassConfigurazioneRegola(nome);

  17126.                 if (giaRegistrato) {
  17127.                     this.pd.setMessage("&Egrave; gi&agrave; presente una Regola di Proxy Pass con questo nome.");
  17128.                     return false;
  17129.                 }
  17130.             } else { // change controllo che se ho modificato il nome, il nuovo nome non sia comunque utilizzato
  17131.                 if(!oldNome.equals(nome)) {
  17132.                     boolean giaRegistrato = this.confCore.existsProxyPassConfigurazioneRegola(nome);

  17133.                     if (giaRegistrato) {
  17134.                         this.pd.setMessage("&Egrave; gi&agrave; presente una Regola di Proxy Pass con questo nome.");
  17135.                         return false;
  17136.                     }
  17137.                 }
  17138.             }

  17139.             return true;

  17140.         } catch (Exception e) {
  17141.             this.logError("Exception: " + e.getMessage(), e);
  17142.             throw new DriverControlStationException(e);
  17143.         }
  17144.     }
  17145.    

  17146.     public CanaliConfigurazione getGestioneCanali(boolean canaliEnabled, String canaliDefault, List<CanaleConfigurazione> canaleList, String canaliNome,
  17147.             String canaliDescrizione, List<CanaleConfigurazioneNodo> nodoList) {
  17148.         CanaliConfigurazione configurazione = new CanaliConfigurazione();
  17149.        
  17150.         if(canaliEnabled) {
  17151.             configurazione.setStato(StatoFunzionalita.ABILITATO);
  17152.            
  17153.             if(canaleList == null)
  17154.                 canaleList = new ArrayList<>();
  17155.            
  17156.             if(canaliDefault != null) {
  17157.                 // viene modificato solo il canale default
  17158.                 for (CanaleConfigurazione canaleConfigurazione : canaleList) {
  17159.                     canaleConfigurazione.setCanaleDefault(false);
  17160.                 }
  17161.                
  17162.                 for (CanaleConfigurazione canaleConfigurazione : canaleList) {
  17163.                     if(canaleConfigurazione.getNome().equals(canaliDefault)) {
  17164.                         canaleConfigurazione.setCanaleDefault(true);
  17165.                         break;
  17166.                     }
  17167.                 }
  17168.             } else {
  17169.                 // creo il canale default
  17170.                
  17171.                 CanaleConfigurazione canaleConfigurazione = new CanaleConfigurazione();
  17172.                 canaleConfigurazione.setNome(canaliNome);
  17173.                 canaleConfigurazione.setDescrizione(canaliDescrizione);
  17174.                 canaleConfigurazione.setCanaleDefault(true);
  17175.                
  17176.                 canaleList.add(canaleConfigurazione);
  17177.             }
  17178.            
  17179.             configurazione.setCanaleList(canaleList);
  17180.            
  17181.             if(nodoList == null)
  17182.                 nodoList = new ArrayList<>();
  17183.            
  17184.             configurazione.setNodoList(nodoList);
  17185.         } else {
  17186.             configurazione.setStato(StatoFunzionalita.DISABILITATO);
  17187.         }
  17188.        
  17189.         return configurazione;
  17190.     }
  17191.     public void prepareCanaleConfigurazioneList(ConsoleSearch ricerca, List<CanaleConfigurazione> lista) throws Exception {
  17192.         try {
  17193.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_CANALI);

  17194.             int idLista = Liste.CONFIGURAZIONE_CANALI;

  17195.             int limit = ricerca.getPageSize(idLista);
  17196.             int offset = ricerca.getIndexIniziale(idLista);
  17197.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  17198.             this.pd.setIndex(offset);
  17199.             this.pd.setPageSize(limit);
  17200.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  17201.            
  17202.             // setto la barra del titolo
  17203.             List<Parameter> lstParam = new ArrayList<>();

  17204.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  17205.            
  17206.            
  17207.             this.pd.setSearchLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NOME);
  17208.             if(search.equals("")){
  17209.                 this.pd.setSearchDescription("");
  17210.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CANALI, null));
  17211.             }else{
  17212.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CANALI, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CANALI_LIST));
  17213.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  17214.             }

  17215.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  17216.            
  17217.             // controllo eventuali risultati ricerca
  17218.             if (!search.equals("")) {
  17219.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NOME, search);
  17220.             }

  17221.             // setto le label delle colonne
  17222.             List<String> lstLabels = new ArrayList<>();
  17223.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NOME);
  17224.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_DESCRIZIONE);
  17225.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_DEFAULT);
  17226.             lstLabels.add(CostantiControlStation.LABEL_IN_USO_COLONNA_HEADER); // inuso
  17227.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  17228.             // preparo i dati
  17229.             List<List<DataElement>> dati = new ArrayList<>();

  17230.             if (lista != null) {

  17231.                 Iterator<CanaleConfigurazione> it = lista.iterator();
  17232.                 while (it.hasNext()) {
  17233.                     CanaleConfigurazione regola = it.next();

  17234.                     List<DataElement> e = new ArrayList<>();
  17235.                     Parameter pIdCanale = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_ID_CANALE, regola.getId() + "");
  17236.                    
  17237.                     // Nome
  17238.                     DataElement de = new DataElement();
  17239.                     de.setIdToRemove(regola.getId() + "");
  17240.                     de.setValue(regola.getNome());
  17241.                     de.setToolTip(regola.getNome());
  17242.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CANALI_CHANGE, pIdCanale);
  17243.                     e.add(de);
  17244.                    
  17245.                     de = new DataElement();
  17246.                     if(regola.getDescrizione() != null && regola.getDescrizione().length() > 100) {
  17247.                         de.setValue(regola.getDescrizione().substring(0, 97)+"...");
  17248.                         de.setToolTip(regola.getDescrizione());
  17249.                     } else {
  17250.                         de.setValue(regola.getDescrizione());
  17251.                     }
  17252.                    
  17253.                     e.add(de);
  17254.                    
  17255.                     // Default
  17256.                     de = new DataElement();
  17257.                     de.setWidthPx(10);
  17258.                     if(regola.isCanaleDefault()){
  17259.                         de.setValue("Si");
  17260.                     }
  17261.                     else{
  17262.                         de.setValue("No");
  17263.                     }
  17264.                     e.add(de);
  17265.                    
  17266.                    
  17267.                     this.addInUsoButtonVisualizzazioneClassica(e, regola.getNome(), regola.getNome(), InUsoType.CANALE);

  17268.                     dati.add(e);
  17269.                 }
  17270.             }

  17271.             this.pd.setDati(dati);
  17272.             this.pd.setAddButton(true);
  17273.         } catch (Exception e) {
  17274.             this.logError("Exception: " + e.getMessage(), e);
  17275.             throw new DriverControlStationException(e);
  17276.         }
  17277.        
  17278.     }
  17279.     public List<DataElement> addCanaleToDati(TipoOperazione tipoOp, List<DataElement> dati, String idCanaleS,
  17280.             String nome, String descrizione) {
  17281.        
  17282.         DataElement dataElement = new DataElement();
  17283.         dataElement.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CANALE);
  17284.         dataElement.setType(DataElementType.TITLE);
  17285.         dati.add(dataElement);
  17286.        
  17287.         if(tipoOp.equals(TipoOperazione.CHANGE)) {
  17288.             // old id canale
  17289.             DataElement de = new DataElement();
  17290.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_ID_CANALE);
  17291.             de.setType(DataElementType.HIDDEN);
  17292.             de.setValue(idCanaleS);
  17293.             dati.add(de);
  17294.         }
  17295.        
  17296.         // nome
  17297.         DataElement de = new DataElement();
  17298.         de = new DataElement();
  17299.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NOME);
  17300.         de.setValue(nome);
  17301.         de.setType(DataElementType.TEXT_EDIT);
  17302.         de.setRequired(true);
  17303.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NOME);
  17304.         de.setSize(this.getSize());
  17305.         dati.add(de);
  17306.        
  17307.         // descrizione
  17308.         de = new DataElement();
  17309.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_DESCRIZIONE);
  17310.         de.setValue(descrizione);
  17311.         de.setType(DataElementType.TEXT_AREA);
  17312.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_DESCRIZIONE);
  17313.         de.setSize(this.getSize());
  17314.         dati.add(de);
  17315.        
  17316.         return dati;
  17317.     }
  17318.    
  17319.     public boolean canaleCheckData(TipoOperazione tipoOp, String oldNome) throws Exception {
  17320.         try{
  17321.             String canaliNome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NOME);
  17322.             String canaliDescrizione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_DESCRIZIONE);
  17323.            
  17324.             if(canaleDatiCheckData(canaliNome, canaliDescrizione) == false) {
  17325.                 return false;
  17326.             }
  17327.            
  17328.             boolean existsCanale = this.confCore.existsCanale(canaliNome);
  17329.            
  17330.             if(tipoOp.equals(TipoOperazione.ADD)) {
  17331.                 if(existsCanale) { // nome gia' occupato
  17332.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_CANALE_GIA_PRESENTE);
  17333.                     return false;
  17334.                 }
  17335.             } else {
  17336.                 // se ho cambiato il nome ed e' gia' scelto allora devo segnalare l'errore.
  17337.                 if(!oldNome.equals(canaliNome) && existsCanale) {
  17338.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_CANALE_NUOVO_NOME_GIA_PRESENTE);
  17339.                     return false;
  17340.                 }
  17341.             }
  17342.            
  17343.             return true;
  17344.         } catch (Exception e) {
  17345.             this.logError("Exception: " + e.getMessage(), e);
  17346.             throw new DriverControlStationException(e);
  17347.         }
  17348.     }
  17349.     public void prepareCanaleNodoConfigurazioneList(ConsoleSearch ricerca, List<CanaleConfigurazioneNodo> lista) throws Exception {
  17350.         try {
  17351.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_CANALI_NODI);

  17352.             int idLista = Liste.CONFIGURAZIONE_CANALI_NODI;
  17353.             int limit = ricerca.getPageSize(idLista);
  17354.             int offset = ricerca.getIndexIniziale(idLista);
  17355.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  17356.             this.pd.setIndex(offset);
  17357.             this.pd.setPageSize(limit);
  17358.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  17359.            
  17360.             // setto la barra del titolo
  17361.             List<Parameter> lstParam = new ArrayList<>();

  17362.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  17363.            
  17364.            
  17365.             this.pd.setSearchLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME);
  17366.             if(search.equals("")){
  17367.                 this.pd.setSearchDescription("");
  17368.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CANALI_NODI, null));
  17369.             }else{
  17370.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CANALI_NODI, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CANALI_NODI_LIST));
  17371.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  17372.             }

  17373.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  17374.              
  17375.             // controllo eventuali risultati ricerca
  17376.             if (!search.equals("")) {
  17377.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME, search);
  17378.             }

  17379.             // setto le label delle colonne
  17380.             List<String> lstLabels = new ArrayList<>();
  17381.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME);
  17382.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_DESCRIZIONE);
  17383.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_CANALI);
  17384.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  17385.             // preparo i dati  
  17386.             List<List<DataElement>> dati = new ArrayList<>();

  17387.             if (lista != null) {
  17388.                 Iterator<CanaleConfigurazioneNodo> it = lista.iterator();
  17389.                 while (it.hasNext()) {
  17390.                     CanaleConfigurazioneNodo regola = it.next();

  17391.                     List<DataElement> e = new ArrayList<>();
  17392.                     Parameter pIdCanaleNodo = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NODI_ID_NODO, regola.getId() + "");
  17393.                    
  17394.                     // Nome
  17395.                     DataElement de = new DataElement();
  17396.                     de.setIdToRemove(regola.getId() + "");
  17397.                     de.setValue(regola.getNome());
  17398.                     de.setToolTip(regola.getNome());
  17399.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CANALI_NODI_CHANGE, pIdCanaleNodo);
  17400.                     e.add(de);
  17401.                    
  17402.                     // descrizione
  17403.                     de = new DataElement();
  17404.                     if(regola.getDescrizione() != null && regola.getDescrizione().length() > 100) {
  17405.                         de.setValue(regola.getDescrizione().substring(0, 97)+"...");
  17406.                         de.setToolTip(regola.getDescrizione());
  17407.                     } else {
  17408.                         de.setValue(regola.getDescrizione());
  17409.                     }
  17410.                    
  17411.                     e.add(de);
  17412.                    
  17413.                     // Canali
  17414.                     de = new DataElement();
  17415.                     List<String> canaleList = regola.getCanaleList();
  17416.                     if(canaleList == null)
  17417.                         canaleList = new ArrayList<>();
  17418.                    
  17419.                     String labelTooltip = StringUtils.join(canaleList.toArray(new String[canaleList.size()]), ", ");
  17420.                    
  17421.                     if(labelTooltip.length() > 100) {
  17422.                         de.setValue(labelTooltip.substring(0, 97)+"...");
  17423.                         de.setToolTip(labelTooltip);
  17424.                     } else {
  17425.                         de.setValue(labelTooltip);
  17426.                     }
  17427.                     e.add(de);

  17428.                     dati.add(e);
  17429.                 }
  17430.             }

  17431.             this.pd.setDati(dati);
  17432.             this.pd.setAddButton(true);
  17433.         } catch (Exception e) {
  17434.             this.logError("Exception: " + e.getMessage(), e);
  17435.             throw new DriverControlStationException(e);
  17436.         }
  17437.        
  17438.     }
  17439.     public List<DataElement> addCanaleNodoToDati(TipoOperazione tipoOp, List<DataElement> dati, String idNodoS, String oldNome,
  17440.             String nome, String descrizione, String[] canali, List<CanaleConfigurazione> canaleList,
  17441.             boolean selectListNode, List<String> aliasesNodi) {
  17442.        
  17443.         DataElement dataElement = new DataElement();
  17444.         dataElement.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CANALI_NODO);
  17445.         dataElement.setType(DataElementType.TITLE);
  17446.         dati.add(dataElement);
  17447.                    
  17448.         if(tipoOp.equals(TipoOperazione.CHANGE)) {
  17449.             // old id canale
  17450.             DataElement de = new DataElement();
  17451.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NODI_ID_NODO);
  17452.             de.setType(DataElementType.HIDDEN);
  17453.             de.setValue(idNodoS);
  17454.             dati.add(de);
  17455.            
  17456.             if(selectListNode && aliasesNodi.contains(oldNome) && aliasesNodi.size()>1 && !oldNome.equals(nome)) {
  17457.                 de = new DataElement();
  17458.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NODI_OLD_NOME);
  17459.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_OLD_NOME);
  17460.                 de.setType(DataElementType.TEXT);
  17461.                 de.setValue(oldNome);
  17462.                 dati.add(de);
  17463.             }
  17464.         }
  17465.        
  17466.         // nome
  17467.         if(selectListNode) {
  17468.             DataElement de = new DataElement();
  17469.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME);
  17470.             de.setValues(aliasesNodi);
  17471.             de.setLabels(aliasesNodi);
  17472.             de.setSelected(nome);
  17473.             de.setRequired(true);
  17474.             de.setType(DataElementType.SELECT);
  17475.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME);
  17476.             if(tipoOp.equals(TipoOperazione.CHANGE)) {
  17477.                 de.setPostBack(true);
  17478.             }
  17479.             dati.add(de);
  17480.         }
  17481.         else {
  17482.             DataElement de = new DataElement();
  17483.             de = new DataElement();
  17484.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME);
  17485.             de.setValue(nome);
  17486.             de.setType(DataElementType.TEXT_EDIT);
  17487.             de.setRequired(true);
  17488.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME);
  17489.             de.setSize(this.getSize());
  17490.             dati.add(de);
  17491.         }
  17492.        
  17493.         // descrizione
  17494.         DataElement de = new DataElement();
  17495.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_DESCRIZIONE);
  17496.         de.setValue(descrizione);
  17497.         de.setType(DataElementType.TEXT_AREA);
  17498.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NODI_DESCRIZIONE);
  17499.         de.setSize(this.getSize());
  17500.         dati.add(de);
  17501.        
  17502.         // canali
  17503.         de = new DataElement();
  17504.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_CANALI);
  17505.         List<String> canaliListValues = canaleList.stream().map(CanaleConfigurazione::getNome).collect(Collectors.toList());
  17506.         de.setValues(canaliListValues);
  17507.         de.setLabels(canaliListValues);
  17508.         de.setSelezionati(canali);
  17509.         de.setRequired(true);
  17510.         de.setType(DataElementType.MULTI_SELECT);
  17511.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NODI_CANALI);
  17512.         de.setRows(10);
  17513.         dati.add(de);
  17514.        
  17515.         return dati;
  17516.     }
  17517.     public boolean canaleNodoCheckData(TipoOperazione tipoOp, String oldNome) throws Exception {
  17518.         try{
  17519.             String canaliNome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME);
  17520.             String canaliDescrizione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NODI_DESCRIZIONE);
  17521.             String [] canali = this.getParameterValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CANALI_NODI_CANALI);
  17522.            
  17523.             // nome obbligatorio
  17524.             if(StringUtils.isEmpty(canaliNome)){
  17525.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  17526.                         ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME));
  17527.                 return false;
  17528.             }
  17529.            
  17530.             if(this.checkSpazi(canaliNome, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME)==false) {
  17531.                 return false;
  17532.             }
  17533.            
  17534.             if(this.checkLength255(canaliNome, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_NOME)==false) {
  17535.                 return false;
  17536.             }
  17537.                        
  17538.             if(this.checkLength255(canaliDescrizione, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_DESCRIZIONE)==false) {
  17539.                 return false;
  17540.             }
  17541.            
  17542.             if(canali == null || canali.length == 0) {
  17543.                 this.pd.setMessage(MessageFormat.format(ConfigurazioneCostanti.MESSAGGIO_CANALE_NODO_CAMPO_CANALE_OBBLIGATORIO,
  17544.                         ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_NODI_CANALI));
  17545.                 return false;
  17546.             }
  17547.            
  17548.             boolean existsCanale = this.confCore.existsCanaleNodo(canaliNome);
  17549.            
  17550.             if(tipoOp.equals(TipoOperazione.ADD)) {
  17551.                 if(existsCanale) { // nome gia' occupato
  17552.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_CANALE_NODO_GIA_PRESENTE);
  17553.                     return false;
  17554.                 }
  17555.             } else {
  17556.                 // se ho cambiato il nome ed e' gia' scelto allora devo segnalare l'errore.
  17557.                 if(!oldNome.equals(canaliNome) && existsCanale) {
  17558.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_CANALE_NODO_NUOVO_NOME_GIA_PRESENTE);
  17559.                     return false;
  17560.                 }
  17561.             }
  17562.            
  17563.             return true;
  17564.         } catch (Exception e) {
  17565.             this.logError("Exception: " + e.getMessage(), e);
  17566.             throw new DriverControlStationException(e);
  17567.         }
  17568.     }

  17569.     // Prepara la lista dei plugin configurati
  17570.     public void preparePluginsArchiviList(ISearch ricerca, List<RegistroPlugin> lista) throws Exception {
  17571.         try {
  17572.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI);

  17573.             int idLista = Liste.CONFIGURAZIONE_PLUGINS_ARCHIVI;
  17574.             int limit = ricerca.getPageSize(idLista);
  17575.             int offset = ricerca.getIndexIniziale(idLista);
  17576.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  17577.             this.pd.setIndex(offset);
  17578.             this.pd.setPageSize(limit);
  17579.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  17580.            
  17581.             // setto la barra del titolo
  17582.             List<Parameter> lstParam = new ArrayList<>();

  17583.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  17584.            
  17585.            
  17586.             this.pd.setSearchLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME);
  17587.             if(search.equals("")){
  17588.                 this.pd.setSearchDescription("");
  17589.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PLUGINS_REGISTRO_ARCHIVI, null));
  17590.             }else{
  17591.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PLUGINS_REGISTRO_ARCHIVI, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_LIST));
  17592.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  17593.             }

  17594.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  17595.            
  17596.             // controllo eventuali risultati ricerca
  17597.             if (!search.equals("")) {
  17598.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME, search);
  17599.             }

  17600.             // setto le label delle colonne
  17601.             List<String> lstLabels = new ArrayList<>();
  17602.             if(lista != null && lista.size() > 1)
  17603.                 lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_POSIZIONE);
  17604.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_STATO);
  17605.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME);
  17606.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_ULTIMO_AGGIORNAMENTO);
  17607.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_APPLICABILITA);
  17608.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  17609.             // preparo i dati
  17610.             List<List<DataElement>> dati = new ArrayList<>();

  17611.             if (lista != null) {
  17612.                 Iterator<RegistroPlugin> it = lista.iterator();
  17613.                 int numeroElementi = lista.size();
  17614.                 int i = 0;
  17615.                 while (it.hasNext()) {
  17616.                     RegistroPlugin registro = it.next();

  17617.                     List<DataElement> e = new ArrayList<>();
  17618. //                  Parameter pIdRegola = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_ID_ARCHIVIO, regola.getId() + "");
  17619.                     Parameter pNomeRegola = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME, registro.getNome() + "");
  17620.                     Parameter pOldNomePlugin = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_OLD_NOME, registro.getNome() + "");
  17621.                    
  17622.                     // Posizione
  17623.                     if(lista.size() > 1) {
  17624.                         DataElement de = new DataElement();
  17625.                         de.setWidthPx(48);
  17626.                         de.setType(DataElementType.IMAGE);
  17627.                         DataElementImage imageUp = new DataElementImage();
  17628.                         Parameter pDirezioneSu = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_POSIZIONE,
  17629.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SU);
  17630.                         Parameter pDirezioneGiu = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_POSIZIONE,
  17631.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_GIU);
  17632.                                
  17633.                         if(i > 0) {
  17634.                             imageUp.setImage(CostantiControlStation.ICONA_FRECCIA_SU);
  17635.                             imageUp.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_SU);
  17636.                             imageUp.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_LIST, pNomeRegola, pDirezioneSu);
  17637.                         }
  17638.                         else {
  17639.                             imageUp.setImage(CostantiControlStation.ICONA_PLACEHOLDER);
  17640.                         }
  17641.                         de.addImage(imageUp);
  17642.                        
  17643.                         if(i < numeroElementi -1) {
  17644.                             DataElementImage imageDown = new DataElementImage();
  17645.                             imageDown.setImage(CostantiControlStation.ICONA_FRECCIA_GIU);
  17646.                             imageDown.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_GIU);
  17647.                             imageDown.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_LIST, pNomeRegola, pDirezioneGiu);
  17648.                             de.addImage(imageDown);
  17649.                         }
  17650.                         de.setValue(registro.getPosizione()+"");
  17651.                         e.add(de);
  17652.                     }
  17653.                    
  17654.                     // Stato
  17655.                     DataElement de = new DataElement();
  17656.                     de.setWidthPx(10);
  17657.                     de.setType(DataElementType.CHECKBOX);
  17658.                     if(registro.getStato()==null // backward compatibility
  17659.                             ||
  17660.                             StatoFunzionalita.ABILITATO.equals(registro.getStato())){
  17661.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  17662.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  17663.                         de.setSelected(CheckboxStatusType.CONFIG_ENABLE);
  17664.                     }
  17665.                     else{
  17666.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  17667.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  17668.                         de.setSelected(CheckboxStatusType.CONFIG_DISABLE);
  17669.                     }
  17670. //                  de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_CHANGE, pNomeRegola);
  17671.                     e.add(de);
  17672.                    
  17673.                    
  17674.                     // Nome
  17675.                     de = new DataElement();
  17676.                     de.setIdToRemove(registro.getNome());
  17677.                     de.setValue(registro.getNome());
  17678.                     de.setToolTip(registro.getNome());
  17679.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_CHANGE, pOldNomePlugin);
  17680.                     e.add(de);
  17681.                    
  17682.                     // ultimo aggiornamento
  17683.                     de = new DataElement();
  17684.                     Date dataUltimoAggiornamento = registro.getData();
  17685.                     String dataValue = "--";
  17686.                    
  17687.                     if(dataUltimoAggiornamento != null) {
  17688.                         dataValue = DateUtils.getSimpleDateFormat(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_FORMATO_DATA).format(dataUltimoAggiornamento);
  17689.                         de.setToolTip(dataValue);
  17690.                     }
  17691.                    
  17692.                     de.setValue(dataValue);
  17693.                     e.add(de);
  17694.                    
  17695.                     // applicabilita
  17696.                     de = new DataElement();
  17697.                     if(registro.getCompatibilitaList().size() > 0) {
  17698.                        
  17699.                         StringBuilder sb = new StringBuilder();
  17700.                         for (String appValue : registro.getCompatibilitaList()) {
  17701.                             TipoPlugin tipo = TipoPlugin.toEnumConstant(appValue, true);
  17702.                             String label = ConfigurazionePluginsTipoPluginUtils.tipoPluginToLabel(tipo);
  17703.                             if(sb.length()>0) {
  17704.                                 sb.append(", ");
  17705.                             }
  17706.                             sb.append(label);
  17707.                         }
  17708.                        
  17709.                         String compatibilita = sb.toString();
  17710.                    
  17711.                         if(compatibilita.length() > 100) {
  17712.                             de.setValue(compatibilita.substring(0, 97)+"...");
  17713.                             de.setToolTip(compatibilita);
  17714.                         } else {
  17715.                             de.setValue(compatibilita);
  17716.                         }
  17717.                     }else {
  17718.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_CLASSI_PLUGIN_QUALSIASI_IN_LIST);
  17719.                     }
  17720.                    
  17721.                     e.add(de);
  17722.                    
  17723.                     dati.add(e);
  17724.                     i++;
  17725.                 }
  17726.             }

  17727.             this.pd.setDati(dati);
  17728.             this.pd.setAddButton(true);
  17729.            
  17730.             // preparo bottoni
  17731.             if(lista!=null && lista.size()>0){
  17732.                 if (this.core.isShowPulsantiImportExport()) {

  17733.                     ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);
  17734.                     if(exporterUtils.existsAtLeastOneExportMode(org.openspcoop2.protocol.sdk.constants.ArchiveType.CONFIGURAZIONE_PLUGIN_ARCHVIO, this.request, this.session)){

  17735.                         List<AreaBottoni> bottoni = new ArrayList<>();

  17736.                         AreaBottoni ab = new AreaBottoni();
  17737.                         List<DataElement> otherbott = new ArrayList<>();
  17738.                         DataElement de = new DataElement();
  17739.                         de.setValue(ConfigurazioneCostanti.LABEL_PLUGIN_ARCHIVIO_ESPORTA_SELEZIONATI);
  17740.                         de.setOnClick(ConfigurazioneCostanti.LABEL_PLUGIN_ARCHIVIO_ESPORTA_SELEZIONATI_ONCLICK);
  17741.                         de.setDisabilitaAjaxStatus();
  17742.                         otherbott.add(de);
  17743.                         ab.setBottoni(otherbott);
  17744.                         bottoni.add(ab);

  17745.                         this.pd.setAreaBottoni(bottoni);

  17746.                     }

  17747.                 }
  17748.             }
  17749.            
  17750.         } catch (Exception e) {
  17751.             this.logError("Exception: " + e.getMessage(), e);
  17752.             throw new DriverControlStationException(e);
  17753.         }
  17754.     }

  17755.    
  17756.     public List<DataElement> addRegistroPluginToDati(TipoOperazione tipoOp, List<DataElement> dati, String oldNome, String idArchivioS,
  17757.             String nome, String descrizione, String stato, String sorgente, BinaryParameter jarArchivio,
  17758.             String dirArchivio, String urlArchivio, String classiPlugin, String[] tipoPlugin, int numeroArchivi) {
  17759.        
  17760.         DataElement dataElement = new DataElement();
  17761.         dataElement.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PLUGINS_ARCHIVIO);
  17762.         dataElement.setType(DataElementType.TITLE);
  17763.         dati.add(dataElement);
  17764.        
  17765.         DataElement de = new DataElement();
  17766.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME);
  17767.         de.setValue(nome);
  17768.         de.setType(DataElementType.TEXT_EDIT);
  17769.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME);
  17770.         de.setSize( getSize());
  17771.         de.setRequired(true);
  17772.         dati.add(de);
  17773.        
  17774.         if(tipoOp.equals(TipoOperazione.ADD)) {
  17775.            
  17776.         } else {
  17777.             de = new DataElement();
  17778.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_ID_ARCHIVIO);
  17779.             de.setValue(idArchivioS);
  17780.             de.setType(DataElementType.HIDDEN);
  17781.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_ID_ARCHIVIO);
  17782.             de.setSize( getSize());
  17783.             dati.add(de);
  17784.            
  17785.             de = new DataElement();
  17786.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME);
  17787.             de.setValue(oldNome);
  17788.             de.setType(DataElementType.HIDDEN);
  17789.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_OLD_NOME);
  17790.             de.setSize( getSize());
  17791.             dati.add(de);
  17792.         }
  17793.        
  17794.         // stato
  17795.         de = new DataElement();
  17796.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_STATO);
  17797.         String [] labelsStato = {StatoFunzionalita.ABILITATO.toString(), StatoFunzionalita.DISABILITATO.toString()};
  17798.         String [] valuesStato = {StatoFunzionalita.ABILITATO.toString(), StatoFunzionalita.DISABILITATO.toString()};
  17799.         de.setLabels(labelsStato);
  17800.         de.setValues(valuesStato);
  17801.         de.setType(DataElementType.SELECT);
  17802.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_STATO);
  17803.         de.setSelected(stato);
  17804.         dati.add(de);
  17805.        
  17806.         // descrizione
  17807.         de = new DataElement();
  17808.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DESCRIZIONE);
  17809.         de.setValue(descrizione);
  17810.         de.setType(DataElementType.TEXT_AREA);
  17811.         de.setRows(3);
  17812.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DESCRIZIONE);
  17813.         de.setSize(this.getSize());
  17814.         dati.add(de);
  17815.        
  17816.         if(tipoOp.equals(TipoOperazione.ADD)) {
  17817.             dati = addRegistroPluginJarToDati(TipoOperazione.ADD, dati, false, nome, sorgente, jarArchivio, dirArchivio, urlArchivio);
  17818.         } else {
  17819.             // link alla lista degli archivi
  17820.            
  17821.             de = new DataElement();
  17822.             de.setType(DataElementType.LINK);
  17823.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR_LIST ,
  17824.                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME, oldNome));
  17825.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  17826.             if (contaListe!=null && contaListe.booleanValue())
  17827.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO_ARCHIVI_ARCHIVI_JAR +" (" + numeroArchivi + ")");
  17828.             else
  17829.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO_ARCHIVI_ARCHIVI_JAR);
  17830.             dati.add(de);
  17831.            
  17832.         }
  17833.        
  17834.         // applicabilita
  17835.         dataElement = new DataElement();
  17836.         dataElement.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_APPLICABILITA);
  17837.         dataElement.setType(DataElementType.SUBTITLE);
  17838.         dati.add(dataElement);
  17839.        
  17840.         // classi plugin
  17841.         de = new DataElement();
  17842.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_CLASSI_PLUGIN);
  17843.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_CLASSI_PLUGIN);
  17844.         de.setType(DataElementType.SELECT);
  17845.         de.setLabels(ConfigurazioneCostanti.LABELS_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_CLASSI_PLUGIN);
  17846.         de.setValues(ConfigurazioneCostanti.VALUES_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_CLASSI_PLUGIN);
  17847.         de.setSelected(classiPlugin);
  17848.         de.setPostBack(true);
  17849.         dati.add(de);
  17850.        
  17851.         // tipo plugin
  17852.         if(classiPlugin.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_CLASSI_PLUGIN_SELEZIONATE)) {
  17853.             de = new DataElement();
  17854.             de.setLabel("");
  17855.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_TIPO_PLUGIN);
  17856.             de.setType(DataElementType.MULTI_SELECT);
  17857.             de.setLabels(ConfigurazionePluginsTipoPluginUtils.getLabelsTipoPlugin(this.confCore.isConfigurazioneAllarmiEnabled()));
  17858.             de.setValues(ConfigurazionePluginsTipoPluginUtils.getValuesTipoPlugin(this.confCore.isConfigurazioneAllarmiEnabled()));
  17859.             de.setSelezionati(tipoPlugin);
  17860.             dati.add(de);
  17861.         }
  17862.        
  17863.         return dati;
  17864.     }
  17865.    
  17866.     public List<DataElement> addRegistroPluginJarToDati(TipoOperazione tipoOp, List<DataElement> dati, boolean addTitle, String nomePlugin, String sorgente, BinaryParameter jarArchivio, String dirArchivio,
  17867.             String urlArchivio) {
  17868.         DataElement de;
  17869.        
  17870.         if(addTitle) {
  17871.             de = new DataElement();
  17872.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PLUGINS_ARCHIVIO);
  17873.             de.setType(DataElementType.TITLE);
  17874.             dati.add(de);
  17875.            
  17876.             de = new DataElement();
  17877.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME);
  17878.             de.setValue(nomePlugin);
  17879.             de.setType(DataElementType.HIDDEN);
  17880.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME);
  17881.             de.setSize( getSize());
  17882.             dati.add(de);
  17883.         }
  17884.        
  17885.         // sorgente
  17886.         de = new DataElement();
  17887.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_SORGENTE);
  17888.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_SORGENTE);
  17889.         de.setType(DataElementType.SELECT);
  17890.         de.setLabels(ConfigurazioneCostanti.LABELS_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_SORGENTE);
  17891.         de.setValues(ConfigurazioneCostanti.VALUES_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_SORGENTE);
  17892.         de.setSelected(sorgente);
  17893.         de.setPostBack(true);
  17894.         dati.add(de);
  17895.        
  17896.         if(sorgente.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_SORGENTE_JAR)) {
  17897.             // jar
  17898.             DataElement deJarArchivio = jarArchivio.getFileDataElement(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR_ARCHIVIO, "", getSize());
  17899.             deJarArchivio.setRequired(true);
  17900.             dati.add(deJarArchivio);
  17901.             dati.addAll(jarArchivio.getFileNameDataElement());
  17902.             dati.add(jarArchivio.getFileIdDataElement());
  17903.         } else if(sorgente.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_SORGENTE_DIR)) {
  17904.             // dir
  17905.             de = new DataElement();
  17906.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DIR_ARCHIVIO);
  17907.             de.setValue(dirArchivio);
  17908.             de.setType(DataElementType.TEXT_AREA);
  17909.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DIR_ARCHIVIO);
  17910.             de.setSize(this.getSize());
  17911.             de.setRequired(true);
  17912.             dati.add(de);
  17913.         } else {
  17914.             // url
  17915.             de = new DataElement();
  17916.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_URL_ARCHIVIO);
  17917.             de.setValue(urlArchivio);
  17918.             de.setType(DataElementType.TEXT_AREA);
  17919.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_URL_ARCHIVIO);
  17920.             de.setSize(this.getSize());
  17921.             de.setRequired(true);
  17922.             dati.add(de);
  17923.         }
  17924.        
  17925.         return dati;
  17926.     }
  17927.    
  17928.     public boolean registroPluginCheckData(TipoOperazione tipoOp, String oldNome, String idArchivioS,
  17929.             String nome, String descrizione, String stato, String sorgente, BinaryParameter jarArchivio,
  17930.             String dirArchivio, String urlArchivio, String classiPlugin, String[] tipoPlugin) throws Exception {
  17931.        
  17932.         try {
  17933.             if(nome==null || "".equals(nome)) {
  17934.                 this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME+"'");
  17935.                 return false;
  17936.             }
  17937.             if(nome.contains(" ")) {
  17938.                 this.pd.setMessage("No indicare spazi nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME+"'");
  17939.                 return false;
  17940.             }
  17941.             if(!this.checkLength255(nome, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME)) {
  17942.                 return false;
  17943.             }
  17944.            
  17945.             // Se tipoOp = add, controllo che l'archivio non sia gia' stato registrato
  17946.             boolean existsArchivio = this.confCore.existsRegistroPlugin(nome);
  17947.            
  17948.             if (tipoOp.equals(TipoOperazione.ADD)) {
  17949.                 if (existsArchivio) {
  17950.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_PLUGINS_ARCHIVIO_DUPLICATO);
  17951.                     return false;
  17952.                 }
  17953.             } else {
  17954.                 // controllo che le modifiche ai parametri non coincidano con altre regole gia' presenti
  17955. //              TrasformazioneRegola trasformazione = this.porteApplicativeCore.getTrasformazione(idPorta, azioniDBCheck, patternDBCheck, contentTypeDBCheck);
  17956.                 if(!nome.equals(oldNome) && existsArchivio) {
  17957.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_PLUGINS_ARCHIVIO_NUOVO_NOME_DUPLICATO);
  17958.                     return false;
  17959.                 }
  17960.             }
  17961.                
  17962.             if(!this.checkLength255(descrizione, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DESCRIZIONE)) {
  17963.                 return false;
  17964.             }
  17965.            
  17966.             boolean valArchivio = this.registroPluginArchivioCheckData(tipoOp, sorgente, nome, jarArchivio, dirArchivio, urlArchivio, false);
  17967.            
  17968.             if(!valArchivio)
  17969.                 return valArchivio;
  17970.            
  17971.             if(classiPlugin.equals(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_CLASSI_PLUGIN_SELEZIONATE)) {
  17972.                 // compatibilita'
  17973.                 if(tipoPlugin == null || tipoPlugin.length == 0){
  17974.                     this.pd.setMessage("Indicare almeno un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_CLASSI_PLUGIN+"'");
  17975.                     return false;
  17976.                 }
  17977.             }
  17978.            
  17979.             return true;
  17980.         } catch (Exception e) {
  17981.             this.logError("Exception: " + e.getMessage(), e);
  17982.             throw new DriverControlStationException(e);
  17983.         }
  17984.     }
  17985.    
  17986.     public boolean registroPluginArchivioCheckData(TipoOperazione tipoOp, String sorgente, String nomePlugin, BinaryParameter jarArchivio,
  17987.             String dirArchivio, String urlArchivio, boolean addJar) throws Exception {
  17988.        
  17989.         try {
  17990.             if (tipoOp.equals(TipoOperazione.ADD)) {
  17991.                 if(sorgente==null || "".equals(sorgente)) {
  17992.                     this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_SORGENTE+"'");
  17993.                     return false;
  17994.                 }
  17995.                
  17996.                 PluginSorgenteArchivio pluginSorgenteArchivio = DriverConfigurazioneDBLib.getEnumPluginSorgenteArchivio(sorgente);
  17997.                
  17998.                 if(pluginSorgenteArchivio == null) {
  17999.                     this.pd.setMessage("Il valore indicato nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_SORGENTE+"' non &egrave; valido.");
  18000.                     return false;
  18001.                 }
  18002.                
  18003.                 switch (pluginSorgenteArchivio) {
  18004.                 case JAR:
  18005.                     // jar
  18006.                     if(jarArchivio.getValue() == null || jarArchivio.getValue().length == 0){
  18007.                         this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR_ARCHIVIO+"'");
  18008.                         return false;
  18009.                     }
  18010.                    
  18011.                     String nomeFile = jarArchivio.getFilename();
  18012.                     if(addJar && this.confCore.existsRegistroPluginArchivio(nomePlugin, nomeFile)) {
  18013.                         this.pd.setMessage("Un '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR_ARCHIVIO+"' con lo stesso nome è già stato assegnato al plugin");
  18014.                         return false;
  18015.                     }
  18016.                     break;
  18017.                 case URL:
  18018.                     // url
  18019.                     if(urlArchivio==null || "".equals(urlArchivio)) {
  18020.                         this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_URL_ARCHIVIO+"'");
  18021.                         return false;
  18022.                     }
  18023.                     if(urlArchivio.contains(" ")) {
  18024.                         this.pd.setMessage("Non indicare spazi nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_URL_ARCHIVIO+"'");
  18025.                         return false;
  18026.                     }
  18027.                     if(!this.checkLength4000(urlArchivio, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_URL_ARCHIVIO)) {
  18028.                         return false;
  18029.                     }
  18030.                    
  18031.                     try {
  18032.                         new URL(urlArchivio);
  18033.                     }catch(Exception e) {
  18034.                         this.pd.setMessage("Il valore indicato nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_URL_ARCHIVIO+"' non rappresenta una URL valida.");
  18035.                         return false;
  18036.                     }
  18037.                    
  18038.                     if(addJar && this.confCore.existsRegistroPluginArchivio(nomePlugin, pluginSorgenteArchivio, urlArchivio)) {
  18039.                         this.pd.setMessage("Un '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR_ARCHIVIO+"', riferito con la stessa URL, è già stato assegnato al plugin");
  18040.                         return false;
  18041.                     }
  18042.                    
  18043.                     break;
  18044.                 case DIR:
  18045.                     // dir
  18046.                     if(dirArchivio==null || "".equals(dirArchivio)) {
  18047.                         this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DIR_ARCHIVIO+"'");
  18048.                         return false;
  18049.                     }
  18050.                     if(dirArchivio.contains(" ")) {
  18051.                         this.pd.setMessage("Non indicare spazi nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DIR_ARCHIVIO+"'");
  18052.                         return false;
  18053.                     }
  18054.                     if(!this.checkLength4000(dirArchivio, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DIR_ARCHIVIO)) {
  18055.                         return false;
  18056.                     }
  18057.                     try {
  18058.                         Paths.get(dirArchivio);
  18059.                     } catch (InvalidPathException ex) {
  18060.                         this.pd.setMessage("Il valore indicato nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DIR_ARCHIVIO+"' non rappresenta un path valido.");
  18061.                         return false;
  18062.                     } catch (NullPointerException ex) {
  18063.                         this.pd.setMessage("Il valore indicato nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DIR_ARCHIVIO+"' non rappresenta un path valido.");
  18064.                         return false;
  18065.                     }
  18066.                    
  18067.                     if(addJar && this.confCore.existsRegistroPluginArchivio(nomePlugin, pluginSorgenteArchivio, dirArchivio)) {
  18068.                         this.pd.setMessage("Un repository di '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR_ARCHIVI+"', riferito con la directory indicata, è già stato assegnato al plugin");
  18069.                         return false;
  18070.                     }
  18071.                    
  18072.                     break;
  18073.                 }
  18074.             }
  18075.            
  18076.             return true;
  18077.         } catch (Exception e) {
  18078.             this.logError("Exception: " + e.getMessage(), e);
  18079.             throw new DriverControlStationException(e);
  18080.         }
  18081.     }

  18082.     // Prepara la lista degli archivi di un plugin
  18083.     public void preparePluginsArchiviJarList(String nome, ISearch ricerca, List<RegistroPluginArchivio> lista) throws Exception {
  18084.         try {
  18085.            
  18086.             Parameter pNomeRegistro = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME, nome);
  18087.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR, pNomeRegistro);

  18088.             int idLista = Liste.CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR;
  18089.             int limit = ricerca.getPageSize(idLista);
  18090.             int offset = ricerca.getIndexIniziale(idLista);
  18091.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);
  18092.            
  18093.             Map<String, String> campiHidden = new HashMap<>();
  18094.             campiHidden.put(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_NOME, nome);
  18095.             this.pd.setHidden(campiHidden);

  18096.             this.pd.setIndex(offset);
  18097.             this.pd.setPageSize(limit);
  18098.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  18099.            
  18100.             // setto la barra del titolo
  18101.             List<Parameter> lstParam = new ArrayList<>();

  18102.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  18103.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PLUGINS_REGISTRO_ARCHIVI, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_LIST));
  18104.             lstParam.add(new Parameter(nome, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_CHANGE,
  18105.                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_OLD_NOME, nome)));
  18106.            
  18107.             this.pd.setSearchLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR_NOME);
  18108.             String labelJarDi = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO_ARCHIVI_ARCHIVI_JAR;
  18109.             if(search.equals("")){
  18110.                 this.pd.setSearchDescription("");
  18111.                 lstParam.add(new Parameter(labelJarDi, null));
  18112.             }else{
  18113.                 lstParam.add(new Parameter(labelJarDi, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR_LIST, pNomeRegistro));
  18114.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  18115.             }

  18116.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  18117.            
  18118.             // controllo eventuali risultati ricerca
  18119.             if (!search.equals("")) {
  18120.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR_NOME, search);
  18121.             }

  18122.             // setto le label delle colonne
  18123.             List<String> lstLabels = new ArrayList<>();
  18124.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DATA_REGISTRAZIONE);
  18125.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_TIPO_SORGENTE);
  18126.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_SORGENTE);
  18127.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_ARCHIVIO);
  18128.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  18129.             // preparo i dati
  18130.             List<List<DataElement>> dati = new ArrayList<>();

  18131.             boolean visualizzaElimina = false;
  18132.             if (lista != null) {
  18133.                 Iterator<RegistroPluginArchivio> it = lista.iterator();
  18134.                 visualizzaElimina = lista.size() > 1;
  18135.                 while (it.hasNext()) {
  18136.                     RegistroPluginArchivio registro = it.next();
  18137.                     PluginSorgenteArchivio sorgente = registro.getSorgente();
  18138.                    
  18139.                     List<DataElement> e = new ArrayList<>();
  18140.                    
  18141.                     // Data Inserimento (definisce IdToRemove)
  18142.                     DataElement de = new DataElement();
  18143.                     de.setIdToRemove(registro.getNome());
  18144.                     Date dataInserimento = registro.getData();
  18145.                     String dataValue = "--";
  18146.                     if(dataInserimento != null) {
  18147.                         dataValue = DateUtils.getSimpleDateFormat(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_FORMATO_DATA).format(dataInserimento);
  18148.                         de.setToolTip(dataValue);
  18149.                     }
  18150.                     de.setValue(dataValue);
  18151.                     e.add(de);
  18152.                    
  18153.                     // Tipo Sorgente
  18154.                     de = new DataElement();
  18155.                     switch (sorgente) {
  18156.                     case DIR:
  18157.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DIR_ARCHIVIO);
  18158.                         break;
  18159.                     case JAR:
  18160.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_JAR_ARCHIVIO);
  18161.                         break;
  18162.                     case URL:
  18163.                         de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_URL_ARCHIVIO);
  18164.                         break;
  18165.                     }
  18166.                     e.add(de);
  18167.                    
  18168.                     // Sorgente
  18169.                     de = new DataElement();
  18170.                     switch (sorgente) {
  18171.                     case DIR:
  18172.                         de.setValue(registro.getDir());
  18173.                         break;
  18174.                     case JAR:
  18175.                         de.setValue(registro.getNome());
  18176.                         break;
  18177.                     case URL:
  18178.                         de.setValue(registro.getUrl());
  18179.                         break;
  18180.                     }
  18181.                     e.add(de);
  18182.                    
  18183.                     // Archivio
  18184.                     de = new DataElement();
  18185.                     switch (sorgente) {
  18186.                     case DIR:
  18187.                         de.setValue("-");
  18188.                         break;
  18189.                     case JAR:
  18190.                         de.setValue(AccordiServizioParteComuneCostanti.LABEL_DOWNLOAD.toLowerCase());
  18191.                         de.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT,
  18192.                                 new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO,  ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ARCHIVIO_JAR),
  18193.                                 new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ARCHIVIO_JAR),
  18194.                                 new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_JAR_NOME_PLUGIN, registro.getNomePlugin()),
  18195.                                 new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_JAR_NOME_ARCHVIO, registro.getNome()));
  18196.                         de.setDisabilitaAjaxStatus();
  18197.                         break;
  18198.                     case URL:
  18199.                         de.setValue("-");
  18200.                         break;
  18201.                     }
  18202.                     e.add(de);
  18203.                    
  18204.                     dati.add(e);
  18205.                 }
  18206.             }

  18207.             this.pd.setDati(dati);
  18208.             this.pd.setAddButton(true);
  18209.             this.pd.setRemoveButton(visualizzaElimina);
  18210.             this.pd.setSelect(visualizzaElimina);
  18211.         } catch (Exception e) {
  18212.             this.logError("Exception: " + e.getMessage(), e);
  18213.             throw new DriverControlStationException(e);
  18214.         }
  18215.     }
  18216.    
  18217.     // Prepara la lista delle classi di plugin configurate
  18218.     public void preparePluginsClassiList(ISearch ricerca, List<Plugin> lista) throws Exception {
  18219.         try {
  18220.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_PLUGINS_CLASSI);

  18221.             int idLista = Liste.CONFIGURAZIONE_PLUGINS_CLASSI;
  18222.             int limit = ricerca.getPageSize(idLista);
  18223.             int offset = ricerca.getIndexIniziale(idLista);
  18224.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  18225.             this.pd.setIndex(offset);
  18226.             this.pd.setPageSize(limit);
  18227.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  18228.            
  18229.             String filterTipo = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_TIPO_PLUGIN_CLASSI);
  18230.             this.addFilterTipoPlugin(filterTipo, true);

  18231.             // filtro dinamico in base al tipo plugin
  18232.             if(!filterTipo.equals("")) {
  18233.                 ConfigurazionePluginsTipoPluginUtils.addFiltriSpecificiTipoPlugin(this.pd, this.log, ricerca, idLista, filterTipo, this.getSize(),
  18234.                         this.confCore.isIntegrationManagerEnabled());
  18235.             }
  18236.            
  18237.             // setto la barra del titolo
  18238.             List<Parameter> lstParam = new ArrayList<>();

  18239.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  18240.            
  18241.            
  18242.             this.pd.setSearchLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_LABEL);
  18243.             if(search.equals("")){
  18244.                 this.pd.setSearchDescription("");
  18245.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO_CLASSI, null));
  18246.             }else{
  18247.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRO_CLASSI, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_CLASSI_LIST));
  18248.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  18249.             }

  18250.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  18251.            
  18252.             // controllo eventuali risultati ricerca
  18253.             if (!search.equals("")) {
  18254.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_LABEL, search);
  18255.             }

  18256.             // setto le label delle colonne
  18257.             List<String> lstLabels = new ArrayList<>();
  18258.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_STATO);
  18259.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO_PLUGIN);
  18260.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO);
  18261.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_LABEL);
  18262.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_APPLICABILITA);
  18263.             lstLabels.add(CostantiControlStation.LABEL_IN_USO_COLONNA_HEADER); // inuso
  18264.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  18265.             // preparo i dati
  18266.             List<List<DataElement>> dati = new ArrayList<>();

  18267.             if (lista != null) {
  18268.                 Iterator<Plugin> it = lista.iterator();
  18269.                 while (it.hasNext()) {
  18270.                     Plugin registro = it.next();
  18271.                    
  18272.                     List<DataElement> e = new ArrayList<>();
  18273.                     Parameter pIdRegistro = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_ID_PLUGIN, registro.getId() + "");
  18274.                    
  18275.                     // Stato
  18276.                     DataElement de = new DataElement();
  18277.                     de.setWidthPx(10);
  18278.                     de.setType(DataElementType.CHECKBOX);
  18279.                     if(registro.getStato()){
  18280.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  18281.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  18282.                         de.setSelected(CheckboxStatusType.CONFIG_ENABLE);
  18283.                     }
  18284.                     else{
  18285.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  18286.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  18287.                         de.setSelected(CheckboxStatusType.CONFIG_DISABLE);
  18288.                     }
  18289. //                      de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_ARCHIVI_CHANGE, pNomeRegola);
  18290.                     e.add(de);
  18291.                    
  18292.                    
  18293.                     // tipo plugin
  18294.                     de = new DataElement();
  18295.                     de.setIdToRemove(registro.getId() + "");
  18296.                     TipoPlugin tipoPlugin = TipoPlugin.toEnumConstant(registro.getTipoPlugin());
  18297.                     String tipoPluginLabel = ConfigurazionePluginsTipoPluginUtils.tipoPluginToLabel(tipoPlugin);
  18298.                     de.setValue(tipoPluginLabel);
  18299.                     if(registro.getDescrizione()!=null && !"".equals(registro.getDescrizione())) {
  18300.                         de.setToolTip(registro.getDescrizione());
  18301.                     }
  18302.                     else {
  18303.                         de.setToolTip(tipoPluginLabel);
  18304.                     }
  18305.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_PLUGINS_CLASSI_CHANGE, pIdRegistro);
  18306.                     e.add(de);
  18307.                    
  18308.                     // tipo
  18309.                     de = new DataElement();
  18310.                     de.setValue(registro.getTipo());
  18311.                     e.add(de);
  18312.                    
  18313.                     // label
  18314.                     de = new DataElement();
  18315.                     de.setValue(registro.getLabel());
  18316.                     e.add(de);
  18317.                    
  18318.                     // applicabilita
  18319.                     de = new DataElement();
  18320.                     String applicabilita = ConfigurazionePluginsTipoPluginUtils.getApplicabilitaClassePlugin(registro);
  18321.                     if(applicabilita != null) {
  18322.                         if(applicabilita.length() > 100) {
  18323.                             de.setValue(applicabilita.substring(0, 97)+"...");
  18324.                             de.setToolTip(applicabilita);
  18325.                         } else {
  18326.                             de.setValue(applicabilita);
  18327.                         }
  18328.                     }else {
  18329.                         de.setValue("-");
  18330.                     }
  18331.                     e.add(de);
  18332.                    
  18333.                     // InUso
  18334.                     this.addInUsoButtonVisualizzazioneClassica(e, tipoPluginLabel + " - " +registro.getLabel(), registro.getId() + "", InUsoType.PLUGIN_CLASSE);
  18335.                    
  18336.                     dati.add(e);
  18337.                 }
  18338.             }

  18339.             this.pd.setDati(dati);
  18340.             this.pd.setAddButton(true);
  18341.            
  18342.             // preparo bottoni
  18343.             if(lista!=null && lista.size()>0){
  18344.                 if (this.core.isShowPulsantiImportExport()) {

  18345.                     ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);
  18346.                     if(exporterUtils.existsAtLeastOneExportMode(org.openspcoop2.protocol.sdk.constants.ArchiveType.CONFIGURAZIONE_PLUGIN_CLASSE, this.request, this.session)){

  18347.                         List<AreaBottoni> bottoni = new ArrayList<>();

  18348.                         AreaBottoni ab = new AreaBottoni();
  18349.                         List<DataElement> otherbott = new ArrayList<>();
  18350.                         DataElement de = new DataElement();
  18351.                         de.setValue(ConfigurazioneCostanti.LABEL_PLUGIN_CLASSE_ESPORTA_SELEZIONATI);
  18352.                         de.setOnClick(ConfigurazioneCostanti.LABEL_PLUGIN_CLASSE_ESPORTA_SELEZIONATI_ONCLICK);
  18353.                         de.setDisabilitaAjaxStatus();
  18354.                         otherbott.add(de);
  18355.                         ab.setBottoni(otherbott);
  18356.                         bottoni.add(ab);

  18357.                         this.pd.setAreaBottoni(bottoni);

  18358.                     }

  18359.                 }
  18360.             }
  18361.            
  18362.         } catch (Exception e) {
  18363.             this.logError("Exception: " + e.getMessage(), e);
  18364.             throw new DriverControlStationException(e);
  18365.         }
  18366.     }
  18367.     public List<DataElement> addPluginClassiToDati(TipoOperazione tipoOp, List<DataElement> dati, String idPluginS,
  18368.             TipoPlugin tipoPlugin, String tipo, String label, String className, String stato, String descrizione, String ruolo,
  18369.             String shTipo, String mhTipo, String mhRuolo,
  18370.             String applicabilita) {
  18371.        
  18372.         DataElement dataElement = new DataElement();
  18373.         dataElement.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_PLUGINS_CLASSI_PLUGIN);
  18374.         dataElement.setType(DataElementType.TITLE);
  18375.         dati.add(dataElement);
  18376.        
  18377.         boolean visualizzaAllarmi = this.confCore.isVisualizzaConfigurazioneAllarmiEnabled();  // configurazione allarmi (solo se sono stati caricati dei plugin di tipo allarme) tramite la funzionalità 'Importa'
  18378.        
  18379.         // tipoPlugin
  18380.         DataElement de = new DataElement();
  18381.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO_PLUGIN);
  18382.         List<String> labels = new ArrayList<>();
  18383.         if(tipoOp.equals(TipoOperazione.ADD)) {
  18384.             labels.add(CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_LABEL_UNDEFINED);
  18385.         }
  18386.         labels.addAll(ConfigurazionePluginsTipoPluginUtils.getLabelsTipoPlugin(visualizzaAllarmi));
  18387.         List<String> values = new ArrayList<>();
  18388.         if(tipoOp.equals(TipoOperazione.ADD)) {
  18389.             values.add(CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_VALORE_UNDEFINED);
  18390.         }
  18391.         values.addAll(ConfigurazionePluginsTipoPluginUtils.getValuesTipoPlugin(visualizzaAllarmi));
  18392.         de.setLabels(labels);
  18393.         de.setValues(values);
  18394.         de.setType(DataElementType.SELECT);
  18395.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO_PLUGIN);
  18396.         if(tipoPlugin!=null) {
  18397.             de.setSelected(tipoPlugin.toString());
  18398.         }
  18399.         if(tipoOp.equals(TipoOperazione.ADD)) {
  18400.             de.setRequired(true);
  18401.         }
  18402.         de.setPostBack(true);
  18403.         dati.add(de);
  18404.        
  18405.         if(tipoOp.equals(TipoOperazione.ADD)) {
  18406.            
  18407.         } else {
  18408.             de = new DataElement();
  18409.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_ID_PLUGIN);
  18410.             de.setValue(idPluginS);
  18411.             de.setType(DataElementType.HIDDEN);
  18412.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_ID_PLUGIN);
  18413.             de.setSize(getSize());
  18414.             dati.add(de);
  18415.         }
  18416.        
  18417.         // sezione dinamica
  18418.         if(tipoPlugin!=null) {
  18419.             dati = ConfigurazionePluginsTipoPluginUtils.getSezioneDinamicaClassePlugin(dati, tipoPlugin, ruolo, shTipo, mhTipo, mhRuolo, applicabilita,
  18420.                     this.confCore.isIntegrationManagerEnabled());
  18421.         }
  18422.        
  18423.         // tipo
  18424.         de = new DataElement();
  18425.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO);
  18426.         de.setValue(tipo);
  18427.         de.setType(DataElementType.TEXT_EDIT);
  18428.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO);
  18429.         de.setSize(this.getSize());
  18430.         de.setRequired(true);
  18431.         dati.add(de);
  18432.        
  18433.         // class name
  18434.         de = new DataElement();
  18435.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_CLASS_NAME);
  18436.         de.setValue(className);
  18437.         de.setType(DataElementType.TEXT_AREA);
  18438.         de.setRows(2);
  18439.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_CLASS_NAME);
  18440.         de.setSize(this.getSize());
  18441.         de.setRequired(true);
  18442.         if(tipoPlugin!=null) {
  18443.             ConfigurazionePluginsTipoPluginUtils.addInfoClassePlugin(de, tipoPlugin, ruolo, shTipo, mhTipo, mhRuolo,
  18444.                     this.confCore.isIntegrationManagerEnabled());
  18445.         }
  18446.         dati.add(de);
  18447.        
  18448.         // label
  18449.         de = new DataElement();
  18450.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_LABEL);
  18451.         de.setValue(label);
  18452.         de.setType(DataElementType.TEXT_EDIT);
  18453.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_LABEL);
  18454.         de.setSize(this.getSize());
  18455.         de.setRequired(true);
  18456.         dati.add(de);
  18457.        
  18458.         // stato
  18459.         de = new DataElement();
  18460.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_STATO);
  18461.         String [] labelsStato = {StatoFunzionalita.ABILITATO.toString(), StatoFunzionalita.DISABILITATO.toString()};
  18462.         String [] valuesStato = {StatoFunzionalita.ABILITATO.toString(), StatoFunzionalita.DISABILITATO.toString()};
  18463.         de.setLabels(labelsStato);
  18464.         de.setValues(valuesStato);
  18465.         de.setType(DataElementType.SELECT);
  18466.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_STATO);
  18467.         de.setSelected(stato);
  18468.         dati.add(de);
  18469.        
  18470.         // descrizione
  18471.         de = new DataElement();
  18472.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_DESCRIZIONE);
  18473.         de.setValue(descrizione);
  18474.         de.setType(DataElementType.TEXT_AREA);
  18475.         de.setRows(3);
  18476.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_DESCRIZIONE);
  18477.         de.setSize(this.getSize());
  18478.         dati.add(de);
  18479.        
  18480.         return dati;
  18481.     }
  18482.    
  18483.     public boolean pluginClassiCheckData(TipoOperazione tipoOp, Plugin oldPlugin, String idPluginS, TipoPlugin tipoPlugin, String tipo,
  18484.             String label, String className, String stato, String descrizione, String ruolo, String shTipo, String mhTipo, String mhRuolo, String applicabilita) throws Exception {
  18485.        
  18486.         try {
  18487.            
  18488.             // tipo plugin
  18489.             if(tipoPlugin==null) {
  18490.                 this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO_PLUGIN+"'");
  18491.                 return false;
  18492.             }
  18493.            
  18494.             // sezione dinamica
  18495.            
  18496.            
  18497.             // tipo
  18498.             if(tipo==null || "".equals(tipo)) {
  18499.                 this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO+"'");
  18500.                 return false;
  18501.             }
  18502.             if(tipo.contains(" ")) {
  18503.                 this.pd.setMessage("Non indicare spazi nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO+"'");
  18504.                 return false;
  18505.             }
  18506.             if(!this.checkSimpleName(tipo, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO)) {
  18507.                 return false;
  18508.             }
  18509.             if(TipoPlugin.AUTENTICAZIONE.equals(tipoPlugin)){
  18510.                 int lenghtMax = 20 - (TipoCredenzialeMittente.TRASPORTO.getRawValue()+"_").length();
  18511.                 if(!this.checkLength(tipo, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO, 1, lenghtMax)) { // finisce poi nei log delle transazioni
  18512.                     return false;
  18513.                 }
  18514.             }
  18515.             else if(!this.checkLength255(tipo, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO)) {
  18516.                 return false;
  18517.             }
  18518.        
  18519.             // label
  18520.             if(label==null || "".equals(label)) {
  18521.                 this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_LABEL+"'");
  18522.                 return false;
  18523.             }
  18524.            
  18525.             if(!this.checkLength255(label, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_LABEL)) {
  18526.                 return false;
  18527.             }
  18528.            
  18529.             // classname
  18530.             if(className==null || "".equals(className)) {
  18531.                 this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_CLASS_NAME+"'");
  18532.                 return false;
  18533.             }
  18534.             if(className.contains(" ")) {
  18535.                 this.pd.setMessage("Non indicare spazi nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_CLASS_NAME+"'");
  18536.                 return false;
  18537.             }
  18538.             if(!this.checkLength255(className, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_CLASS_NAME)) {
  18539.                 return false;
  18540.             }
  18541.            
  18542.             if(!this.checkLength255(descrizione, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DESCRIZIONE)) {
  18543.                 return false;
  18544.             }
  18545.            
  18546.            
  18547.             // Non posso modificare, negli elementi riferiti, un plugin in uso
  18548.             if (tipoOp.equals(TipoOperazione.CHANGE)) {
  18549.                
  18550.                 TipoPlugin oldTipoPlugin = TipoPlugin.toEnumConstant(oldPlugin.getTipoPlugin());
  18551.                 boolean oldStatoEnabled = ServletUtils.isCheckBoxEnabled(stato);
  18552.                 boolean modificatiElementiRiferiti = (!tipoPlugin.equals(oldTipoPlugin)) || (!tipo.equals(oldPlugin.getTipo())) || (oldStatoEnabled != oldPlugin.getStato());
  18553.                
  18554.                 if(modificatiElementiRiferiti) {
  18555.                    
  18556.                     HashMap<ErrorsHandlerCostant, List<String>> whereIsInUso = new HashMap<ErrorsHandlerCostant, List<String>>();
  18557.                     boolean normalizeObjectIds = !this.isModalitaCompleta();
  18558.                     boolean pluginInUso = this.confCore.isPluginInUso(oldPlugin.getClassName(),
  18559.                             oldPlugin.getLabel(), oldPlugin.getTipoPlugin(), oldPlugin.getTipo(),whereIsInUso,normalizeObjectIds);
  18560.                    
  18561.                     if (pluginInUso) {
  18562.                         if((oldStatoEnabled != oldPlugin.getStato())) {
  18563.                             this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_PLUGINS_PLUGIN_INUSO_MODIFICA_STATO);
  18564.                         }
  18565.                         else {
  18566.                             this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_PLUGINS_PLUGIN_INUSO_MODIFICA_TIPO);
  18567.                         }
  18568.                         return false;
  18569.                     }
  18570.                 }
  18571.                
  18572.             }
  18573.            
  18574.            
  18575.             // Se tipoOp = add, controllo che l'archivio non sia gia' stato registrato
  18576.             boolean existsPluginConTipo = this.confCore.existsPluginConTipo(tipoPlugin, tipo);
  18577.             boolean existsPluginConLabel = this.confCore.existsPluginConLabel(tipoPlugin, label);
  18578.             boolean existsPluginConClassName = this.confCore.existsPluginConClassName(tipoPlugin, className);
  18579.             boolean errorExists = false;    
  18580.            
  18581.             if (tipoOp.equals(TipoOperazione.ADD)) {
  18582.                 errorExists = existsPluginConTipo || existsPluginConLabel || existsPluginConClassName;
  18583.             } else {
  18584.                 // controllo che le modifiche ai parametri non coincidano con altre regole gia' presenti
  18585.                 TipoPlugin oldTipoPlugin = TipoPlugin.toEnumConstant(oldPlugin.getTipoPlugin());
  18586.                    
  18587.                 // controllare se e' variato uno dei tipi della unique
  18588.                 if(!tipoPlugin.equals(oldTipoPlugin)) {
  18589.                     errorExists = existsPluginConTipo || existsPluginConLabel || existsPluginConClassName;
  18590.                 }
  18591.                 else if(!tipo.equals(oldPlugin.getTipo()) && existsPluginConTipo) {
  18592.                     errorExists = true;
  18593.                 }
  18594.                 else if(!label.equals(oldPlugin.getLabel()) && existsPluginConLabel) {
  18595.                     errorExists = true;
  18596.                 }
  18597.                 else if(!className.equals(oldPlugin.getClassName()) && existsPluginConClassName) {
  18598.                     errorExists = true;
  18599.                 }
  18600.             }
  18601.                
  18602.             if(errorExists) {
  18603.                
  18604.                 String descrizioneTipoPlugin = ConfigurazionePluginsTipoPluginUtils.tipoPluginToLabel(tipoPlugin);
  18605.                
  18606.                 if (existsPluginConTipo) {
  18607.                     this.pd.setMessage(MessageFormat.format(ConfigurazioneCostanti.MESSAGGIO_ERRORE_PLUGINS_PLUGIN_DUPLICATO_TIPO, descrizioneTipoPlugin, tipo));
  18608.                     return false;
  18609.                 }
  18610.                 if (existsPluginConLabel) {
  18611.                     this.pd.setMessage(MessageFormat.format(ConfigurazioneCostanti.MESSAGGIO_ERRORE_PLUGINS_PLUGIN_DUPLICATO_LABEL, descrizioneTipoPlugin, label));
  18612.                     return false;
  18613.                 }
  18614.                 if (existsPluginConClassName) {
  18615.                     this.pd.setMessage(MessageFormat.format(ConfigurazioneCostanti.MESSAGGIO_ERRORE_PLUGINS_PLUGIN_DUPLICATO_CLASSNAME, descrizioneTipoPlugin, className));
  18616.                     return false;
  18617.                 }
  18618.             }
  18619.            
  18620.             if(!this.checkLength255(descrizione, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_DESCRIZIONE)) {
  18621.                 return false;
  18622.             }
  18623.            
  18624.             return true;
  18625.         } catch (Exception e) {
  18626.             this.logError("Exception: " + e.getMessage(), e);
  18627.             throw new DriverControlStationException(e);
  18628.         }
  18629.     }
  18630.    
  18631.     public void addFilterTipoPlugin(String tipoPlugin, boolean postBack) throws Exception{
  18632.         try {
  18633.            
  18634.             boolean visualizzaAllarmi = this.confCore.isVisualizzaConfigurazioneAllarmiEnabled();  // configurazione allarmi (solo se sono stati caricati dei plugin di tipo allarme) tramite la funzionalità 'Importa'
  18635.             List<String> valuesTipoPlugin = ConfigurazionePluginsTipoPluginUtils.getValuesTipoPlugin(visualizzaAllarmi);
  18636.             List<String> labelsTipoPlugin = ConfigurazionePluginsTipoPluginUtils.getLabelsTipoPlugin(visualizzaAllarmi);
  18637.            
  18638.             int length = 1;
  18639.             if(valuesTipoPlugin!=null && valuesTipoPlugin.size()>0) {
  18640.                 length+=valuesTipoPlugin.size();
  18641.             }
  18642.             String [] values = new String[length];
  18643.             String [] labels = new String[length];
  18644.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_RUOLO_QUALSIASI;
  18645.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_RUOLO_QUALSIASI;
  18646.             if(valuesTipoPlugin!=null && valuesTipoPlugin.size()>0) {
  18647.                 for (int i =0; i < valuesTipoPlugin.size() ; i ++) {
  18648.                     labels[i+1] = labelsTipoPlugin.get(i);
  18649.                     values[i+1] = valuesTipoPlugin.get(i);
  18650.                 }
  18651.             }
  18652.            
  18653.             this.pd.addFilter(Filtri.FILTRO_TIPO_PLUGIN_CLASSI, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO_PLUGIN, tipoPlugin, values, labels, postBack, this.getSize());
  18654.            
  18655.         } catch (Exception e) {
  18656.             this.logError("Exception: " + e.getMessage(), e);
  18657.             throw new DriverControlStationException(e);
  18658.         }
  18659.     }
  18660.    
  18661.     public void addFiltriSpecificiTipoPlugin(String tipoPlugin, boolean postBack) throws Exception{
  18662.         try {
  18663.            
  18664.             List<String> valuesTipoPlugin = ConfigurazionePluginsTipoPluginUtils.getValuesTipoPlugin(this.confCore.isConfigurazioneAllarmiEnabled());
  18665.             List<String> labelsTipoPlugin = ConfigurazionePluginsTipoPluginUtils.getLabelsTipoPlugin(this.confCore.isConfigurazioneAllarmiEnabled());
  18666.            
  18667.             int length = 1;
  18668.             if(valuesTipoPlugin!=null && valuesTipoPlugin.size()>0) {
  18669.                 length+=valuesTipoPlugin.size();
  18670.             }
  18671.             String [] values = new String[length];
  18672.             String [] labels = new String[length];
  18673.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_RUOLO_QUALSIASI;
  18674.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_RUOLO_QUALSIASI;
  18675.             if(valuesTipoPlugin!=null && valuesTipoPlugin.size()>0) {
  18676.                 for (int i =0; i < valuesTipoPlugin.size() ; i ++) {
  18677.                     labels[i+1] = labelsTipoPlugin.get(i);
  18678.                     values[i+1] = valuesTipoPlugin.get(i);
  18679.                 }
  18680.             }
  18681.            
  18682.             this.pd.addFilter(Filtri.FILTRO_TIPO_PLUGIN_CLASSI, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_CLASSI_TIPO_PLUGIN, tipoPlugin, values, labels, postBack, this.getSize());
  18683.            
  18684.         } catch (Exception e) {
  18685.             this.logError("Exception: " + e.getMessage(), e);
  18686.             throw new DriverControlStationException(e);
  18687.         }
  18688.     }
  18689.     public void prepareAllarmiList(ConsoleSearch ricerca, List<ConfigurazioneAllarmeBean> lista,
  18690.             RuoloPorta ruoloPorta, String nomePorta, ServiceBinding serviceBinding) throws Exception{
  18691.         try {
  18692.             List<Parameter> lstParamSession = new ArrayList<>();

  18693.             Parameter parRuoloPorta = null;
  18694.             if(ruoloPorta!=null) {
  18695.                 parRuoloPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA, ruoloPorta.getValue());
  18696.                 lstParamSession.add(parRuoloPorta);
  18697.             }
  18698.             Parameter parNomePorta = null;
  18699.             if(nomePorta!=null) {
  18700.                 parNomePorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA, nomePorta);
  18701.                 lstParamSession.add(parNomePorta);
  18702.             }
  18703.             Parameter parServiceBinding = null;
  18704.             if(serviceBinding!=null) {
  18705.                 parServiceBinding = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING, serviceBinding.name());
  18706.                 lstParamSession.add(parServiceBinding);
  18707.             }
  18708.            
  18709.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_ALLARMI, lstParamSession);

  18710.             int idLista = Liste.CONFIGURAZIONE_ALLARMI;
  18711.             int limit = ricerca.getPageSize(idLista);
  18712.             int offset = ricerca.getIndexIniziale(idLista);
  18713.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  18714.             String filterStato = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_STATO);
  18715.             boolean addStatiAllarme = this.confCore.isShowAllarmiSearchStatiAllarmi();
  18716.             this.addFilterStato(filterStato, addStatiAllarme, false);
  18717.            
  18718.             this.pd.setIndex(offset);
  18719.             this.pd.setPageSize(limit);
  18720.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  18721.            
  18722.             this.pd.setCustomListViewName(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARMI_NOME_VISTA_CUSTOM_LISTA);
  18723.            
  18724.            
  18725.             List<Parameter> lstParamPorta = null;
  18726.             if(ruoloPorta!=null) {
  18727.                 lstParamPorta = getTitleListAllarmi(ruoloPorta, nomePorta, serviceBinding, null);
  18728.             }
  18729.            
  18730.            
  18731.             this.pd.setSearchLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ALIAS);
  18732.            
  18733.             if(search.equals("")){
  18734.                 this.pd.setSearchDescription("");
  18735.             }

  18736.             // setto la barra del titolo
  18737.             List<Parameter> lstParam = null;
  18738.             if(lstParamPorta!=null) {
  18739.                 lstParam = lstParamPorta;
  18740.             } else {
  18741.                 lstParam = new ArrayList<>();
  18742.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI, null));
  18743.             }
  18744.            
  18745.             if(!search.equals("")){
  18746.                 if(lstParamSession.size() > 0) {
  18747.                     lstParam.set((lstParam.size() -1), new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI,
  18748.                         ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_LIST, lstParamSession.toArray(new Parameter[lstParamSession.size()])));
  18749.                 } else {
  18750.                     lstParam.set((lstParam.size() -1), new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI,
  18751.                         ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_LIST));
  18752.                 }
  18753.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  18754.             }
  18755.            
  18756.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  18757.            
  18758.             if(ruoloPorta!=null) {
  18759.                 this.impostaComandiMenuContestualeAllarmi(ruoloPorta, nomePorta);
  18760.             }
  18761.            
  18762.             // controllo eventuali risultati ricerca
  18763.             if (!search.equals("")) {
  18764.                 ServletUtils.enabledPageDataSearch(this.pd, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI, search);
  18765.             }

  18766.             // setto le label delle colonne
  18767.             List<String> lstLabels = new ArrayList<>();
  18768.             //lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO);
  18769. //          lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_STATO);
  18770. //          lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA);
  18771.             //lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO);
  18772. //          lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ALIAS);
  18773. //          lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_DESCRIZIONE);
  18774. //          lstLabels.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RUNTIME);
  18775.            
  18776.             // label vista custom
  18777.             lstLabels.add("");//ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_STATO); // colonna stato
  18778.             lstLabels.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI);
  18779.            
  18780.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  18781.             // preparo i dati
  18782.             List<List<DataElement>> dati = new ArrayList<>();

  18783.             if (lista != null) {
  18784.                 Iterator<ConfigurazioneAllarmeBean> it = lista.iterator();
  18785.                 while (it.hasNext()) {
  18786.                     List<DataElement> e = creaEntryAllarmeCustom(lstParamSession, it);
  18787.                                        
  18788.                     dati.add(e);
  18789.                 }
  18790.             }
  18791.            
  18792.             this.pd.setDati(dati);
  18793.             this.pd.setAddButton(true);
  18794.            
  18795.             // preparo bottoni
  18796.             if(lista!=null && lista.size()>0){
  18797.                 if (this.core.isShowPulsantiImportExport()  && (nomePorta==null || StringUtils.isEmpty(nomePorta))) {

  18798.                     ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);
  18799.                     if(exporterUtils.existsAtLeastOneExportMode(org.openspcoop2.protocol.sdk.constants.ArchiveType.ALLARME, this.request, this.session)){

  18800.                         List<AreaBottoni> bottoni = new ArrayList<>();

  18801.                         AreaBottoni ab = new AreaBottoni();
  18802.                         List<DataElement> otherbott = new ArrayList<>();
  18803.                         DataElement de = new DataElement();
  18804.                         de.setValue(ConfigurazioneCostanti.LABEL_ALLARMI_ESPORTA_SELEZIONATI);
  18805.                         de.setOnClick(ConfigurazioneCostanti.LABEL_ALLARMI_ESPORTA_SELEZIONATI_ONCLICK);
  18806.                         de.setDisabilitaAjaxStatus();
  18807.                         otherbott.add(de);
  18808.                         ab.setBottoni(otherbott);
  18809.                         bottoni.add(ab);

  18810.                         this.pd.setAreaBottoni(bottoni);

  18811.                     }

  18812.                 }
  18813.             }
  18814.            
  18815.         } catch (Exception e) {
  18816.             this.logError("Exception: " + e.getMessage(), e);
  18817.             throw new DriverControlStationException(e);
  18818.         }
  18819.     }
  18820.    
  18821.     public void impostaComandiMenuContestualeAllarmi(RuoloPorta ruoloPorta, String nomePorta) throws Exception{
  18822.         if(ruoloPorta!=null) {
  18823.             if(RuoloPorta.DELEGATA.equals(ruoloPorta)) {
  18824.                 IDPortaDelegata idPortaDelegata = new IDPortaDelegata();
  18825.                 idPortaDelegata.setNome(nomePorta);
  18826.                 PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(idPortaDelegata);
  18827.                
  18828.                 MappingFruizionePortaDelegata mappingPD = this.porteDelegateCore.getMappingFruizionePortaDelegata(myPD);
  18829.                 long idSoggetto = myPD.getIdSoggetto().longValue();
  18830.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPD.getIdServizio());
  18831.                 long idFruizione = this.apsCore.getIdFruizioneAccordoServizioParteSpecifica(mappingPD.getIdFruitore(),mappingPD.getIdServizio());
  18832.                
  18833.                 PorteDelegateHelper porteDelegateHelper = new PorteDelegateHelper(this.request, this.pd, this.session);
  18834.                 porteDelegateHelper.impostaComandiMenuContestualePD(idSoggetto +"", idAsps+"", idFruizione+"");
  18835.             }
  18836.             else {
  18837.                 IDPortaApplicativa idPortaApplicativa = new IDPortaApplicativa();
  18838.                 idPortaApplicativa.setNome(nomePorta);
  18839.                 PortaApplicativa myPA = this.porteApplicativeCore.getPortaApplicativa(idPortaApplicativa);
  18840.                
  18841.                 MappingErogazionePortaApplicativa mappingPA = this.porteApplicativeCore.getMappingErogazionePortaApplicativa(myPA);
  18842.                 long idSoggetto = myPA.getIdSoggetto().longValue();
  18843.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPA.getIdServizio());
  18844.                
  18845.                 PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(this.request, this.pd, this.session);
  18846.                 porteApplicativeHelper.impostaComandiMenuContestualePA(idSoggetto+"", idAsps+"");
  18847.             }
  18848.         }
  18849.     }
  18850.    
  18851.     public List<DataElement> creaEntryAllarme(List<Parameter> lstParamSession, Iterator<ConfigurazioneAllarmeBean> it)
  18852.             throws UtilsException {
  18853.         ConfigurazioneAllarmeBean allarme = it.next();
  18854.        
  18855.         Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ID_ALLARME, allarme.getId() + "");
  18856.         List<Parameter> lstParamEntry = new ArrayList<>();
  18857.         lstParamEntry.add(pId);
  18858.         if(lstParamSession.size() > 0) {
  18859.             lstParamEntry.addAll(lstParamSession);
  18860.         }
  18861.        
  18862.         List<DataElement> e = new ArrayList<>();
  18863.        
  18864.         // Abilitato
  18865.         DataElement de = new DataElement();
  18866.         de.setWidthPx(10);
  18867.         de.setType(DataElementType.CHECKBOX);
  18868.         if(allarme.getEnabled() == 1){
  18869.             if(this.confCore.isShowAllarmiElenchiStatiAllarmi()) {
  18870.                 if(allarme.getStato()!=null && (allarme.getStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_OK.intValue())) {
  18871.                     de.setToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_OK);
  18872.                     de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_OK);
  18873.                     de.setSelected(CheckboxStatusType.CONFIG_ENABLE);
  18874.                 } else if(allarme.getStato()!=null && (allarme.getStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_ERROR.intValue())) {
  18875.                     de.setToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_ERROR);
  18876.                     de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_ERROR);
  18877.                     de.setSelected(CheckboxStatusType.CONFIG_ERROR);
  18878.                 } else if(allarme.getStato()!=null && (allarme.getStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_WARNING.intValue())) {
  18879.                     de.setToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_WARNING);
  18880.                     de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_WARNING);
  18881.                     de.setSelected(CheckboxStatusType.CONFIG_WARNING);
  18882.                 }
  18883.             }
  18884.             else {
  18885.                 de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  18886.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  18887.                 de.setSelected(CheckboxStatusType.CONFIG_ENABLE);
  18888.             }
  18889.         }
  18890.         else{
  18891.             de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  18892.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  18893.             de.setSelected(CheckboxStatusType.CONFIG_DISABLE);
  18894.         }
  18895.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntry.toArray(new Parameter[lstParamEntry.size()]));
  18896.         e.add(de);
  18897.        
  18898.         // Stato
  18899. //                  de = new DataElement();
  18900. //                  
  18901. //                  if(allarme.getEnabled() == 1) {
  18902. //                      if(allarme.getStato() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_OK) {
  18903. //                          de.setToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_OK);
  18904. //                          de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_OK);
  18905. //                      } else if(allarme.getStato() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_ERROR) {
  18906. //                          de.setToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_ERROR);
  18907. //                          de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_ERROR);
  18908. //                      } else if(allarme.getStato() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_WARNING) {
  18909. //                          de.setToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_WARNING);
  18910. //                          de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_WARNING);
  18911. //                      }
  18912. //                  } else {
  18913. //                      de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  18914. //                      de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  18915. //                  }
  18916. //                  
  18917. //                  e.add(de);
  18918.        
  18919. //                  // Tipo
  18920. //                  de = new DataElement();
  18921. //                  de.setValue(allarme.getTipo());
  18922. //                  e.add(de);
  18923.        
  18924.         // TipoAllarme
  18925.        
  18926.         de = new DataElement();
  18927.         de.setWidthPx(24);
  18928.         de.setType(DataElementType.IMAGE);
  18929.         DataElementImage imageUp = new DataElementImage();
  18930.         String mode = TipoAllarme.ATTIVO.equals(allarme.getTipoAllarme()) ? ConfigurazioneCostanti.VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA_ATTIVA : ConfigurazioneCostanti.VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA_PASSIVA;
  18931.         if(TipoAllarme.ATTIVO.equals(allarme.getTipoAllarme())) {
  18932.             imageUp.setImage(CostantiControlStation.ICONA_ALARM_ACTIVE);
  18933.             imageUp.setToolTip(mode);
  18934.         }
  18935.         else {
  18936.             imageUp.setImage(CostantiControlStation.ICONA_ALARM_PASSIVE);
  18937.             imageUp.setToolTip(mode);
  18938.         }
  18939.         de.addImage(imageUp);
  18940.         de.allineaTdAlCentro();
  18941.         de.setValue(mode);
  18942.         e.add(de);
  18943.        
  18944.         // Nome
  18945.         de = new DataElement();
  18946.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntry.toArray(new Parameter[lstParamEntry.size()]));
  18947.         de.setValue(allarme.getAlias());
  18948.         de.setIdToRemove(""+allarme.getId());
  18949.         //de.setToolTip(allarme.getNome());
  18950.         de.setToolTip(allarme.getAlias());
  18951.         e.add(de);
  18952.        
  18953.         // Descrizione
  18954.         de = new DataElement();
  18955.         de.setValue(allarme.getDescrizioneAbbr());
  18956.         de.setToolTip(allarme.getDescrizione());
  18957.         e.add(de);
  18958.        
  18959.         // Runtime
  18960.         boolean isActive = allarme.getEnabled() == 1 && TipoAllarme.ATTIVO.equals(allarme.getTipoAllarme());
  18961.         de = new DataElement();
  18962.         if(isActive){
  18963.             de.setValue("Visualizza");
  18964.         }
  18965.         else{
  18966.             de.setValue("-");
  18967.         }
  18968.         de.allineaTdAlCentro();
  18969.         de.setWidthPx(60);
  18970.         if(isActive){
  18971.             Parameter pState = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_STATE, true+"");
  18972.             List<Parameter> lstParamEntryState = new ArrayList<>();
  18973.             lstParamEntryState.addAll(lstParamEntry);
  18974.             lstParamEntryState.add(pState);
  18975.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntryState.toArray(new Parameter[lstParamEntryState.size()]));
  18976.         }
  18977.         e.add(de);
  18978.         return e;
  18979.     }
  18980.    
  18981.     private List<DataElement> creaEntryAllarmeCustom(List<Parameter> lstParamSession, Iterator<ConfigurazioneAllarmeBean> it) throws UtilsException {
  18982.         ConfigurazioneAllarmeBean allarme = it.next();
  18983.        
  18984.         Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ID_ALLARME, allarme.getId() + "");
  18985.         List<Parameter> lstParamEntry = new ArrayList<>();
  18986.         lstParamEntry.add(pId);
  18987.         if(lstParamSession.size() > 0) {
  18988.             lstParamEntry.addAll(lstParamSession);
  18989.         }
  18990.        
  18991.         List<DataElement> e = new ArrayList<>();
  18992.        
  18993.         // Riga 1 Titolo
  18994.         DataElement de = new DataElement();
  18995.         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntry.toArray(new Parameter[lstParamEntry.size()]));
  18996.         de.setValue(allarme.getAlias());
  18997.         de.setIdToRemove(""+allarme.getId());
  18998.         de.setType(DataElementType.TITLE);
  18999.         e.add(de);
  19000.        
  19001.         // Riga2 : Modalita' + descrizione
  19002.         de = new DataElement();
  19003.         String mode = TipoAllarme.ATTIVO.equals(allarme.getTipoAllarme()) ? ConfigurazioneCostanti.VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA_ATTIVA : ConfigurazioneCostanti.VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA_PASSIVA;
  19004.         String descrAbbr = allarme.getDescrizioneAbbr();
  19005.         if(StringUtils.isNotBlank(descrAbbr)) {
  19006.             de.setValue(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_ALLARMI_LIST_MODALITA_DESCRIZIONE, mode, descrAbbr));
  19007.         } else {
  19008.             de.setValue(MessageFormat.format(ConfigurazioneCostanti.MESSAGE_METADATI_ALLARMI_LIST_MODALITA, mode));
  19009.         }
  19010.         de.setType(DataElementType.SUBTITLE);
  19011.         e.add(de);
  19012.        
  19013.         // Abilitato
  19014.         de = new DataElement();
  19015.         de.setWidthPx(16);
  19016.         de.setType(DataElementType.CHECKBOX);
  19017.         if(allarme.getEnabled() == 1){
  19018.             if(this.confCore.isShowAllarmiElenchiStatiAllarmi()) {
  19019.                 if(allarme.getStato()!=null && (allarme.getStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_OK.intValue())) {
  19020.                     de.setStatusType(CheckboxStatusType.CONFIG_ENABLE);
  19021.                     de.setStatusToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_OK);
  19022.                 } else if(allarme.getStato()!=null && (allarme.getStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_ERROR.intValue())) {
  19023.                     de.setStatusType(CheckboxStatusType.CONFIG_ERROR);
  19024.                     de.setStatusToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_ERROR);
  19025.                 } else if(allarme.getStato()!=null && (allarme.getStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_WARNING.intValue())) {
  19026.                     de.setStatusType(CheckboxStatusType.CONFIG_WARNING);
  19027.                     de.setStatusToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_WARNING);
  19028.                 }
  19029.             }
  19030.             else {
  19031.                 de.setStatusType(CheckboxStatusType.CONFIG_ENABLE);
  19032.                 de.setStatusToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  19033.             }
  19034.         }
  19035.         else{
  19036.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  19037.             de.setStatusToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  19038.         }
  19039.         e.add(de);
  19040.        
  19041.         // Runtime
  19042.         boolean isActive = allarme.getEnabled() == 1 && TipoAllarme.ATTIVO.equals(allarme.getTipoAllarme());
  19043.         de = new DataElement();
  19044.         if(isActive){
  19045.             Parameter pState = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_STATE, true+"");
  19046.             List<Parameter> lstParamEntryState = new ArrayList<>();
  19047.             lstParamEntryState.addAll(lstParamEntry);
  19048.             lstParamEntryState.add(pState);
  19049.             this.addVisualizzaRuntimeButton(e, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntryState);
  19050.         }
  19051.        
  19052.         return e;
  19053.     }
  19054.    
  19055.     public List<Parameter> getTitleListAllarmi(RuoloPorta ruoloPorta, String nomePorta, ServiceBinding serviceBinding, String nomeOggetto) throws Exception{
  19056.         List<Parameter> lstParamPorta = null;
  19057.         if(ruoloPorta!=null) {
  19058.             String labelPerPorta = null;
  19059.             if(RuoloPorta.DELEGATA.equals(ruoloPorta)) {
  19060.                 // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  19061.                 Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  19062.                 if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  19063.                
  19064.                 IDPortaDelegata idPortaDelegata = new IDPortaDelegata();
  19065.                 idPortaDelegata.setNome(nomePorta);
  19066.                 PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(idPortaDelegata);
  19067.                 String idporta = myPD.getNome();
  19068.                
  19069.                 MappingFruizionePortaDelegata mappingPD = this.porteDelegateCore.getMappingFruizionePortaDelegata(myPD);
  19070.                 long idSoggetto = myPD.getIdSoggetto().longValue();
  19071.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPD.getIdServizio());
  19072.                 long idFruizione = this.apsCore.getIdFruizioneAccordoServizioParteSpecifica(mappingPD.getIdFruitore(),mappingPD.getIdServizio());
  19073.                
  19074.                 PorteDelegateHelper porteDelegateHelper = new PorteDelegateHelper(this.request, this.pd, this.session);
  19075.                 lstParamPorta = porteDelegateHelper.getTitoloPD(parentPD,idSoggetto +"", idAsps+"", idFruizione+"");
  19076.                
  19077.                 if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  19078.                     labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  19079.                             ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_DI,
  19080.                             ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI,
  19081.                             myPD);
  19082.                 }
  19083.                 else {
  19084.                     labelPerPorta = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_DI+idporta;
  19085.                 }
  19086.                
  19087.             }
  19088.             else {
  19089.                 Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, this.session, this.request);
  19090.                
  19091.                 IDPortaApplicativa idPortaApplicativa = new IDPortaApplicativa();
  19092.                 idPortaApplicativa.setNome(nomePorta);
  19093.                 PortaApplicativa myPA = this.porteApplicativeCore.getPortaApplicativa(idPortaApplicativa);
  19094.                 String idporta = myPA.getNome();
  19095.                
  19096.                 MappingErogazionePortaApplicativa mappingPA = this.porteApplicativeCore.getMappingErogazionePortaApplicativa(myPA);
  19097.                 long idSoggetto = myPA.getIdSoggetto().longValue();
  19098.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPA.getIdServizio());
  19099.                
  19100.                 PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(this.request, this.pd, this.session);
  19101.                 lstParamPorta = porteApplicativeHelper.getTitoloPA(parentPA, idSoggetto+"", idAsps+"");
  19102.                
  19103.                 if(parentPA!=null && (parentPA.intValue() == PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE)) {
  19104.                     labelPerPorta = this.porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  19105.                             ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_DI,
  19106.                             ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI,
  19107.                             myPA);
  19108.                 }
  19109.                 else {
  19110.                     labelPerPorta = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_DI+idporta;
  19111.                 }
  19112.                
  19113.             }
  19114.            
  19115.             if(nomeOggetto==null) {
  19116.                 lstParamPorta.add(new Parameter(labelPerPorta,null));
  19117.             }
  19118.             else {
  19119.                 List<Parameter> list = new ArrayList<>();
  19120.                 list.add(new Parameter( ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA, ruoloPorta.getValue()));
  19121.                 list.add(new Parameter( ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA, nomePorta));
  19122.                 if(serviceBinding!=null) {
  19123.                     list.add(new Parameter( ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING,serviceBinding.name()));
  19124.                 }
  19125.                 lstParamPorta.add(new Parameter(labelPerPorta, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_LIST, list));
  19126.                 lstParamPorta.add(new Parameter(nomeOggetto,null));
  19127.             }
  19128.         }
  19129.        
  19130.         return lstParamPorta;
  19131.     }
  19132.    
  19133.    
  19134.    
  19135.     public boolean allarmeCheckData(StringBuilder sbParsingError, TipoOperazione tipoOp, ConfigurazioneAllarmeBean oldAllarme, ConfigurazioneAllarmeBean allarme, int numeroPluginRegistrati
  19136.             , List<org.openspcoop2.monitor.sdk.parameters.Parameter<?>> parameters) throws Exception {
  19137.        
  19138.         try {
  19139.            
  19140.             // errori di parsing letti durante la read della richiesta
  19141.             if(sbParsingError.length() >0){
  19142.                 this.pd.setMessage(sbParsingError.toString());
  19143.                 return false;
  19144.             }
  19145.            
  19146.             /* ******** CONTROLLO PLUGIN *************** */
  19147.            
  19148.             if(allarme.getPlugin()==null){
  19149.                 if(numeroPluginRegistrati<=0){
  19150.                     this.log.debug("Non risultano registrati plugins di allarmi");
  19151.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_FILTRO_PLUGIN_NON_TROVATI);
  19152.                 }
  19153.                 else{
  19154.                     this.log.debug("Non è stato selezionato un plugin");
  19155.                     this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_PLUGIN+"'");
  19156.                     return false;
  19157.                 }
  19158.                 return false;
  19159.             }
  19160.            
  19161.             /* ******** ELEMENTI OBBLIGATORI *************** */
  19162.            
  19163.             if(allarme.getTipoAllarme()==null){
  19164.                 this.log.debug("Non è stato indicato il tipo di allarme (è stato selezionato un plugin?)");
  19165.                 this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_TIPO_NON_INDICATO);
  19166.                 return false;
  19167.             }
  19168.            
  19169.             if(allarme.getNome()==null || "".equals(allarme.getNome())){
  19170.                 this.log.debug("Non è stato indicato un nome identificativo dell'allarme");
  19171.                 this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME+"'");
  19172.                 return false;
  19173.             }
  19174.             if (!this.checkNCNameAndSerial(allarme.getNome(), ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME)) {
  19175.                 return false;
  19176.             }
  19177.            
  19178.             if(allarme.getAlias()==null || "".equals(allarme.getAlias())){
  19179.                 this.log.debug("Non è stato indicato un nome per l'allarme");
  19180.                 this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ALIAS+"'");
  19181.                 return false;
  19182.             }
  19183.             if (!this.checkNCName(allarme.getAlias(), ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ALIAS)) {
  19184.                 return false;
  19185.             }
  19186.            
  19187.             if(allarme.getTipoAllarme().equals(TipoAllarme.ATTIVO)){
  19188.                 if(allarme.getPeriodo()==null){
  19189.                     this.log.debug("Non è stata indicata la frequenza di attivazione per il controllo dello stato dell'allarme");
  19190.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_FREQUENZA_NON_INDICATA);
  19191.                     return false;
  19192.                 }
  19193.                 if(allarme.getPeriodo()<=0){
  19194.                     this.log.debug("Indicare una frequenza di attivazione (maggiore di 0) per il controllo dello stato dell'allarme");
  19195.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_FREQUENZA_NON_VALIDA);
  19196.                     return false;
  19197.                 }
  19198.             }
  19199.            
  19200.             if(allarme.getFiltro().isEnabled()){
  19201.                
  19202.                 if( (allarme.getFiltro().getRuoloPorta()==null || RuoloPorta.ENTRAMBI.equals(allarme.getFiltro().getRuoloPorta()))
  19203.                         &&
  19204.                         allarme.getFiltro().getProtocollo()==null &&
  19205.                         allarme.getFiltro().getRuoloFruitore()==null &&
  19206.                         allarme.getFiltro().getTipoFruitore()==null &&
  19207.                         allarme.getFiltro().getNomeFruitore()==null &&
  19208.                         allarme.getFiltro().getServizioApplicativoFruitore()==null &&
  19209.                         allarme.getFiltro().getRuoloErogatore()==null &&
  19210.                         allarme.getFiltro().getTipoErogatore()==null &&
  19211.                         allarme.getFiltro().getNomeErogatore()==null &&
  19212.                         allarme.getFiltro().getTag()==null &&
  19213.                         allarme.getFiltro().getTipoServizio()==null &&
  19214.                         allarme.getFiltro().getNomeServizio()==null &&
  19215.                         allarme.getFiltro().getAzione()==null){
  19216.                     String messaggio = "Se si abilita il filtro deve essere selezionato almeno un criterio";
  19217.                     this.pd.setMessage(messaggio);
  19218.                     return false;
  19219.                 }
  19220.                
  19221.             }
  19222.            
  19223.             if(allarme.getGroupBy().isEnabled()){
  19224.                
  19225.                 if( !allarme.getGroupBy().isRuoloPorta() &&
  19226.                         !allarme.getGroupBy().getProtocollo() &&
  19227.                         !allarme.getGroupBy().getFruitore() &&
  19228.                         !allarme.getGroupBy().getServizioApplicativoFruitore() &&
  19229.                         !allarme.getGroupBy().getIdentificativoAutenticato() &&
  19230.                         (allarme.getGroupBy().getToken()==null || "".equals(allarme.getGroupBy().getToken())) &&
  19231.                         !allarme.getGroupBy().getErogatore() &&
  19232.                         !allarme.getGroupBy().getServizio() &&
  19233.                         !allarme.getGroupBy().getAzione()){
  19234.                     String messaggio = "Se si abilita il collezionamento dei dati deve essere selezionato almeno un criterio di raggruppamento";
  19235.                     this.pd.setMessage(messaggio);
  19236.                     return false;
  19237.                 }
  19238.             }
  19239.            
  19240.             /* ******** VALIDAZIONE E SALVATAGGIO PARAMETRI *************** */
  19241.            
  19242.             IDynamicValidator v = DynamicFactory.getInstance().newDynamicValidator(TipoPlugin.ALLARME, allarme.getTipo(), allarme.getPlugin().getClassName(),this.log);
  19243.            
  19244.             Context context = this.createAlarmContext(allarme, parameters);
  19245.             try {
  19246.                 // validazione parametri
  19247.                 v.validate(context);
  19248.             }  catch (ValidationException e) {
  19249.                 StringBuilder sb = new StringBuilder();
  19250.                
  19251.                 sb.append(e.getMessage());

  19252.                 Map<String, String> errors = e.getErrors();
  19253.                 if (errors != null) {
  19254.                     Set<String> keys = errors.keySet();
  19255.                    
  19256.                     StringBuilder sbInner = new StringBuilder();

  19257.                     for (String key : keys) {
  19258.                         if(sbInner.length() >0) {
  19259.                             sbInner.append("\n");
  19260.                         }

  19261.                         org.openspcoop2.monitor.sdk.parameters.Parameter<?> sp = context.getParameter(key);

  19262.                         String errorMsg = errors.get(key);

  19263.                         // recupero il label del parametro
  19264.                         String label = sp != null ? sp.getRendering().getLabel() : key;

  19265.                         sbInner.append(label).append(": ").append(errorMsg);

  19266.                     }
  19267.                    
  19268.                     sb.append("\n").append(sbInner.toString());
  19269.                 }
  19270.                 this.pd.setMessage(sb.toString());
  19271.                 return false;
  19272.             }
  19273.            
  19274.            
  19275.             /* ******** VALIDAZIONE NOTIFICA MAIL *************** */
  19276.            
  19277.             if(allarme.getMail()!=null && allarme.getMail().getInvia()!=null && allarme.getMail().getInvia()==1){
  19278.                 if(allarme.getMail().getDestinatari()==null || "".equals(allarme.getMail().getDestinatari())){
  19279.                     this.log.debug("Almeno un indirizzo e-mail è obbligatorio");
  19280.                     this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_EMAIL_VUOTA);
  19281.                     return false;
  19282.                 }
  19283.                 String [] tmp = allarme.getMail().getDestinatari().split(",");
  19284.                 for (int i = 0; i < tmp.length; i++) {
  19285.                     if(this.checkEmail(tmp[i].trim(), ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_EMAIL)==false){
  19286.                         this.log.debug("L'indirizzo e-mail fornito ["+tmp[i].trim()+"] non risulta valido");
  19287.                         return false;
  19288.                     }
  19289.                 }
  19290.             }
  19291.            
  19292.             boolean porta = allarme.getFiltro()!=null && allarme.getFiltro().isEnabled() && allarme.getFiltro().getRuoloPorta()!=null && allarme.getFiltro().getNomePorta()!=null;
  19293.            
  19294.            
  19295.             // Controllo alias
  19296.             boolean existsAlias = false;
  19297.             ConsoleSearch search = new ConsoleSearch(true);
  19298.             List<ConfigurazioneAllarmeBean> allarmiConAlias = this.confCore.allarmiList(search, porta ? allarme.getFiltro().getRuoloPorta(): null,
  19299.                     porta ? allarme.getFiltro().getNomePorta() : null);
  19300.             if(allarmiConAlias!=null && !allarmiConAlias.isEmpty()) {
  19301.                 for (ConfigurazioneAllarmeBean allarmeCheck : allarmiConAlias) {
  19302.                     if(allarmeCheck.getAlias().equals(allarme.getAlias())) {
  19303.                         if (tipoOp.equals(TipoOperazione.ADD)) {
  19304.                             existsAlias = true;
  19305.                         }
  19306.                         else {
  19307.                             if(allarmeCheck.getId().longValue() != allarme.getId().longValue()) {
  19308.                                 existsAlias = true;
  19309.                             }
  19310.                         }      
  19311.                     }
  19312.                 }
  19313.             }
  19314.             if(existsAlias) {
  19315.                 this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_ALIAS_DUPLICATO);
  19316.                 return false;
  19317.             }
  19318.            
  19319.             // Controllo nome (si può solo modificare in ADD)
  19320.             if(tipoOp.equals(TipoOperazione.ADD)) {
  19321.                 boolean existsAllarme = this.confCore.existsAllarme(allarme.getNome());
  19322.                 if (existsAllarme) {
  19323.                        
  19324.                     ConfigurazioneAllarmeBean existsAllarmeBean = this.confCore.getAllarme(allarme.getNome());
  19325.                     if(existsAllarmeBean.getFiltro()!=null && existsAllarmeBean.getFiltro().isEnabled() &&
  19326.                             existsAllarmeBean.getFiltro().getRuoloPorta()!=null &&
  19327.                             StringUtils.isNotEmpty(existsAllarmeBean.getFiltro().getNomePorta())) {
  19328.                         if(org.openspcoop2.core.allarmi.constants.RuoloPorta.APPLICATIVA.equals(existsAllarmeBean.getFiltro().getRuoloPorta())) {
  19329.                             String descrPorta = null;
  19330.                             try {
  19331.                                 IDPortaApplicativa idPA = new IDPortaApplicativa();
  19332.                                 idPA.setNome(existsAllarmeBean.getFiltro().getNomePorta());
  19333.                                
  19334.                                 PortaApplicativa pa = this.porteApplicativeCore.getPortaApplicativa(idPA);
  19335.                                 MappingErogazionePortaApplicativa mappingPA = this.porteApplicativeCore.getMappingErogazionePortaApplicativa(pa);
  19336.                                
  19337.                                 String suffixGruppo = "";
  19338.                                 if(!mappingPA.isDefault()) {
  19339.                                     suffixGruppo = " (Gruppo: "+mappingPA.getDescrizione()+")";
  19340.                                 }
  19341.                                 String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(pa.getTipoSoggettoProprietario());
  19342.                                 descrPorta="["+NamingUtils.getLabelProtocollo(protocollo)+"] "+
  19343.                                         NamingUtils.getLabelAccordoServizioParteSpecifica(protocollo, mappingPA.getIdServizio())+
  19344.                                         suffixGruppo;
  19345.                             }catch(Exception e) {
  19346.                                 this.logError("Identificazione erogazione che possiede l'allarme '"+allarme.getNome()+"' non riuscita: "+e.getMessage(),e);
  19347.                                 descrPorta = existsAllarmeBean.getFiltro().getNomePorta();
  19348.                             }
  19349.                            
  19350.                             this.pd.setMessage(MessageFormat.format(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_DUPLICATO_EXISTS_IN_EROGAZIONE, descrPorta));
  19351.                         }
  19352.                         else if(org.openspcoop2.core.allarmi.constants.RuoloPorta.DELEGATA.equals(existsAllarmeBean.getFiltro().getRuoloPorta())) {
  19353.                             String descrPorta = null;
  19354.                             try {
  19355.                                 IDPortaDelegata idPD = new IDPortaDelegata();
  19356.                                 idPD.setNome(existsAllarmeBean.getFiltro().getNomePorta());
  19357.                                
  19358.                                 PortaDelegata pd = this.porteDelegateCore.getPortaDelegata(idPD);
  19359.                                 MappingFruizionePortaDelegata mappingPD = this.porteDelegateCore.getMappingFruizionePortaDelegata(pd);
  19360.                                
  19361.                                 String suffixGruppo = "";
  19362.                                 if(!mappingPD.isDefault()) {
  19363.                                     suffixGruppo = " (Gruppo: "+mappingPD.getDescrizione()+")";
  19364.                                 }
  19365.                                 String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(pd.getTipoSoggettoProprietario());
  19366.                                 descrPorta="["+NamingUtils.getLabelProtocollo(protocollo)+"] "+
  19367.                                         NamingUtils.getLabelAccordoServizioParteSpecifica(protocollo, mappingPD.getIdServizio())+
  19368.                                         " (Fruitore:"+NamingUtils.getLabelSoggetto(protocollo, new IDSoggetto(pd.getTipoSoggettoProprietario(), pd.getNomeSoggettoProprietario()))+")"+
  19369.                                         suffixGruppo;
  19370.                             }catch(Exception e) {
  19371.                                 this.logError("Identificazione fruizione che possiede l'allarme '"+allarme.getNome()+"' non riuscita: "+e.getMessage(),e);
  19372.                                 descrPorta = existsAllarmeBean.getFiltro().getNomePorta();
  19373.                             }
  19374.                        
  19375.                             this.pd.setMessage(MessageFormat.format(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_DUPLICATO_EXISTS_IN_FRUIZIONE, descrPorta));
  19376.                         }
  19377.                         else {
  19378.                             this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_DUPLICATO_EXISTS_IN_CONFIGURAZIONE_GENERALE);
  19379.                         }
  19380.                     }
  19381.                     else {
  19382.                         this.pd.setMessage(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_DUPLICATO_EXISTS_IN_CONFIGURAZIONE_GENERALE);
  19383.                     }
  19384.                     return false;
  19385.                 }
  19386.             }
  19387.            
  19388.             return true;
  19389.         } catch (Exception e) {
  19390.             this.logError("Exception: " + e.getMessage(), e);
  19391.             throw new DriverControlStationException(e);
  19392.         }
  19393.     }
  19394.    
  19395.     public Context createAlarmContext(ConfigurazioneAllarmeBean allarme, List<org.openspcoop2.monitor.sdk.parameters.Parameter<?>> parameters) throws DAOFactoryException {
  19396.         Context context = new AlarmContext(allarme, this.log, DAOConsoleFactory.getInstance(this.log), parameters );
  19397.        
  19398.         return context;
  19399.     }
  19400.    
  19401.     public void sendToAllarmi(List<String> urls) throws Exception{
  19402.         if(urls!=null && urls.size()>0){
  19403.             for (String url : urls) {
  19404.                 this.log.debug("Invoke ["+url+"] ...");
  19405.                 HttpResponse response = HttpUtilities.getHTTPResponse(url);
  19406.                 if(response.getContent()!=null){
  19407.                     this.log.debug("Invoked ["+url+"] Status["+response.getResultHTTPOperation()+"] Message["+new String(response.getContent())+"]");  
  19408.                 }
  19409.                 else{
  19410.                     this.log.debug("Invoked ["+url+"] Status["+response.getResultHTTPOperation()+"]");
  19411.                 }
  19412.                 if(response.getResultHTTPOperation()>202){
  19413.                     throw new DriverControlStationException("Error occurs during invoke url["+url+"] Status["+response.getResultHTTPOperation()+"] Message["+new String(response.getContent())+"]");    
  19414.                 }  
  19415.             }
  19416.         }
  19417.     }
  19418.    
  19419.     public String readAllarmeFromRequest(TipoOperazione tipoOp, boolean first,
  19420.             ConfigurazioneAllarmeBean allarme, AlarmEngineConfig alarmEngineConfig, Plugin plugin, List<org.openspcoop2.monitor.sdk.parameters.Parameter<?>> parameters ) throws Exception {

  19421.         StringBuilder sbParsingError = new StringBuilder();
  19422.        
  19423.         if(first) {
  19424. //          if(tipoOp.equals(TipoOperazione.ADD)) {
  19425. //              allarme.setEnabled(1);
  19426. //              allarme.setTipoAllarme(null);
  19427. //              allarme.setMail(new AllarmeMail());
  19428. //              allarme.getMail().setInviaAlert(0);
  19429. //              allarme.getMail().setInviaWarning(0);
  19430. //              if(alarmEngineConfig.isMailAckMode()){
  19431. //                  allarme.getMail().setAckMode(1);
  19432. //              }else{
  19433. //                  allarme.getMail().setAckMode(0);
  19434. //              }
  19435. //              allarme.setScript(new AllarmeScript());
  19436. //              allarme.getScript().setInvocaAlert(0);
  19437. //              allarme.getScript().setInvocaWarning(0);
  19438. //              if(alarmEngineConfig.isScriptAckMode()){
  19439. //                  allarme.getScript().setAckMode(1);
  19440. //              }else{
  19441. //                  allarme.getScript().setAckMode(0);
  19442. //              }
  19443. //          }
  19444.         } else {
  19445.             // ricostruisco lo stato a partire dai parametri
  19446.             String idAllarmeS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ID_ALLARME);
  19447.             if(tipoOp.equals(TipoOperazione.ADD)) {
  19448.                 allarme.setId(null);
  19449.             } else {
  19450.                 allarme.setId(Long.parseLong(idAllarmeS));
  19451.             }
  19452.            
  19453.             String nome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME);
  19454.             allarme.setNome(nome);
  19455.            
  19456.             String alias = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ALIAS);
  19457.             allarme.setAlias(alias);
  19458.            
  19459.             String descrizione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_DESCRIZIONE);
  19460.             allarme.setDescrizione(descrizione);
  19461.            
  19462.             String tipo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO);
  19463.             allarme.setTipo(tipo);
  19464.            
  19465.             String modalitaS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA);
  19466.             TipoAllarme tipoAllarme = null;
  19467.             if(StringUtils.isNotBlank(modalitaS)) {
  19468.                 tipoAllarme = TipoAllarme.toEnumConstant(modalitaS);
  19469.             }
  19470.             allarme.setTipoAllarme(tipoAllarme);
  19471.            
  19472. //          String descrizione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_DESCRIZIONE);
  19473.            
  19474.             if(allarme.getTipoAllarme() != null && (allarme.getTipoAllarme().equals(TipoAllarme.ATTIVO))) {
  19475.                 String periodoS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_PERIODO);
  19476.                 String tipoPeriodoS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO_PERIODO);
  19477.                
  19478.                 if(StringUtils.isNotBlank(periodoS)) {
  19479.                     try {
  19480.                         allarme.setPeriodo(Integer.parseInt(periodoS));
  19481.                     }catch(Throwable t) {
  19482.                         this.logError("Periodo indicato non è un intero ["+periodoS+"]: "+t.getMessage(),t);
  19483.                     }
  19484.                 }
  19485.                
  19486.                 if(StringUtils.isNotBlank(tipoPeriodoS)) {
  19487.                     if(ConfigurazioneCostanti.VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO_PERIODO_MINUTI.equals(tipoPeriodoS)){
  19488.                         allarme.setTipoPeriodo(AllarmiConverterUtils.toValue(TipoPeriodo.M));
  19489.                     }
  19490.                     else if(ConfigurazioneCostanti.VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO_PERIODO_GIORNI.equals(tipoPeriodoS)){
  19491.                         allarme.setTipoPeriodo(AllarmiConverterUtils.toValue(TipoPeriodo.G));
  19492.                     }
  19493.                     else{
  19494.                         allarme.setTipoPeriodo(AllarmiConverterUtils.toValue(TipoPeriodo.H));
  19495.                     }
  19496.                 }
  19497.             }
  19498.            
  19499.             String abilitatoS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO);
  19500.             if(StringUtils.isNotBlank(abilitatoS)) {
  19501.                 allarme.setEnabled(Integer.parseInt(abilitatoS));
  19502.             }
  19503.            
  19504.            
  19505.             // Sezione filtro/ groupby
  19506.             this.readDatiAllarmeFiltroFromHttpParameters(allarme, first);
  19507.            
  19508.             // sezione parametri
  19509.             if(plugin != null) {
  19510.                 if(parameters != null&& parameters.size() > 0) {
  19511.                     for (org.openspcoop2.monitor.sdk.parameters.Parameter<?> par : parameters) {
  19512.                         String value = this.getParameter(par.getId());
  19513.                         if(ParameterType.CHECK_BOX.equals(par.getType())){
  19514.                             if(Costanti.CHECK_BOX_ENABLED.equals(value) || Costanti.CHECK_BOX_ENABLED_ABILITATO.equals(value) || Costanti.CHECK_BOX_ENABLED_TRUE.equals(value)) {
  19515.                                 value = Costanti.CHECK_BOX_ENABLED_TRUE;
  19516.                             }
  19517.                             else {
  19518.                                 value = Costanti.CHECK_BOX_DISABLED_FALSE;
  19519.                             }
  19520.                         }
  19521.                         par.setValueAsString(value);
  19522. //                      
  19523. //                      boolean found = false;
  19524. //                      for (AllarmeParametro parDB : allarme.getAllarmeParametroList()) {
  19525. //                          if(parDB.getIdParametro().equals(par.getId())){
  19526. //                              parDB.setValore(par.getValueAsString());
  19527. //                              found = true;
  19528. //                              break;
  19529. //                          }
  19530. //                      }
  19531. //                      if(!found){
  19532. //                          AllarmeParametro parDB = new AllarmeParametro();
  19533. //                          parDB.setIdParametro(par.getId());
  19534. //                          parDB.setValore(par.getValueAsString());
  19535. //                          allarme.addAllarmeParametro(parDB);
  19536. //                      }
  19537.                     }
  19538.                 }
  19539.             }
  19540.            
  19541.             // sezione mail
  19542.             String inviaEmailAlertS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_INVIA_EMAIL_ALERT);
  19543.             if(StringUtils.isNotBlank(inviaEmailAlertS)) {
  19544.                 allarme.getMail().setInvia(Integer.parseInt(inviaEmailAlertS));
  19545.             }
  19546.            
  19547.             if(allarme.getMail().getInvia() == 1) {
  19548.                 String destinatariEmail = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_DESTINATARI_EMAIL);
  19549.                 allarme.getMail().setDestinatari(destinatariEmail);
  19550.                
  19551.                 // notifica warning
  19552.                 String notificaWarningEmailS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_WARNING);
  19553.                 if(StringUtils.isNotBlank(notificaWarningEmailS)) {
  19554.                     allarme.getMail().setInviaWarning(Integer.parseInt(notificaWarningEmailS));
  19555.                 }
  19556.                
  19557.                 if(this.confCore.getAllarmiConfig().isMailShowAllOptions()) {                  
  19558.                     // Subject
  19559.                     String subject = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_INVIA_EMAIL_SUBJECT);
  19560.                     allarme.getMail().setSubject(subject);
  19561.                    
  19562.                     // Body
  19563.                     String body = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_INVIA_EMAIL_BODY);
  19564.                     allarme.getMail().setBody(body);
  19565.                 }
  19566.             }
  19567.            
  19568.             // sezione script
  19569.             String invocaScriptAlertS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_INVOCA_SCRIPT_ALERT);
  19570.             if(StringUtils.isNotBlank(invocaScriptAlertS)) {
  19571.                 allarme.getScript().setInvoca(Integer.parseInt(invocaScriptAlertS));
  19572.             }
  19573.            
  19574.             if(allarme.getScript().getInvoca() == 1) {
  19575.                 // notifica warning
  19576.                 String notificaWarningScriptS = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_WARNING_SCRIPT);
  19577.                 if(StringUtils.isNotBlank(notificaWarningScriptS)) {
  19578.                     allarme.getScript().setInvocaWarning(Integer.parseInt(notificaWarningScriptS));
  19579.                 }
  19580.                
  19581.                 if(this.confCore.getAllarmiConfig().isScriptShowAllOptions()) {
  19582.                     // Subject
  19583.                     String path = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_SCRIPT_PATH);
  19584.                     allarme.getScript().setCommand(path);
  19585.                    
  19586.                     // Body
  19587.                     String args = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_SCRIPT_ARGUMENTS);
  19588.                     allarme.getScript().setArgs(args);
  19589.                 }
  19590.             }
  19591.         }
  19592.        
  19593.         if(sbParsingError.length() > 0){
  19594.             return sbParsingError.toString();
  19595.         }
  19596.            
  19597.         return null;
  19598.     }
  19599.    
  19600.    
  19601.     public String readDatiAllarmeFiltroFromHttpParameters(ConfigurazioneAllarmeBean policy, boolean first) throws Exception {
  19602.        
  19603.         StringBuilder sbParsingError = new StringBuilder();
  19604.        
  19605.         // Filtro - stato
  19606.         String stato = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_ENABLED);
  19607.         if(stato!=null && !"".equals(stato)){
  19608.             policy.getFiltro().setEnabled(ServletUtils.isCheckBoxEnabled(stato));
  19609.         }
  19610.        
  19611.         // Filtro
  19612.         if(policy.getFiltro().isEnabled()){
  19613.            
  19614.             // ruolo della PdD
  19615.             String ruoloPdD = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_PDD);
  19616.             if(ruoloPdD!=null && !"".equals(ruoloPdD)){
  19617.                 try{
  19618.                     policy.getFiltro().setRuoloPorta(RuoloPorta.toEnumConstant(ruoloPdD, true));
  19619.                 }catch(Exception e){
  19620.                     String messaggio = "Il valore ("+ruoloPdD+") indicato in '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_PDD+"' non è tra i ruoli gestiti";
  19621.                     this.logError(messaggio,e);
  19622.                     this.addParsingError(sbParsingError,messaggio);
  19623.                 }
  19624.             }
  19625.            
  19626.             // protocollo
  19627.             String protocollo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PROTOCOLLO);
  19628.             if(protocollo!=null && !"".equals(protocollo) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(protocollo)){
  19629.                 policy.getFiltro().setProtocollo(protocollo);
  19630.             }
  19631.             else{
  19632.                 if(!first){
  19633.                     policy.getFiltro().setProtocollo(null);
  19634.                 }
  19635.             }
  19636.            
  19637.             // ruolo erogatore
  19638.             String ruoloErogatore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_EROGATORE);
  19639.             if(ruoloErogatore!=null && !"".equals(ruoloErogatore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(ruoloErogatore) ){
  19640.                 policy.getFiltro().setRuoloErogatore(ruoloErogatore);
  19641.             }
  19642.             else{
  19643.                 if(!first){
  19644.                     policy.getFiltro().setRuoloErogatore(null);
  19645.                 }
  19646.             }
  19647.            
  19648.             // erogatore
  19649.             String erogatore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_EROGATORE);
  19650.             boolean erogatoreSelected = false;
  19651.             if(erogatore!=null && !"".equals(erogatore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(erogatore) && erogatore.contains("/") ){
  19652.                 String [] tmp = erogatore.split("/");
  19653.                 policy.getFiltro().setTipoErogatore(tmp[0]);
  19654.                 policy.getFiltro().setNomeErogatore(tmp[1]);
  19655.                 erogatoreSelected = true;
  19656.             }
  19657.             else{
  19658.                 if(!first){
  19659.                     policy.getFiltro().setTipoErogatore(null);
  19660.                     policy.getFiltro().setNomeErogatore(null);
  19661.                 }
  19662.             }
  19663.            
  19664.             // servizio applicativo erogatore
  19665. //          String servizioApplicativoErogatore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_EROGATORE);
  19666. //          if(servizioApplicativoErogatore!=null && !"".equals(servizioApplicativoErogatore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(servizioApplicativoErogatore) ){
  19667. //              policy.getFiltro().setServizioApplicativoErogatore(servizioApplicativoErogatore);
  19668. //          }
  19669. //          else{
  19670. //              if(!first){
  19671. //                  policy.getFiltro().setServizioApplicativoErogatore(null);
  19672. //              }
  19673. //          }
  19674.            
  19675.             // tag
  19676.             String tag = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_TAG);
  19677.             if(tag!=null && !"".equals(tag) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(tag)){
  19678.                 policy.getFiltro().setTag(tag);
  19679.             }
  19680.             else{
  19681.                 if(!first){
  19682.                     policy.getFiltro().setTag(null);
  19683.                 }
  19684.             }
  19685.            
  19686.             // servizio
  19687.             String servizio = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SERVIZIO);
  19688.             if(servizio!=null && !"".equals(servizio) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(servizio) && servizio.contains("/") ){
  19689.                 String [] tmp = servizio.split("/");
  19690.                 policy.getFiltro().setTipoServizio(tmp[0]);
  19691.                 policy.getFiltro().setNomeServizio(tmp[1]);
  19692.                 policy.getFiltro().setVersioneServizio(Integer.parseInt(tmp[2]));
  19693.                 if(this.core.isControlloTrafficoPolicyGlobaleFiltroApiSoggettoErogatore()) {
  19694.                     policy.getFiltro().setTipoErogatore(tmp[3]);
  19695.                     policy.getFiltro().setNomeErogatore(tmp[4]);
  19696.                 }
  19697.             }
  19698.             else{
  19699.                 if(!first){
  19700.                     policy.getFiltro().setTipoServizio(null);
  19701.                     policy.getFiltro().setNomeServizio(null);
  19702.                     policy.getFiltro().setVersioneServizio(null);
  19703.                     if(this.core.isControlloTrafficoPolicyGlobaleFiltroApiSoggettoErogatore()&& !erogatoreSelected) {
  19704.                         policy.getFiltro().setTipoErogatore(null);
  19705.                         policy.getFiltro().setNomeErogatore(null);
  19706.                     }
  19707.                 }
  19708.             }
  19709.            
  19710.             // azione
  19711.             String [] azione = this.getParameterValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE);
  19712.             if(azione!=null && azione.length>0) {
  19713.                 StringBuilder bf = new StringBuilder();
  19714.                 for (String az : azione) {
  19715.                     if(bf.length()>0) {
  19716.                         bf.append(",");
  19717.                     }
  19718.                     bf.append(az);
  19719.                 }
  19720.                 policy.getFiltro().setAzione(bf.toString());
  19721.             }
  19722.             else{
  19723.                 if(!first){
  19724.                     policy.getFiltro().setAzione(null);
  19725.                 }
  19726.             }
  19727.            
  19728.             // ruolo fruitore
  19729.             String ruoloFruitore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_FRUITORE);
  19730.             if(ruoloFruitore!=null && !"".equals(ruoloFruitore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(ruoloFruitore) ){
  19731.                 policy.getFiltro().setRuoloFruitore(ruoloFruitore);
  19732.             }
  19733.             else{
  19734.                 if(!first){
  19735.                     policy.getFiltro().setRuoloFruitore(null);
  19736.                 }
  19737.             }
  19738.            
  19739.             // fruitore
  19740.             String fruitore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_FRUITORE);
  19741.             if(fruitore!=null && !"".equals(fruitore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(fruitore) && fruitore.contains("/") ){
  19742.                 String [] tmp = fruitore.split("/");
  19743.                 policy.getFiltro().setTipoFruitore(tmp[0]);
  19744.                 policy.getFiltro().setNomeFruitore(tmp[1]);
  19745.             }
  19746.             else{
  19747.                 if(!first){
  19748.                     policy.getFiltro().setTipoFruitore(null);
  19749.                     policy.getFiltro().setNomeFruitore(null);
  19750.                 }
  19751.             }
  19752.            
  19753.             // servizio applicativo fruitore
  19754.             String servizioApplicativoFruitore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_FRUITORE);
  19755.             if(servizioApplicativoFruitore!=null && !"".equals(servizioApplicativoFruitore) && !ConfigurazioneCostanti.VALUE_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI.equals(servizioApplicativoFruitore) ){
  19756.                 policy.getFiltro().setServizioApplicativoFruitore(servizioApplicativoFruitore);
  19757.             }
  19758.             else{
  19759.                 if(!first){
  19760.                     policy.getFiltro().setServizioApplicativoFruitore(null);
  19761.                 }
  19762.             }
  19763.            
  19764.             // per Chiave
  19765. //          String perChiave = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PER_CHIAVE_ENABLED);
  19766. //          if(first==false){
  19767. //              policy.getFiltro().setInformazioneApplicativaEnabled(ServletUtils.isCheckBoxEnabled(perChiave));
  19768. //          }
  19769.            
  19770. //          if(policy.getFiltro().isInformazioneApplicativaEnabled()){
  19771. //              
  19772. //              // Per Chiave - Tipo
  19773. //              String perChiaveTipo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PER_CHIAVE_TIPO);
  19774. //              if(perChiaveTipo!=null && !"".equals(perChiaveTipo) ){
  19775. //                  policy.getFiltro().setInformazioneApplicativaTipo(perChiaveTipo);
  19776. //              }
  19777. //              else{
  19778. //                  if(!first){
  19779. //                      policy.getFiltro().setInformazioneApplicativaTipo(ConfigurazioneCostanti.ALLARMI_FILTRO_PER_CHIAVE_TIPO_DEFAULT); // default
  19780. //                  }
  19781. //              }
  19782. //              
  19783. //              // Per Chiave - Nome
  19784. //              String perChiaveNome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PER_CHIAVE_NOME);
  19785. //              if(perChiaveNome!=null && !"".equals(perChiaveNome) ){
  19786. //                  policy.getFiltro().setInformazioneApplicativaNome(perChiaveNome);
  19787. //              }
  19788. //              else{
  19789. //                  if(!first){
  19790. //                      policy.getFiltro().setInformazioneApplicativaNome(null);
  19791. //                  }
  19792. //              }
  19793. //              
  19794. //              // Per Chiave - Valore
  19795. //              String perChiaveValore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PER_CHIAVE_VALORE);
  19796. //              if(perChiaveValore!=null && !"".equals(perChiaveValore) ){
  19797. //                  policy.getFiltro().setInformazioneApplicativaValore(StringEscapeUtils.unescapeHtml(perChiaveValore)); // il valore viene "escaped" perchè può conteenere ""
  19798. //              }
  19799. //              else{
  19800. //                  if(!first){
  19801. //                      policy.getFiltro().setInformazioneApplicativaValore(null);
  19802. //                  }
  19803. //              }
  19804. //              
  19805. //          }
  19806. //          else{
  19807. //              policy.getFiltro().setInformazioneApplicativaTipo(null);
  19808. //              policy.getFiltro().setInformazioneApplicativaNome(null);
  19809. //              policy.getFiltro().setInformazioneApplicativaValore(null);
  19810. //          }
  19811.         }
  19812.         else{
  19813.             policy.getFiltro().setRuoloPorta(RuoloPorta.ENTRAMBI);
  19814.             policy.getFiltro().setTipoFruitore(null);
  19815.             policy.getFiltro().setNomeFruitore(null);
  19816.             policy.getFiltro().setServizioApplicativoFruitore(null);
  19817.             policy.getFiltro().setTipoErogatore(null);
  19818.             policy.getFiltro().setNomeErogatore(null);
  19819. //          policy.getFiltro().setServizioApplicativoErogatore(null);
  19820.             policy.getFiltro().setTipoServizio(null);
  19821.             policy.getFiltro().setNomeServizio(null);
  19822.             policy.getFiltro().setAzione(null);
  19823. //          policy.getFiltro().setInformazioneApplicativaEnabled(false);
  19824. //          policy.getFiltro().setInformazioneApplicativaTipo(null);
  19825. //          policy.getFiltro().setInformazioneApplicativaNome(null);
  19826. //          policy.getFiltro().setInformazioneApplicativaValore(null);
  19827.         }
  19828.        
  19829.         // GroupBy - stato
  19830.         String statoGroupBy = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_ENABLED);
  19831.         if(statoGroupBy!=null && !"".equals(statoGroupBy)){
  19832.             policy.getGroupBy().setEnabled(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_COLLEZIONAMENTO_ABILITATO.equals(statoGroupBy) ||
  19833.                     ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(statoGroupBy));
  19834.         }
  19835.        
  19836.         // GroupBy
  19837.         if(policy.getGroupBy().isEnabled()){
  19838.            
  19839.             // ruolo della PdD
  19840.             String ruoloPdD = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_RUOLO_PDD);
  19841.             if(first==false){
  19842.                 policy.getGroupBy().setRuoloPorta(ServletUtils.isCheckBoxEnabled(ruoloPdD));
  19843.             }
  19844.            
  19845.             // protocollo
  19846.             String protocollo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PROTOCOLLO);
  19847.             if(first==false){
  19848.                 policy.getGroupBy().setProtocollo(ServletUtils.isCheckBoxEnabled(protocollo));
  19849.             }
  19850.            
  19851.             // erogatore
  19852.             String erogatore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_EROGATORE);
  19853.             if(first==false){
  19854.                 policy.getGroupBy().setErogatore(ServletUtils.isCheckBoxEnabled(erogatore));
  19855.             }
  19856.            
  19857.             // servizio applicativo erogatore
  19858. //          String servizioApplicativoErogatore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_SA_EROGATORE);
  19859. //          if(first==false){
  19860. //              policy.getGroupBy().setServizioApplicativoErogatore(ServletUtils.isCheckBoxEnabled(servizioApplicativoErogatore));
  19861. //          }
  19862.            
  19863.             // servizio
  19864.             String servizio = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_SERVIZIO);
  19865.             if(first==false){
  19866.                 policy.getGroupBy().setServizio(ServletUtils.isCheckBoxEnabled(servizio));
  19867.                 policy.getGroupBy().setErogatore(ServletUtils.isCheckBoxEnabled(servizio)); // imposto anche l'erogatore poiche' identifica API differenti
  19868.             }
  19869.            
  19870.             // azione
  19871.             String azione = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_AZIONE);
  19872.             if(first==false){
  19873.                 policy.getGroupBy().setAzione(ServletUtils.isCheckBoxEnabled(azione));
  19874.             }
  19875.            
  19876.             // fruitore
  19877.             String fruitore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_FRUITORE);
  19878.             if(first==false){
  19879.                 policy.getGroupBy().setFruitore(ServletUtils.isCheckBoxEnabled(fruitore));
  19880.             }
  19881.            
  19882.             // servizio applicativo fruitore
  19883.             String servizioApplicativoFruitore = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_SA_FRUITORE);
  19884.             if(first==false){
  19885.                 policy.getGroupBy().setServizioApplicativoFruitore(ServletUtils.isCheckBoxEnabled(servizioApplicativoFruitore));
  19886.             }
  19887.            
  19888.             // richiedente
  19889.             String richiedente = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_RICHIEDENTE);
  19890.             if(first==false){
  19891.                 policy.getGroupBy().setServizioApplicativoFruitore(ServletUtils.isCheckBoxEnabled(richiedente));
  19892.                 policy.getGroupBy().setFruitore(ServletUtils.isCheckBoxEnabled(richiedente));
  19893.                 policy.getGroupBy().setIdentificativoAutenticato(ServletUtils.isCheckBoxEnabled(richiedente));
  19894.             }
  19895.            
  19896.             // token
  19897.             String token = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_TOKEN);
  19898.             if(first==false){
  19899.                 if(ServletUtils.isCheckBoxEnabled(token)) {
  19900.                     String [] tokenSelezionati = this.getParameterValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_TOKEN_CLAIMS);
  19901.                     if(tokenSelezionati!=null && tokenSelezionati.length>0) {
  19902.                         StringBuilder bf = new StringBuilder();
  19903.                         for (int i = 0; i < tokenSelezionati.length; i++) {
  19904.                             TipoCredenzialeMittente tipo = TipoCredenzialeMittente.toEnumConstant(tokenSelezionati[i],true);
  19905.                             if(TipoCredenzialeMittente.TOKEN_ISSUER.equals(tipo)) {
  19906.                                 continue;
  19907.                             }
  19908.                             else if(TipoCredenzialeMittente.TOKEN_SUBJECT.equals(tipo)) {
  19909.                                 if(!bf.toString().endsWith(",") && bf.length()>0) {
  19910.                                     bf.append(",");
  19911.                                 }
  19912.                                 bf.append(TipoCredenzialeMittente.TOKEN_ISSUER.name());
  19913.                                 if(i==0) {
  19914.                                     bf.append(",");
  19915.                                 }
  19916.                             }
  19917.                             if(i>0) {
  19918.                                 bf.append(",");
  19919.                             }
  19920.                             bf.append(tokenSelezionati[i]);
  19921.                         }
  19922.                         if(bf.length()>0) {
  19923.                             policy.getGroupBy().setToken(bf.toString());
  19924.                         }
  19925.                         else {
  19926.                             policy.getGroupBy().setToken(null);
  19927.                         }
  19928.                     }
  19929.                     else {
  19930.                         policy.getGroupBy().setToken(null);
  19931.                     }
  19932.                 }
  19933.                 else {
  19934.                     policy.getGroupBy().setToken(null);
  19935.                 }
  19936.             }

  19937.             // per Chiave
  19938. //          String perChiave = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_ENABLED);
  19939. //          if(first==false){
  19940. //              policy.getGroupBy().setInformazioneApplicativaEnabled(ServletUtils.isCheckBoxEnabled(perChiave));
  19941. //          }
  19942. //          
  19943. //          if(policy.getGroupBy().isInformazioneApplicativaEnabled()){
  19944. //              
  19945. //              // Per Chiave - Tipo
  19946. //              String perChiaveTipo = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_TIPO);
  19947. //              if(perChiaveTipo!=null && !"".equals(perChiaveTipo) ){
  19948. //                  policy.getGroupBy().setInformazioneApplicativaTipo(perChiaveTipo);
  19949. //              }
  19950. //              else{
  19951. //                  if(!first){
  19952. //                      policy.getGroupBy().setInformazioneApplicativaTipo(ConfigurazioneCostanti.ALLARMI_GROUPBY_PER_CHIAVE_TIPO_DEFAULT); // default
  19953. //                  }
  19954. //              }
  19955. //              
  19956. //              // Per Chiave - Nome
  19957. //              String perChiaveNome = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_NOME);
  19958. //              if(perChiaveNome!=null && !"".equals(perChiaveNome) ){
  19959. //                  policy.getGroupBy().setInformazioneApplicativaNome(perChiaveNome);
  19960. //              }
  19961. //              else{
  19962. //                  if(!first){
  19963. //                      policy.getGroupBy().setInformazioneApplicativaNome(null);
  19964. //                  }
  19965. //              }
  19966. //              
  19967. //              
  19968. //          }
  19969. //          else{
  19970. //              policy.getGroupBy().setInformazioneApplicativaTipo(null);
  19971. //              policy.getGroupBy().setInformazioneApplicativaNome(null);
  19972. //          }
  19973.         }
  19974.         else{
  19975.             policy.getGroupBy().setRuoloPorta(false);
  19976.             policy.getGroupBy().setFruitore(false);
  19977.             policy.getGroupBy().setServizioApplicativoFruitore(false);
  19978.             policy.getGroupBy().setIdentificativoAutenticato(false);
  19979.             policy.getGroupBy().setToken(null);
  19980.             policy.getGroupBy().setErogatore(false);
  19981. //          policy.getGroupBy().setServizioApplicativoErogatore(false);
  19982.             policy.getGroupBy().setServizio(false);
  19983.             policy.getGroupBy().setAzione(false);
  19984. //          policy.getGroupBy().setInformazioneApplicativaEnabled(false);
  19985. //          policy.getGroupBy().setInformazioneApplicativaTipo(null);
  19986. //          policy.getGroupBy().setInformazioneApplicativaNome(null);
  19987.         }
  19988.        
  19989.        
  19990.         if(sbParsingError.length() > 0){
  19991.             return sbParsingError.toString();
  19992.         }
  19993.         return null;
  19994.     }
  19995.    
  19996.     public void addAllarmeToDati(List<DataElement> dati, TipoOperazione tipoOperazione, ConfigurazioneAllarmeBean allarme, AlarmEngineConfig alarmEngineConfig, List<Plugin> listaPlugin,
  19997.             List<org.openspcoop2.monitor.sdk.parameters.Parameter<?>> parameters, RuoloPorta ruoloPorta, String nomePorta, ServiceBinding serviceBinding
  19998.             ) throws Exception {
  19999.        
  20000.         String stateParam = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_STATE);
  20001.         boolean state = stateParam!=null && "true".equals(stateParam);
  20002.        
  20003.         if(TipoOperazione.CHANGE.equals(tipoOperazione)){
  20004.            
  20005.             // Runtime
  20006.             if(!state) {
  20007.                 boolean isActive = allarme.getEnabled() == 1 && TipoAllarme.ATTIVO.equals(allarme.getTipoAllarme());
  20008.                 if(isActive){
  20009.                     List<Parameter> lstParamSession = new ArrayList<>();
  20010.    
  20011.                     Parameter parRuoloPorta = null;
  20012.                     if(ruoloPorta!=null) {
  20013.                         parRuoloPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA, ruoloPorta.getValue());
  20014.                         lstParamSession.add(parRuoloPorta);
  20015.                     }
  20016.                     Parameter parNomePorta = null;
  20017.                     if(nomePorta!=null) {
  20018.                         parNomePorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA, nomePorta);
  20019.                         lstParamSession.add(parNomePorta);
  20020.                     }
  20021.                     Parameter parServiceBinding = null;
  20022.                     if(serviceBinding!=null) {
  20023.                         parServiceBinding = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING, serviceBinding.name());
  20024.                         lstParamSession.add(parServiceBinding);
  20025.                     }
  20026.                    
  20027.                     Parameter pState = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_STATE, true+"");
  20028.                    
  20029.                     Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ID_ALLARME, allarme.getId() + "");
  20030.                     List<Parameter> lstParamEntry = new ArrayList<>();
  20031.                     lstParamEntry.add(pId);
  20032.                     if(lstParamSession.size() > 0) {
  20033.                         lstParamEntry.addAll(lstParamSession);
  20034.                     }
  20035.                    
  20036.                     List<Parameter> lstParamEntryState = new ArrayList<>();
  20037.                     lstParamEntryState.addAll(lstParamEntry);
  20038.                     lstParamEntryState.add(pState);
  20039.                    
  20040.                     this.pd.addComandoVisualizzaRuntimeElementoButton(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntryState);
  20041.                    
  20042.                 }
  20043.             }
  20044.            
  20045.         }
  20046.        
  20047.         boolean allarmeAttivo = allarme.getTipoAllarme() != null && (allarme.getTipoAllarme().equals(TipoAllarme.ATTIVO));
  20048.        
  20049.         boolean first = this.isFirstTimeFromHttpParameters(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FIRST_TIME);
  20050.         DataElement de;
  20051.        
  20052.         Parameter pIdAllarme = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ID_ALLARME, allarme.getId()+"");
  20053.         // id
  20054.         de = new DataElement();
  20055.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ID_ALLARME);
  20056.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ID_ALLARME);
  20057.         de.setType(DataElementType.HIDDEN);
  20058.         if(tipoOperazione.equals(TipoOperazione.ADD)) {
  20059.             de.setValue("");
  20060.         } else {
  20061.             de.setValue(allarme.getId()+"");
  20062.         }
  20063.         dati.add(de);
  20064.        
  20065.         de = new DataElement();
  20066.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA);
  20067.         de.setValue(ruoloPorta!=null ? ruoloPorta.getValue() : null);
  20068.         de.setType(DataElementType.HIDDEN);
  20069.         dati.add(de);
  20070.        
  20071.         de = new DataElement();
  20072.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA);
  20073.         de.setValue(nomePorta);
  20074.         de.setType(DataElementType.HIDDEN);
  20075.         dati.add(de);
  20076.        
  20077.         if(serviceBinding!=null) {
  20078.             de = new DataElement();
  20079.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING);
  20080.             de.setValue(serviceBinding.name());
  20081.             de.setType(DataElementType.HIDDEN);
  20082.             dati.add(de);
  20083.         }
  20084.                
  20085.         if(state) {
  20086.            
  20087.             String refreshParam = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_OP_REFRESH);
  20088.             boolean refresh = refreshParam!=null && "true".equals(refreshParam);
  20089.            
  20090.             String stopParam = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_OP_STOP);
  20091.             boolean stop = stopParam!=null && "true".equals(stopParam);
  20092.            
  20093.             String startParam = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_OP_START);
  20094.             boolean start = startParam!=null && "true".equals(startParam);
  20095.            
  20096.             String restartParam = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_OP_RESTART);
  20097.             boolean restart = restartParam!=null && "true".equals(restartParam);
  20098.            
  20099.             if(refresh || stop || start || restart) {
  20100.                 try {
  20101.                     String label = "";
  20102.                     if(refresh) {
  20103.                         AllarmiUtils.refreshActiveThreadState(allarme, this.log, alarmEngineConfig);
  20104.                         label = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_AGGIORNA_STATO_REFRESH;
  20105.                     }
  20106.                     else if(stop) {
  20107.                         AllarmiUtils.stopActiveThread(allarme, this.log, alarmEngineConfig);
  20108.                         label = "Stop allarme";
  20109.                     }
  20110.                     else if(start) {
  20111.                         AllarmiUtils.startActiveThread(allarme, this.log, alarmEngineConfig);
  20112.                         label = "Start allarme";
  20113.                     }
  20114.                     else if(restart) {
  20115.                         AllarmiUtils.restartActiveThread(allarme, this.log, alarmEngineConfig);
  20116.                         label = "Restart allarme";
  20117.                     }
  20118.                    
  20119.                     // Dormo qualche secondo per dare il tempo di fare il recheck o stop/start dell'allarme
  20120.                     Utilities.sleep(3000);
  20121.                    
  20122.                     if(refresh) {
  20123.                         this.pd.setMessage(label+" avviato con successo", MessageType.INFO);
  20124.                     }
  20125.                     else {
  20126.                         this.pd.setMessage(label+" effettuato con successo", MessageType.INFO);
  20127.                     }
  20128.                    
  20129.                 } catch(Exception e) {
  20130.                     String errorMsg = "Richiesta di aggiornamento dello stato dell'allarme '"+allarme.getAlias()+"' fallita: "+e.getMessage();
  20131.                     ControlStationCore.getLog().error(errorMsg, e);
  20132.                     this.pd.setMessage(errorMsg, MessageType.ERROR);
  20133.                 }
  20134.             }
  20135.            
  20136.            
  20137.            
  20138.             List<Parameter> lstParamEntry = new ArrayList<>();
  20139.             if(ruoloPorta!=null) {
  20140.                 Parameter parRuoloPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA, ruoloPorta.getValue());
  20141.                 lstParamEntry.add(parRuoloPorta);
  20142.             }
  20143.             if(nomePorta!=null) {
  20144.                 Parameter parNomePorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA, nomePorta);
  20145.                 lstParamEntry.add(parNomePorta);
  20146.             }
  20147.             if(serviceBinding!=null) {
  20148.                 Parameter parServiceBinding = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING, serviceBinding.name());
  20149.                 lstParamEntry.add(parServiceBinding);
  20150.             }
  20151.             Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ID_ALLARME, allarme.getId() + "");
  20152.             lstParamEntry.add(pId);
  20153.             Parameter pState = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_STATE, true+"");
  20154.             lstParamEntry.add(pState);
  20155.            
  20156.             boolean existsActiveThread = false;
  20157.             try {
  20158.                 existsActiveThread = AllarmiUtils.existsActiveThread(allarme, this.log, alarmEngineConfig);
  20159.             } catch(Exception e) {
  20160.                 String errorMsg = "Lettura stato del thread dell'allarme '"+allarme.getAlias()+"' fallita: "+e.getMessage();
  20161.                 ControlStationCore.getLog().error(errorMsg, e);
  20162.             }
  20163.            
  20164.            
  20165.            
  20166.             de = new DataElement();
  20167.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_INFORMAZIONI_RUNTIME);
  20168.             de.setType(DataElementType.TITLE);
  20169.             dati.add(de);
  20170.            
  20171.             // Link refresh
  20172.            
  20173.             de = new DataElement();
  20174.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_VISUALIZZA_STATO);
  20175.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_VISUALIZZA_STATO_REFRESH);
  20176.             de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_VISUALIZZA_STATO_REFRESH);
  20177.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntry.toArray(new Parameter[lstParamEntry.size()]));
  20178.             de.setType(DataElementType.LINK);
  20179.             dati.add(de);
  20180.            
  20181.             de = new DataElement();
  20182.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_STATE);
  20183.             de.setLabelAffiancata(false);
  20184.             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  20185.             de.setRows(20);
  20186.             de.setCols(100);
  20187.             String result = null;
  20188.             try {
  20189.                 if(existsActiveThread) {
  20190.                     result = AllarmiUtils.getActiveThreadImage(allarme, this.log, alarmEngineConfig);
  20191.                 }
  20192.                 else {
  20193.                     result = "Il thread di gestione dell'allarme non è attivo";
  20194.                 }
  20195.             } catch(Exception e) {
  20196.                 String errorMsg = "Lettura stato dell'allarme '"+allarme.getAlias()+"' fallita: "+e.getMessage();
  20197.                 ControlStationCore.getLog().error(errorMsg, e);
  20198.                 result = errorMsg;
  20199.             }
  20200.             de.setValue(result);
  20201.             dati.add(de);
  20202.            
  20203.            
  20204.             de = new DataElement();
  20205.             de.setType(DataElementType.SUBTITLE);
  20206.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GESTIONE_THREAD);
  20207.             dati.add(de);
  20208.            
  20209.             // Link ricalcola stato
  20210.            
  20211.             if(existsActiveThread) {
  20212.                 de = new DataElement();
  20213.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_AGGIORNA_STATO);
  20214.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_AGGIORNA_STATO_REFRESH);
  20215.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_AGGIORNA_STATO_REFRESH);
  20216.                 List<Parameter> lstParamEntryRecheck = new ArrayList<>();
  20217.                 lstParamEntryRecheck.addAll(lstParamEntry);
  20218.                 Parameter pRecheck = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_OP_REFRESH, true+"");
  20219.                 lstParamEntryRecheck.add(pRecheck);
  20220.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntryRecheck.toArray(new Parameter[lstParamEntryRecheck.size()]));
  20221.                 de.setType(DataElementType.LINK);
  20222.                 dati.add(de);
  20223.             }
  20224.            
  20225.             // Link restart
  20226.            
  20227.             if(existsActiveThread) {
  20228.                 de = new DataElement();
  20229.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RESTART_ALLARME);
  20230.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_RESTART_ALLARME);
  20231.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_RESTART_ALLARME);
  20232.                 List<Parameter> lstParamEntryRestart = new ArrayList<>();
  20233.                 lstParamEntryRestart.addAll(lstParamEntry);
  20234.                 Parameter pRestart = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_OP_RESTART, true+"");
  20235.                 lstParamEntryRestart.add(pRestart);
  20236.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntryRestart.toArray(new Parameter[lstParamEntryRestart.size()]));
  20237.                 de.setType(DataElementType.LINK);
  20238.                 dati.add(de);
  20239.             }
  20240.            
  20241.             // Link stop
  20242.            
  20243.             if(existsActiveThread) {
  20244.                 de = new DataElement();
  20245.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_STOP_ALLARME);
  20246.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_STOP_ALLARME);
  20247.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_STOP_ALLARME);
  20248.                 List<Parameter> lstParamEntryStop = new ArrayList<>();
  20249.                 lstParamEntryStop.addAll(lstParamEntry);
  20250.                 Parameter pStop = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_OP_STOP, true+"");
  20251.                 lstParamEntryStop.add(pStop);
  20252.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntryStop.toArray(new Parameter[lstParamEntryStop.size()]));
  20253.                 de.setType(DataElementType.LINK);
  20254.                 dati.add(de);
  20255.             }
  20256.            
  20257.             // Link start
  20258.            
  20259.             if(!existsActiveThread) {
  20260.                 de = new DataElement();
  20261.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_START_ALLARME);
  20262.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_START_ALLARME);
  20263.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_START_ALLARME);
  20264.                 List<Parameter> lstParamEntryStart = new ArrayList<>();
  20265.                 lstParamEntryStart.addAll(lstParamEntry);
  20266.                 Parameter pStart = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_OP_START, true+"");
  20267.                 lstParamEntryStart.add(pStart);
  20268.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntryStart.toArray(new Parameter[lstParamEntryStart.size()]));
  20269.                 de.setType(DataElementType.LINK);
  20270.                 dati.add(de);
  20271.             }
  20272.            

  20273.                
  20274.             this.pd.disableEditMode();

  20275.            
  20276.             return;
  20277.         }
  20278.        
  20279.         // Informazioni Generali
  20280.         de = new DataElement();
  20281.         de.setType(DataElementType.TITLE);
  20282.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_INFORMAZIONI_GENERALI);
  20283.         dati.add(de);
  20284.        
  20285.         // plugin select
  20286.         de = new DataElement();
  20287.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_PLUGIN);
  20288.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_PLUGIN);
  20289.         if(tipoOperazione.equals(TipoOperazione.ADD)){
  20290.             de.setType(DataElementType.SELECT);
  20291.             List<String> pluginValues = new ArrayList<>();
  20292.             List<String> pluginLabels = new ArrayList<>();
  20293.            
  20294.             for (Plugin pluginBean : listaPlugin) {
  20295.                 String key = pluginBean.getLabel() + ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_PLUGIN_NOME_SEP + pluginBean.getClassName();
  20296.                
  20297.                 pluginValues.add(key);
  20298.                 pluginLabels.add(pluginBean.getLabel());
  20299.             }
  20300.            
  20301.             pluginValues.add(0, ConfigurazioneCostanti.DEFAULT_VALUE_NESSUNO);
  20302.             pluginLabels.add(0, ConfigurazioneCostanti.LABEL_DEFAULT_VALUE_NESSUNO);
  20303.            
  20304.             de.setValues(pluginValues);
  20305.             de.setLabels(pluginLabels);
  20306.             if(first) {
  20307.                 de.setSelected(ConfigurazioneCostanti.DEFAULT_VALUE_NESSUNO);
  20308.             } else {
  20309.                 if(allarme.getPlugin() != null)
  20310.                     de.setSelected(allarme.getPlugin().getLabel() + ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_PLUGIN_NOME_SEP + allarme.getPlugin().getClassName());  
  20311.             }
  20312.            
  20313.             de.setPostBack_viaPOST(true);
  20314.             de.setRequired(true);
  20315.         }
  20316.         else{
  20317.             de.setType(DataElementType.TEXT);
  20318.             de.setValue(allarme.getPlugin().getLabel());    
  20319.         }
  20320.         dati.add(de);
  20321.                        
  20322.         // tipo
  20323.         de = new DataElement();
  20324.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA);
  20325.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO);
  20326.         de.setValue(allarme.getTipo() != null ? allarme.getTipo() : "");
  20327.         de.setType(DataElementType.HIDDEN);
  20328.         dati.add(de);
  20329.                
  20330.         // nome
  20331.         de = new DataElement();
  20332.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME);
  20333.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME);
  20334.         if(tipoOperazione.equals(TipoOperazione.ADD)){
  20335.             if(first || allarme.getPlugin() == null) {
  20336.                 de.setType(DataElementType.HIDDEN);
  20337.                 de.setValue("");
  20338.             } else {
  20339.                 de.setType(DataElementType.HIDDEN);
  20340.                 de.setValue(allarme.getNome());
  20341.             }
  20342.             de.setRequired(true);
  20343.         }
  20344.         else{
  20345.             if(!this.isModalitaStandard() && this.confCore.isShowAllarmiIdentificativoRuntime()) {
  20346.                 de.setType(DataElementType.TEXT);
  20347.             }
  20348.             else {
  20349.                 de.setType(DataElementType.HIDDEN);
  20350.             }
  20351.             de.setValue(allarme.getNome());
  20352.         }
  20353.         dati.add(de);
  20354.        
  20355.         // alias
  20356.         de = new DataElement();
  20357.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ALIAS);
  20358.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ALIAS);
  20359.         if(tipoOperazione.equals(TipoOperazione.ADD)){
  20360.             if(first || allarme.getPlugin() == null) {
  20361.                 de.setType(DataElementType.HIDDEN);
  20362.                 de.setValue("");
  20363.             } else {
  20364.                 de.setType(DataElementType.TEXT_EDIT);
  20365.                 de.setValue(allarme.getAlias());
  20366.             }
  20367.             de.setRequired(true);
  20368.         }
  20369.         else{
  20370.             de.setType(DataElementType.TEXT_EDIT);
  20371.             de.setValue(allarme.getAlias());
  20372.         }
  20373.         dati.add(de);
  20374.                
  20375.         // abilitato
  20376.         de = new DataElement();
  20377.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO);
  20378.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO);
  20379.        
  20380.         de.setType(DataElementType.SELECT);
  20381.         String [] abilitatoValues = ConfigurazioneCostanti.VALUES_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO;
  20382.         String [] abilitatoLabels = ConfigurazioneCostanti.LABELS_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO;
  20383.        
  20384.         de.setValues(abilitatoValues);
  20385.         de.setLabels(abilitatoLabels);
  20386.        
  20387.         if(tipoOperazione.equals(TipoOperazione.ADD)){
  20388.             if(first || allarme.getPlugin() == null) {
  20389.                 de.setType(DataElementType.HIDDEN);
  20390.                 de.setValue(ConfigurazioneCostanti.VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO_SI);
  20391.             } else {
  20392.                 de.setSelected(allarme.getEnabled()+"");
  20393.             }
  20394.         }else{
  20395.             de.setSelected(allarme.getEnabled()+"");
  20396.         }
  20397.         dati.add(de);
  20398.        
  20399.         // descrizione
  20400.         de = new DataElement();
  20401.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_DESCRIZIONE);
  20402.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_DESCRIZIONE);
  20403.         if(tipoOperazione.equals(TipoOperazione.ADD)){
  20404.             if(first || allarme.getPlugin() == null) {
  20405.                 de.setType(DataElementType.HIDDEN);
  20406.             }
  20407.             else {
  20408.                 de.setType(DataElementType.TEXT_AREA);
  20409.                 de.setRows(2);
  20410.             }
  20411.         }
  20412.         else {
  20413.             de.setType(DataElementType.TEXT_AREA);
  20414.             de.setRows(2);
  20415.         }
  20416.         de.setValue(allarme.getDescrizione());
  20417.         dati.add(de);
  20418.        
  20419.         // frequenza
  20420.         if(allarmeAttivo) {
  20421.             de = new DataElement();
  20422.             de.setType(DataElementType.SUBTITLE);
  20423.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_INFORMAZIONI_GENERALI_FREQUENZA);
  20424.             dati.add(de);
  20425.         }
  20426.        
  20427.         // modalita
  20428.         de = new DataElement();
  20429.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA);
  20430.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA);
  20431.         de.setValue(allarme.getTipoAllarme() != null ? allarme.getTipoAllarme().getValue() : "");
  20432.         de.setType(DataElementType.HIDDEN);
  20433.         dati.add(de);
  20434.        
  20435.         de = new DataElement();
  20436.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA);
  20437.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA_LABEL);
  20438.         if(allarme.getTipoAllarme() != null &&
  20439.                 (allarme.getTipoAllarme().equals(TipoAllarme.ATTIVO) || allarme.getTipoAllarme().equals(TipoAllarme.PASSIVO))) {
  20440.             de.setType(DataElementType.TEXT);
  20441.             de.setValue(allarme.getTipoAllarme().equals(TipoAllarme.ATTIVO) ? ConfigurazioneCostanti.VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA_ATTIVA : ConfigurazioneCostanti.VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_MODALITA_PASSIVA );
  20442.         } else {
  20443.             de.setType(DataElementType.HIDDEN);
  20444.             de.setValue("");
  20445.         }
  20446.         dati.add(de);
  20447.        
  20448.         // frequenza
  20449.         if(allarmeAttivo) {
  20450.            
  20451.             // number periodo
  20452.             de = new DataElement();
  20453.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_PERIODO);
  20454.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_PERIODO);
  20455.             de.setType(DataElementType.NUMBER);
  20456.             de.setRequired(true);
  20457.             if(tipoOperazione.equals(TipoOperazione.ADD)){
  20458.                 if(first) {
  20459.                     de.setValue("");
  20460.                 } else {
  20461.                     de.setValue(allarme.getPeriodo()+"");
  20462.                 }
  20463.             }else{
  20464.                 de.setValue(allarme.getPeriodo()+"");
  20465.             }
  20466.             dati.add(de);
  20467.            
  20468.             // select tipo periodo
  20469.             de = new DataElement();
  20470.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO_PERIODO);
  20471.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO_PERIODO);
  20472.             de.setType(DataElementType.SELECT);
  20473.             String [] tipoPeriodoValues = ConfigurazioneCostanti.VALUES_PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO_PERIODO;
  20474.             String [] tipoPeriodoLabels = ConfigurazioneCostanti.LABELS_PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO_PERIODO;
  20475.            
  20476.             de.setRequired(true);
  20477.             de.setValues(tipoPeriodoValues);
  20478.             de.setLabels(tipoPeriodoLabels);
  20479.             if(tipoOperazione.equals(TipoOperazione.ADD)){
  20480.                 if(first || allarme.getTipoPeriodo()==null || StringUtils.isEmpty(allarme.getTipoPeriodo())) {
  20481.                     de.setSelected(ConfigurazioneCostanti.VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_TIPO_PERIODO_ORE);
  20482.                 } else {
  20483.                     de.setSelected(allarme.getTipoPeriodo());
  20484.                 }
  20485.             }else{
  20486.                 de.setSelected(allarme.getTipoPeriodo());
  20487.             }
  20488.             dati.add(de);
  20489.            
  20490.         }
  20491.        
  20492.         // field da visualizzare in modifica
  20493.         if(tipoOperazione.equals(TipoOperazione.CHANGE) && this.confCore.isShowAllarmiFormStatoAllarme()) {
  20494.            
  20495.             de = new DataElement();
  20496.             de.setType(DataElementType.SUBTITLE);
  20497.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_STATO_ALLARME);
  20498.             dati.add(de);      
  20499.            
  20500.             // stato
  20501.             de = new DataElement();
  20502.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_STATO);
  20503.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_STATO);
  20504.             de.setType(DataElementType.TEXT);
  20505.             if(allarme.getEnabled() == 1) { // allarme abilitato
  20506.                 de.setValue(ConfigurazioneCostanti.getLabelStato(AllarmiConverterUtils.toStatoAllarme(allarme.getStato())));
  20507.             }
  20508.            
  20509.             if(allarme.getEnabled() == 0) { // allarme disabilitato
  20510.                 de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  20511.             }
  20512.             dati.add(de);  
  20513.            
  20514.             // Acknowledge
  20515.             if(this.confCore.getAllarmiConfig().isOptionsAcknowledgedStatusAssociation() ||
  20516.                     ( allarme.getMail().getInvia() == 1 && this.confCore.getAllarmiConfig().isMailCheckAcknowledgedStatus()) ||
  20517.                     ( allarme.getScript().getInvoca() == 1 && this.confCore.getAllarmiConfig().isScriptCheckAcknowledgedStatus()) ) {
  20518.                
  20519.                 de = new DataElement();
  20520.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ACKNOWLEDGED);
  20521.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ACKNOWLEDGED);
  20522.                 if(allarme.getEnabled() == 1 &&
  20523.                         (
  20524.                                 allarme.getStato().intValue() == org.openspcoop2.core.allarmi.utils.AllarmiConverterUtils.toIntegerValue(StatoAllarme.WARNING)
  20525.                                 ||
  20526.                                 allarme.getStato().intValue() == org.openspcoop2.core.allarmi.utils.AllarmiConverterUtils.toIntegerValue(StatoAllarme.ERROR)
  20527.                         )
  20528.                         ) {
  20529.                     de.setType(DataElementType.TEXT);
  20530.                 }
  20531.                 else {
  20532.                     de.setType(DataElementType.HIDDEN);
  20533.                 }
  20534.                 if(allarme.getAcknowledged() == 1) {
  20535.                     de.setValue(ConfigurazioneCostanti.LABEL_VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_ACKNOWLEDGE_SI);
  20536.                 }
  20537.                
  20538.                 if(allarme.getAcknowledged() == 0) {
  20539.                     de.setValue(ConfigurazioneCostanti.LABEL_VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_ACKNOWLEDGE_NO);
  20540.                 }
  20541.                 dati.add(de);
  20542.             }
  20543.            
  20544.             // Archivio Stati
  20545.             if(this.confCore.isShowAllarmiFormStatoAllarmeHistory() && this.confCore.getAllarmiConfig().isHistoryEnabled()) {
  20546.                 de = new DataElement();
  20547.     //          de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ARCHIVIO_STATI);
  20548.                 de.setType(DataElementType.LINK);
  20549.                 de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_HISTORY_LIST, pIdAllarme);
  20550.                 de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ARCHIVIO_STATI);
  20551.                 dati.add(de);
  20552.             }
  20553.         }
  20554.        
  20555.         if(tipoOperazione.equals(TipoOperazione.CHANGE) && allarmeAttivo) {
  20556.            
  20557.             de = new DataElement();
  20558.             de.setType(DataElementType.SUBTITLE);
  20559.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RUNTIME);
  20560.             dati.add(de);      
  20561.            
  20562.             List<Parameter> lstParamEntry = new ArrayList<>();
  20563.             if(ruoloPorta!=null) {
  20564.                 Parameter parRuoloPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA, ruoloPorta.getValue());
  20565.                 lstParamEntry.add(parRuoloPorta);
  20566.             }
  20567.             if(nomePorta!=null) {
  20568.                 Parameter parNomePorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA, nomePorta);
  20569.                 lstParamEntry.add(parNomePorta);
  20570.             }
  20571.             if(serviceBinding!=null) {
  20572.                 Parameter parServiceBinding = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING, serviceBinding.name());
  20573.                 lstParamEntry.add(parServiceBinding);
  20574.             }
  20575.             Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ID_ALLARME, allarme.getId() + "");
  20576.             lstParamEntry.add(pId);
  20577.             Parameter pState = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_STATE, true+"");
  20578.             lstParamEntry.add(pState);
  20579.            
  20580.             de = new DataElement();
  20581.             de.setType(DataElementType.LINK);
  20582.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParamEntry.toArray(new Parameter[lstParamEntry.size()]));
  20583.             de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_VISUALIZZA_STATO_EDIT);
  20584.             dati.add(de);
  20585.            
  20586.         }
  20587.        
  20588.        
  20589.         boolean delegata = false;
  20590.         boolean applicativa = false;
  20591.         @SuppressWarnings("unused")
  20592.         boolean configurazione = false;
  20593.         if(ruoloPorta!=null) {
  20594.             if(RuoloPorta.DELEGATA.equals(ruoloPorta)) {
  20595.                 delegata = (nomePorta!=null);
  20596.             }
  20597.             else if(RuoloPorta.APPLICATIVA.equals(ruoloPorta)) {
  20598.                 applicativa = (nomePorta!=null);
  20599.             }
  20600.         }
  20601.         configurazione = !delegata && !applicativa;
  20602.        
  20603.         boolean multitenant = this.confCore.isMultitenant();
  20604.        
  20605.         boolean tokenAbilitato = true;
  20606.        
  20607.         PddTipologia pddTipologiaSoggettoAutenticati = null;
  20608.         boolean gestioneErogatori_soggettiAutenticati_escludiSoggettoErogatore = false;
  20609.         PortaDelegata portaDelegata = null;
  20610.         PortaApplicativa portaApplicativa = null;
  20611.         CredenzialeTipo tipoAutenticazione = null;
  20612.         Boolean appId = null;
  20613.         String tokenPolicy = null;
  20614.         IDSoggetto idSoggettoProprietario = null;
  20615.         if(ruoloPorta!=null) {
  20616.             if(applicativa) {
  20617.                
  20618.                 if(multitenant && this.confCore.getMultitenantSoggettiErogazioni()!=null) {
  20619.                     switch (this.confCore.getMultitenantSoggettiErogazioni()) {
  20620.                     case SOLO_SOGGETTI_ESTERNI:
  20621.                         pddTipologiaSoggettoAutenticati = PddTipologia.ESTERNO;
  20622.                         break;
  20623.                     case ESCLUDI_SOGGETTO_EROGATORE:
  20624.                         gestioneErogatori_soggettiAutenticati_escludiSoggettoErogatore = true;
  20625.                         break;
  20626.                     case TUTTI:
  20627.                         break;
  20628.                     }
  20629.                 }
  20630.                
  20631.                 IDPortaApplicativa idPA = new IDPortaApplicativa();
  20632.                 idPA.setNome(nomePorta);
  20633.                 portaApplicativa = this.porteApplicativeCore.getPortaApplicativa(idPA);
  20634.                 tipoAutenticazione = CredenzialeTipo.toEnumConstant(portaApplicativa.getAutenticazione());
  20635.                 if(CredenzialeTipo.APIKEY.equals(tipoAutenticazione)) {
  20636.                     ApiKeyState apiKeyState =  new ApiKeyState(this.porteApplicativeCore.getParametroAutenticazione(portaApplicativa.getAutenticazione(), portaApplicativa.getProprietaAutenticazioneList()));
  20637.                     appId = apiKeyState.appIdSelected;
  20638.                 }
  20639.                 if(portaApplicativa.getGestioneToken()!=null && portaApplicativa.getGestioneToken().getPolicy()!=null) {
  20640.                     tokenPolicy = portaApplicativa.getGestioneToken().getPolicy();
  20641.                 }
  20642.                 idSoggettoProprietario = new IDSoggetto(portaApplicativa.getTipoSoggettoProprietario(), portaApplicativa.getNomeSoggettoProprietario());
  20643.                
  20644.                 if(portaApplicativa.getGestioneToken()!=null) {
  20645.                     String gestioneTokenPolicy = portaApplicativa.getGestioneToken().getPolicy();
  20646.                     if( gestioneTokenPolicy == null ||
  20647.                             gestioneTokenPolicy.equals("") ||
  20648.                             gestioneTokenPolicy.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO)) {
  20649.                         tokenAbilitato = false;
  20650.                     }                      
  20651.                 }
  20652.                 else {
  20653.                     tokenAbilitato = false;
  20654.                 }

  20655.             }
  20656.             if(delegata) {
  20657.                 IDPortaDelegata idPD = new IDPortaDelegata();
  20658.                 idPD.setNome(nomePorta);
  20659.                 portaDelegata = this.porteDelegateCore.getPortaDelegata(idPD);
  20660.                 tipoAutenticazione = CredenzialeTipo.toEnumConstant(portaDelegata.getAutenticazione());
  20661.                 if(CredenzialeTipo.APIKEY.equals(tipoAutenticazione)) {
  20662.                     ApiKeyState apiKeyState =  new ApiKeyState(this.porteDelegateCore.getParametroAutenticazione(portaDelegata.getAutenticazione(), portaDelegata.getProprietaAutenticazioneList()));
  20663.                     appId = apiKeyState.appIdSelected;
  20664.                 }
  20665.                 if(portaDelegata.getGestioneToken()!=null && portaDelegata.getGestioneToken().getPolicy()!=null) {
  20666.                     tokenPolicy = portaDelegata.getGestioneToken().getPolicy();
  20667.                 }
  20668.                 idSoggettoProprietario = new IDSoggetto(portaDelegata.getTipoSoggettoProprietario(), portaDelegata.getNomeSoggettoProprietario());
  20669.                
  20670.                 if(portaDelegata.getGestioneToken()!=null) {
  20671.                     String gestioneTokenPolicy = portaDelegata.getGestioneToken().getPolicy();
  20672.                     if( gestioneTokenPolicy == null ||
  20673.                             gestioneTokenPolicy.equals("") ||
  20674.                             gestioneTokenPolicy.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO)) {
  20675.                         tokenAbilitato = false;
  20676.                     }                      
  20677.                 }
  20678.                 else {
  20679.                     tokenAbilitato = false;
  20680.                 }
  20681.             }
  20682.         }

  20683.         Context context = this.createAlarmContext(allarme, parameters);
  20684.         boolean groupByAllarme = this.isShowGroupBy(allarme, context);
  20685.        
  20686.         if( (parameters != null && parameters.size() > 0) || groupByAllarme) {
  20687.             de = new DataElement();
  20688.             de.setType(DataElementType.TITLE);
  20689.             de.setLabel(getParameterSectionTitle(allarme, groupByAllarme));
  20690.             dati.add(de);
  20691.         }
  20692.        
  20693.         // sezione dinamica parametri
  20694.         if(parameters != null && parameters.size() > 0) {
  20695.            
  20696.             for (org.openspcoop2.monitor.sdk.parameters.Parameter<?> parameter : parameters) {
  20697.                 BaseComponent<?> component = (BaseComponent<?>) parameter;
  20698.                
  20699.                 component.updateRendering();
  20700.                
  20701.                 String postBack = this.getPostBackElementName();
  20702.                 if(StringUtils.isNotEmpty(postBack)) {
  20703.                     if(postBack.equals(parameter.getId())) {
  20704.                         component.valueSelectedListener();
  20705.                     }
  20706.                 }
  20707.                
  20708.                 if(component.getRendered()) { // nella versione originale non sono consentiti gli hidden
  20709.                     dati.add(component.toDataElement());
  20710.                 }
  20711.                 else {
  20712.                     Hidden<?> hidden = new Hidden<>(parameter, component.getLoader());
  20713.                     dati.add(hidden.toDataElement());
  20714.                 }
  20715.                
  20716.             }
  20717.         }
  20718.        
  20719.         // sezione group by
  20720.         if(groupByAllarme) {
  20721.             this.addToDatiAllarmeGroupBy(dati, tipoOperazione, allarme, context,
  20722.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_RAGGRUPPAMENTO,
  20723.                     ruoloPorta, nomePorta, serviceBinding, tokenAbilitato);
  20724.         }
  20725.        
  20726.         // Sezione filtro
  20727.         if(this.isShowFilter(allarme, context)) {
  20728.             this.addToDatiAllarmeFiltro(dati, tipoOperazione, allarme, context,
  20729.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO,
  20730.                     ruoloPorta, nomePorta, serviceBinding, idSoggettoProprietario, tokenAbilitato ,
  20731.                     tipoAutenticazione, appId, tokenPolicy,
  20732.                     pddTipologiaSoggettoAutenticati, gestioneErogatori_soggettiAutenticati_escludiSoggettoErogatore);
  20733.         }
  20734.        
  20735.         // Notifiche Email
  20736.         if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20737.             de = new DataElement();
  20738.             de.setType(DataElementType.TITLE);
  20739.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_NOTIFICA_EMAIL);
  20740.             dati.add(de);
  20741.         }
  20742.        
  20743.         // abilitato inviaEmailAlert
  20744.         de = new DataElement();
  20745.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_INVIA_EMAIL_ALERT_ABILITATO);
  20746.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_INVIA_EMAIL_ALERT);
  20747.         if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20748.             de.setType(DataElementType.SELECT);
  20749.             String [] inviaEmailAlertValues = ConfigurazioneCostanti.VALUES_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO;
  20750.             String [] inviaEmailAlertLabels = ConfigurazioneCostanti.LABELS_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO;
  20751.             de.setValues(inviaEmailAlertValues);
  20752.             de.setLabels(inviaEmailAlertLabels);
  20753.             de.setSelected(allarme.getMail().getInvia()+"");
  20754.             de.setPostBack_viaPOST(true);
  20755.         }
  20756.         else {
  20757.             de.setType(DataElementType.HIDDEN);
  20758.             de.setValue(allarme.getMail().getInvia()+"");
  20759.         }
  20760.         dati.add(de);
  20761.        
  20762.         if(allarme.getMail().getInvia() == 1) {
  20763.             // destinatari
  20764.             de = new DataElement();
  20765.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_DESTINATARI_EMAIL);
  20766.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_DESTINATARI_EMAIL);
  20767.             if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20768.                 de.setType(DataElementType.TEXT_EDIT);
  20769.                 de.setNote(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_DESTINATARI_EMAIL_NOTE);
  20770.             }
  20771.             else {
  20772.                 de.setType(DataElementType.HIDDEN);
  20773.             }
  20774.             de.setValue(allarme.getMail().getDestinatari());
  20775.             dati.add(de);
  20776.            
  20777.             // notifica warning
  20778.             de = new DataElement();
  20779.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_WARNING);
  20780.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_WARNING);
  20781.             if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20782.                 de.setType(DataElementType.SELECT);
  20783.                 String [] notificaWarningValues = ConfigurazioneCostanti.VALUES_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO;
  20784.                 String [] notificaWarinigLabels = ConfigurazioneCostanti.LABELS_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO;
  20785.                 de.setValues(notificaWarningValues);
  20786.                 de.setLabels(notificaWarinigLabels);
  20787.                 de.setSelected(allarme.getMail().getInviaWarning()+"");
  20788.             }
  20789.             else {
  20790.                 de.setType(DataElementType.HIDDEN);
  20791.                 de.setValue(allarme.getMail().getInviaWarning()+"");
  20792.             }
  20793.             dati.add(de);
  20794.            
  20795.             if(this.confCore.getAllarmiConfig().isMailShowAllOptions()) {          
  20796.                 // Subject
  20797.                 de = new DataElement();
  20798.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_INVIA_EMAIL_SUBJECT);
  20799.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_INVIA_EMAIL_SUBJECT);
  20800.                 if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20801.                     de.setType(DataElementType.TEXT_EDIT);
  20802.                 }
  20803.                 else {
  20804.                     de.setType(DataElementType.HIDDEN);
  20805.                 }
  20806.                 de.setValue(allarme.getMail().getSubject());
  20807.                 dati.add(de);
  20808.                
  20809.                 // Body
  20810.                 de = new DataElement();
  20811.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_INVIA_EMAIL_BODY);
  20812.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_INVIA_EMAIL_BODY);
  20813.                 if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20814.                     de.setType(DataElementType.TEXT_AREA);
  20815.                 }
  20816.                 else {
  20817.                     de.setType(DataElementType.HIDDEN);
  20818.                 }
  20819.                 de.setValue(allarme.getMail().getBody());
  20820.                 dati.add(de);
  20821.             }
  20822.         }
  20823.        
  20824.        
  20825.         // Notifiche monitoraggio esterno
  20826.         if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20827.             de = new DataElement();
  20828.             de.setType(DataElementType.TITLE);
  20829.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_NOTIFICA_MONITORAGGIO_ESTERNO);
  20830.             dati.add(de);
  20831.         }
  20832.        
  20833.         // abilitato invocaScriptAlert
  20834.         de = new DataElement();
  20835.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_INVOCA_SCRIPT_ALERT_ABILITATO);
  20836.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_INVOCA_SCRIPT_ALERT);
  20837.         if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20838.             de.setType(DataElementType.SELECT);
  20839.             String [] invocaScriptAlertValues = ConfigurazioneCostanti.VALUES_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO;
  20840.             String [] invocaScriptAlertLabels = ConfigurazioneCostanti.LABELS_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO;
  20841.             de.setValues(invocaScriptAlertValues);
  20842.             de.setLabels(invocaScriptAlertLabels);
  20843.             de.setSelected(allarme.getScript().getInvoca()+"");
  20844.             de.setPostBack_viaPOST(true);
  20845.         }
  20846.         else {
  20847.             de.setType(DataElementType.HIDDEN);
  20848.             de.setValue(allarme.getScript().getInvoca()+"");
  20849.         }
  20850.         dati.add(de);
  20851.        
  20852.         if(allarme.getScript().getInvoca() == 1) {
  20853.             // notifica warning
  20854.             de = new DataElement();
  20855.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_WARNING_SCRIPT);
  20856.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_WARNING_SCRIPT);
  20857.             if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20858.                 de.setType(DataElementType.SELECT);
  20859.                 String [] notificaWarningValues = ConfigurazioneCostanti.VALUES_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO;
  20860.                 String [] notificaWarinigLabels = ConfigurazioneCostanti.LABELS_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO;
  20861.                 de.setValues(notificaWarningValues);
  20862.                 de.setLabels(notificaWarinigLabels);
  20863.                 de.setSelected(allarme.getScript().getInvocaWarning()+"");
  20864.             }
  20865.             else {
  20866.                 de.setType(DataElementType.HIDDEN);
  20867.                 de.setValue(allarme.getScript().getInvocaWarning()+"");
  20868.             }
  20869.             dati.add(de);
  20870.            
  20871.             if(this.confCore.getAllarmiConfig().isScriptShowAllOptions()) {
  20872.            
  20873.                 // Subject
  20874.                 de = new DataElement();
  20875.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_SCRIPT_PATH);
  20876.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_SCRIPT_PATH);
  20877.                 if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20878.                     de.setType(DataElementType.TEXT_EDIT);
  20879.                 }
  20880.                 else {
  20881.                     de.setType(DataElementType.HIDDEN);
  20882.                 }
  20883.                 de.setValue(allarme.getScript().getCommand());
  20884.                 dati.add(de);
  20885.                
  20886.                 // Body
  20887.                 de = new DataElement();
  20888.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_SCRIPT_ARGUMENTS);
  20889.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOTIFICA_SCRIPT_ARGUMENTS);
  20890.                 if(tipoOperazione.equals(TipoOperazione.CHANGE) || (!first && allarme.getPlugin() != null) ){
  20891.                     de.setType(DataElementType.TEXT_EDIT);
  20892.                 }
  20893.                 else {
  20894.                     de.setType(DataElementType.HIDDEN);
  20895.                 }
  20896.                 de.setValue(allarme.getScript().getArgs());
  20897.                 dati.add(de);
  20898.             }
  20899.         }
  20900.        
  20901.     }
  20902.    
  20903.     public boolean isShowFilter(ConfigurazioneAllarmeBean allarme, Context context) throws Exception {
  20904.         if(allarme==null || allarme.getPlugin() == null){
  20905.             return false; // all'inizio deve prima essere scelto il plugin
  20906.         }
  20907.        
  20908.         return this.confCore.isUsableFilter(allarme, context);
  20909.     }
  20910.    
  20911.     public FiltersConfiguration getFiltersConfiguration(ConfigurazioneAllarmeBean allarme, Context context) throws Exception {
  20912.         if(allarme==null || allarme.getPlugin() == null){
  20913.             return null;
  20914.         }
  20915.         return this.confCore.getFiltersConfiguration(allarme, context);
  20916.     }
  20917.    
  20918.    
  20919.     public boolean isShowGroupBy(ConfigurazioneAllarmeBean allarme, Context context) throws Exception {
  20920.         if(allarme==null || allarme.getPlugin() == null){
  20921.             return false; // all'inizio deve prima essere scelto il plugin
  20922.         }
  20923.        
  20924.         return this.confCore.isUsableGroupBy(allarme, context);
  20925.     }
  20926.    
  20927.     public GroupByConfiguration getGroupByConfiguration(ConfigurazioneAllarmeBean allarme, Context context) throws Exception {
  20928.         if(allarme==null || allarme.getPlugin() == null){
  20929.             return null;
  20930.         }
  20931.         return this.confCore.getGroupByConfiguration(allarme, context);
  20932.     }
  20933.    
  20934.     public String getParameterSectionTitle(ConfigurazioneAllarmeBean allarme, boolean groupByAllarme) throws Exception {
  20935.         if(allarme==null || allarme.getPlugin() == null){
  20936.             return ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_PARAMETRI; // all'inizio deve prima essere scelto il plugin
  20937.         }
  20938.         return this.confCore.getParameterSectionTitle(allarme, groupByAllarme);
  20939.     }
  20940.    
  20941.     private void addToDatiAllarmeFiltro(List<DataElement> dati, TipoOperazione tipoOperazione, ConfigurazioneAllarmeBean allarme, Context context, String nomeSezione,
  20942.             RuoloPorta ruoloPorta, String nomePorta, ServiceBinding serviceBinding,
  20943.             IDSoggetto idSoggettoProprietario, boolean tokenAbilitato,
  20944.             CredenzialeTipo tipoAutenticazione, Boolean appId, String tokenPolicy,
  20945.             PddTipologia pddTipologiaSoggettoAutenticati, boolean gestioneErogatori_soggettiAutenticati_escludiSoggettoErogatore) throws Exception {
  20946.    
  20947.         boolean delegata = false;
  20948.         boolean applicativa = false;
  20949.         boolean configurazione = false;
  20950.         if(ruoloPorta!=null) {
  20951.             if(RuoloPorta.DELEGATA.equals(ruoloPorta)) {
  20952.                 delegata = (nomePorta!=null);
  20953.             }
  20954.             else if(RuoloPorta.APPLICATIVA.equals(ruoloPorta)) {
  20955.                 applicativa = (nomePorta!=null);
  20956.             }
  20957.         }
  20958.         configurazione = !delegata && !applicativa;
  20959.        
  20960.         org.openspcoop2.core.config.constants.CredenzialeTipo tipoAutenticazioneConfig = null;
  20961.         if(tipoAutenticazione!=null) {
  20962.             tipoAutenticazioneConfig = org.openspcoop2.core.config.constants.CredenzialeTipo.toEnumConstant(tipoAutenticazione.getValue(), true);
  20963.         }
  20964.        
  20965.         boolean tokenPolicyOR = false;
  20966.         if(tokenPolicy!=null && !"".equals(tokenPolicy)) {
  20967.             if(tipoAutenticazione!=null && !org.openspcoop2.core.config.constants.CredenzialeTipo.TOKEN.equals(tipoAutenticazioneConfig)) {
  20968.                 tokenPolicyOR = true;
  20969.             }
  20970.             else {
  20971.                 tipoAutenticazioneConfig = org.openspcoop2.core.config.constants.CredenzialeTipo.TOKEN;
  20972.             }
  20973.         }
  20974.        
  20975.         boolean multitenant = this.confCore.isMultitenant();
  20976.        
  20977.         FiltersConfiguration filterConfig = this.confCore.getFiltersConfiguration(allarme, context);
  20978.        
  20979.         // Ruolo Gateway
  20980.         RuoloPorta ruoloPortaFiltro = null;
  20981.         if(allarme!=null && allarme.getFiltro()!=null) {
  20982.             ruoloPortaFiltro = allarme.getFiltro().getRuoloPorta();
  20983.         }
  20984.         if(configurazione && filterConfig!=null && !filterConfig.isHideGatewayRole() &&
  20985.                 (filterConfig.isForceInGatewayRole() || filterConfig.isForceOutGatewayRole())) {
  20986.             if(filterConfig.isForceInGatewayRole()) {
  20987.                 ruoloPortaFiltro = RuoloPorta.APPLICATIVA;
  20988.             }
  20989.             else if(filterConfig.isForceOutGatewayRole()) {
  20990.                 ruoloPortaFiltro = RuoloPorta.DELEGATA;
  20991.             }
  20992.         }

  20993.        
  20994.         // Elaboro valori con dipendenze
  20995.        
  20996.         List<String> protocolliLabel = null;
  20997.         List<String> protocolliValue = null;
  20998.         String protocolloSelezionatoLabel = null;
  20999.         String protocolloSelezionatoValue = null;
  21000.        
  21001.         List<String> ruoliErogatoreLabel = null;
  21002.         List<String> ruoliErogatoreValue = null;
  21003.         String ruoloErogatoreSelezionatoLabel = null;
  21004.         String ruoloErogatoreSelezionatoValue = null;
  21005.        
  21006.         List<String> erogatoriLabel = null;
  21007.         List<String> erogatoriValue = null;
  21008.         String datiIdentificativiErogatoreSelezionatoLabel = null;
  21009.         String datiIdentificativiErogatoreSelezionatoValue = null;
  21010.        
  21011.         List<String> tagLabel = null;
  21012.         List<String> tagValue = null;
  21013.         @SuppressWarnings("unused")
  21014.         String datiIdentificativiTagSelezionatoLabel = null;
  21015.         String datiIdentificativiTagSelezionatoValue = null;
  21016.        
  21017.         List<String> serviziLabel = null;
  21018.         List<String> serviziValue = null;
  21019.         String datiIdentificativiServizioSelezionatoLabel = null;
  21020.         String datiIdentificativiServizioSelezionatoValue = null;
  21021.        
  21022.         List<String> azioniLabel = null;
  21023.         List<String> azioniValue = null;
  21024.         List<String> azioniSelezionataLabel = null;
  21025.         List<String> azioniSelezionataValue = null;
  21026.        
  21027. //      List<String> serviziApplicativiErogatoreLabel = null;
  21028. //      List<String> serviziApplicativiErogatoreValue = null;
  21029. //      String servizioApplicativoErogatoreSelezionatoLabel = null;
  21030. //      String servizioApplicativoErogatoreSelezionatoValue = null;
  21031.        
  21032.         List<String> ruoliFruitoreLabel = null;
  21033.         List<String> ruoliFruitoreValue = null;
  21034.         String ruoloFruitoreSelezionatoLabel = null;
  21035.         String ruoloFruitoreSelezionatoValue = null;
  21036.        
  21037.         List<String> fruitoriLabel = null;
  21038.         List<String> fruitoriValue = null;
  21039.         String datiIdentificativiFruitoreSelezionatoLabel = null;
  21040.         String datiIdentificativiFruitoreSelezionatoValue = null;
  21041.        
  21042.         List<String> serviziApplicativiFruitoreLabel = null;
  21043.         List<String> serviziApplicativiFruitoreValue = null;
  21044.         String servizioApplicativoFruitoreSelezionatoLabel = null;
  21045.         String servizioApplicativoFruitoreSelezionatoValue = null;
  21046.        
  21047.         // Cerco Ruoli con queste caratteristiche
  21048.         FiltroRicercaRuoli filtroRuoli = new FiltroRicercaRuoli();
  21049.         filtroRuoli.setTipologia(RuoloTipologia.INTERNO);
  21050.        
  21051.         boolean protocolloAssociatoFiltroNonSelezionatoUtente = false;
  21052.         if(allarme!=null && allarme.getFiltro()!=null && allarme.getFiltro().isEnabled()){
  21053.             protocolliValue = this.confCore.getProtocolli(this.request, this.session);
  21054.             if(allarme.getFiltro().getProtocollo()!=null) {
  21055.                 // sara' sempre impostato, a meno della prima volta (create policy)
  21056.                 if(protocolliValue.contains(allarme.getFiltro().getProtocollo())==false) {
  21057.                     protocolloAssociatoFiltroNonSelezionatoUtente = true;
  21058.                 }
  21059.             }
  21060.         }
  21061.        
  21062.         if(allarme!=null && allarme.getFiltro()!=null && allarme.getFiltro().isEnabled()){
  21063.            
  21064.             // protocollo
  21065.             if(configurazione) {
  21066.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  21067.                     protocolloSelezionatoValue = allarme.getFiltro().getProtocollo();
  21068.                 }
  21069.                 else {
  21070.                     if(!protocolliValue.contains(allarme.getFiltro().getProtocollo())){
  21071.                         allarme.getFiltro().setProtocollo(null);
  21072.                     }
  21073.                     protocolloSelezionatoValue = allarme.getFiltro().getProtocollo();
  21074.                     if(protocolloSelezionatoValue==null || protocolloSelezionatoValue.equals("")) {
  21075.                         if(protocolliValue.size()==1) {
  21076.                             protocolloSelezionatoValue = protocolliValue.get(0);
  21077.                         }
  21078.                         else {
  21079.                             protocolloSelezionatoValue = this.confCore.getProtocolloDefault(this.request, this.session, protocolliValue);
  21080.                         }
  21081.                     }
  21082.                     //protocolli = enrichListConQualsiasi(protocolli); NOTA: In questa versione un protocollo deve essere per forza selezionato.
  21083.                     protocolliLabel = new ArrayList<>();
  21084.                     for (String protocollo : protocolliValue) {
  21085.                         protocolliLabel.add(this.getLabelProtocollo(protocollo));
  21086.                     }
  21087.                 }
  21088.                 protocolloSelezionatoLabel = this.getLabelProtocollo(protocolloSelezionatoValue);
  21089.             }
  21090.             else {
  21091.                 protocolloSelezionatoValue = allarme.getFiltro().getProtocollo();
  21092.                 if(protocolloSelezionatoValue==null) {
  21093.                     protocolloSelezionatoValue = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(idSoggettoProprietario.getTipo());
  21094.                 }
  21095.             }
  21096.            
  21097.             // ruolo erogatore
  21098.             if(configurazione) {
  21099.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  21100.                     ruoloErogatoreSelezionatoValue = allarme.getFiltro().getRuoloErogatore();
  21101.                     ruoloErogatoreSelezionatoLabel = ruoloErogatoreSelezionatoValue!=null ? ruoloErogatoreSelezionatoValue :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  21102.                 }
  21103.                 else {
  21104.                     List<String> ruoliErogatore = this.core.getAllRuoli(filtroRuoli);
  21105.                    
  21106.                     if(allarme.getFiltro().getRuoloErogatore()!=null) {
  21107.                         ruoloErogatoreSelezionatoValue = allarme.getFiltro().getRuoloErogatore();
  21108.                     }
  21109.                     if(!ruoliErogatore.contains(ruoloErogatoreSelezionatoValue)){
  21110.                         allarme.getFiltro().setRuoloErogatore(null);
  21111.                         ruoloErogatoreSelezionatoValue = null;
  21112.                     }
  21113.                     ruoliErogatoreLabel = enrichListConLabelQualsiasi(ruoliErogatore);
  21114.                     ruoliErogatoreValue = enrichListConValueQualsiasi(ruoliErogatore);
  21115.                 }
  21116.             }
  21117.            
  21118.             // erogatore
  21119.             if(configurazione) {
  21120.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  21121.                     IDSoggetto idSoggetto = null;
  21122.                     if(allarme.getFiltro().getTipoErogatore()!=null && allarme.getFiltro().getNomeErogatore()!=null){
  21123.                         datiIdentificativiErogatoreSelezionatoValue = allarme.getFiltro().getTipoErogatore() + "/" + allarme.getFiltro().getNomeErogatore();
  21124.                         idSoggetto = new IDSoggetto(allarme.getFiltro().getTipoErogatore() , allarme.getFiltro().getNomeErogatore());
  21125.                     }
  21126.                     datiIdentificativiErogatoreSelezionatoLabel = idSoggetto!=null ? this.getLabelNomeSoggetto(idSoggetto) :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  21127.                 }
  21128.                 else {
  21129.                     List<IDSoggetto> listErogatori = new ArrayList<>();

  21130.                     List<IDSoggetto> listSoggettiPreFilterMultitenant = this.confCore.getSoggettiErogatori(protocolloSelezionatoValue, protocolliValue);
  21131.                     if(ruoloPortaFiltro!=null && !RuoloPorta.ENTRAMBI.equals(ruoloPortaFiltro)) {
  21132.                         for (IDSoggetto idSoggetto : listSoggettiPreFilterMultitenant) {
  21133.                             Soggetto s = this.soggettiCore.getSoggettoRegistro(idSoggetto);
  21134.                             boolean isPddEsterna = this.pddCore.isPddEsterna(s.getPortaDominio());
  21135.                             if(RuoloPorta.DELEGATA.equals(ruoloPortaFiltro)) {
  21136.                                 if(isPddEsterna) {
  21137.                                     listErogatori.add(idSoggetto);
  21138.                                 }  
  21139.                                 else {
  21140.                                     if(!PddTipologia.ESTERNO.equals(pddTipologiaSoggettoAutenticati)) {
  21141.                                         // multitenant abilitato
  21142.                                         listErogatori.add(idSoggetto);
  21143.                                     }
  21144.                                 }
  21145.                             }
  21146.                             else {
  21147.                                 if(!isPddEsterna) {
  21148.                                     listErogatori.add(idSoggetto);
  21149.                                 }
  21150.                             }
  21151.                         }
  21152.                     }
  21153.                     else {
  21154.                         listErogatori.addAll(listSoggettiPreFilterMultitenant);
  21155.                     }
  21156.                    
  21157.                     erogatoriLabel = new ArrayList<>();
  21158.                     erogatoriValue = new ArrayList<>();
  21159.                     for (IDSoggetto idSoggetto : listErogatori) {
  21160.                         erogatoriLabel.add(this.getLabelNomeSoggetto(idSoggetto));
  21161.                         erogatoriValue.add(idSoggetto.getTipo()+"/"+idSoggetto.getNome());
  21162.                     }
  21163.                     if(allarme.getFiltro().getTipoErogatore()!=null && allarme.getFiltro().getNomeErogatore()!=null){
  21164.                         datiIdentificativiErogatoreSelezionatoValue = allarme.getFiltro().getTipoErogatore() + "/" + allarme.getFiltro().getNomeErogatore();
  21165.                     }
  21166.                     if(!erogatoriValue.contains(datiIdentificativiErogatoreSelezionatoValue)){
  21167.                         allarme.getFiltro().setTipoErogatore(null);
  21168.                         allarme.getFiltro().setNomeErogatore(null);
  21169.                         datiIdentificativiErogatoreSelezionatoValue = null;
  21170.                     }
  21171.                     erogatoriLabel = enrichListConLabelQualsiasi(erogatoriLabel);
  21172.                     erogatoriValue = enrichListConValueQualsiasi(erogatoriValue);
  21173.                 }
  21174.             }
  21175.                    
  21176.             // tag
  21177.             if(configurazione) {
  21178.                 FiltroRicercaGruppi filtroRicerca = new FiltroRicercaGruppi();
  21179.                 List<String> elencoGruppi = this.gruppiCore.getAllGruppi(filtroRicerca);
  21180.                 tagLabel = enrichListConLabelQualsiasi(elencoGruppi);
  21181.                 tagValue = enrichListConValueQualsiasi(elencoGruppi);
  21182.                 datiIdentificativiTagSelezionatoValue=allarme.getFiltro().getTag();
  21183.                 datiIdentificativiTagSelezionatoLabel=allarme.getFiltro().getTag();
  21184.             }
  21185.            
  21186.             // servizio
  21187.             if(configurazione) {
  21188.                 boolean controlloAllarmiFiltroApiSoggettoErogatore = this.core.getAllarmiConfig().isOptionsFilterApiOrganization();
  21189.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  21190.                     IDServizio idServizio = null;
  21191.                     if(allarme.getFiltro().getTipoServizio()!=null && allarme.getFiltro().getNomeServizio()!=null && allarme.getFiltro().getVersioneServizio()!=null &&
  21192.                             allarme.getFiltro().getTipoErogatore()!=null && allarme.getFiltro().getNomeErogatore()!=null
  21193.                             ){
  21194.                         datiIdentificativiServizioSelezionatoValue = allarme.getFiltro().getTipoServizio()+"/"+allarme.getFiltro().getNomeServizio()+"/"+allarme.getFiltro().getVersioneServizio().intValue();
  21195.                         if(controlloAllarmiFiltroApiSoggettoErogatore) {
  21196.                             datiIdentificativiServizioSelezionatoValue = datiIdentificativiServizioSelezionatoValue+"/"+allarme.getFiltro().getTipoErogatore()+"/"+allarme.getFiltro().getNomeErogatore();
  21197.                             idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(allarme.getFiltro().getTipoServizio(),
  21198.                                     allarme.getFiltro().getNomeServizio(),
  21199.                                     allarme.getFiltro().getTipoErogatore(),
  21200.                                     allarme.getFiltro().getNomeErogatore(),
  21201.                                     allarme.getFiltro().getVersioneServizio());
  21202.                         }
  21203.                         else {
  21204.                             idServizio = IDServizioFactory.getInstance().getIDServizioFromValuesWithoutCheck(allarme.getFiltro().getTipoServizio(),
  21205.                                     allarme.getFiltro().getNomeServizio(),
  21206.                                     null,
  21207.                                     null,
  21208.                                     allarme.getFiltro().getVersioneServizio());
  21209.                         }
  21210.                     }
  21211.                     if(controlloAllarmiFiltroApiSoggettoErogatore) {
  21212.                         datiIdentificativiServizioSelezionatoLabel = idServizio!=null ? this.getLabelIdServizio(idServizio) :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  21213.                     }
  21214.                     else {
  21215.                         datiIdentificativiServizioSelezionatoLabel = idServizio!=null ? this.getLabelIdServizioSenzaErogatore(idServizio) :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  21216.                     }
  21217.                 }
  21218.                 else {
  21219.                     List<IDServizio> listServizi = this.confCore.getServizi(protocolloSelezionatoValue, protocolliValue,
  21220.                             allarme.getFiltro().getTipoErogatore(), allarme.getFiltro().getNomeErogatore(), allarme.getFiltro().getTag());
  21221.                     serviziLabel = new ArrayList<>();
  21222.                     serviziValue = new ArrayList<>();
  21223.                     for (IDServizio idServizio : listServizi) {
  21224.                        
  21225.                         String valueAPI = idServizio.getTipo()+"/"+idServizio.getNome()+"/"+idServizio.getVersione().intValue();
  21226.                         if(controlloAllarmiFiltroApiSoggettoErogatore) {
  21227.                             valueAPI = valueAPI +"/"+ idServizio.getSoggettoErogatore().getTipo()+"/"+idServizio.getSoggettoErogatore().getNome();
  21228.                         }
  21229.                         if(serviziValue.contains(valueAPI)) {
  21230.                             continue;
  21231.                         }
  21232.                         serviziValue.add(valueAPI);
  21233.                        
  21234.                         String labelAPI = null;
  21235.                         if(controlloAllarmiFiltroApiSoggettoErogatore) {
  21236.                             labelAPI = this.getLabelIdServizio(idServizio);
  21237.                         }
  21238.                         else {
  21239.                             labelAPI = this.getLabelIdServizioSenzaErogatore(idServizio);
  21240.                         }
  21241.                         serviziLabel.add(labelAPI);
  21242.                     }
  21243.                     boolean definedApi = allarme.getFiltro().getTipoServizio()!=null && allarme.getFiltro().getNomeServizio()!=null && allarme.getFiltro().getVersioneServizio()!=null;
  21244.                     if(controlloAllarmiFiltroApiSoggettoErogatore) {
  21245.                         definedApi = definedApi && allarme.getFiltro().getTipoErogatore()!=null && allarme.getFiltro().getNomeErogatore()!=null;
  21246.                     }
  21247.                     if( definedApi ){
  21248.                         datiIdentificativiServizioSelezionatoValue = allarme.getFiltro().getTipoServizio()+"/"+allarme.getFiltro().getNomeServizio()+"/"+allarme.getFiltro().getVersioneServizio().intValue();
  21249.                         if(controlloAllarmiFiltroApiSoggettoErogatore) {
  21250.                             datiIdentificativiServizioSelezionatoValue = datiIdentificativiServizioSelezionatoValue +"/"+allarme.getFiltro().getTipoErogatore()+"/"+allarme.getFiltro().getNomeErogatore();
  21251.                         }
  21252.                     }
  21253.                     if(!serviziValue.contains(datiIdentificativiServizioSelezionatoValue)){
  21254.                         allarme.getFiltro().setTipoServizio(null);
  21255.                         allarme.getFiltro().setNomeServizio(null);
  21256.                         allarme.getFiltro().setVersioneServizio(null);
  21257.                         datiIdentificativiServizioSelezionatoValue = null;
  21258.                     }
  21259.                     serviziLabel = enrichListConLabelQualsiasi(serviziLabel);
  21260.                     serviziValue = enrichListConValueQualsiasi(serviziValue);
  21261.                 }
  21262.             }
  21263.            
  21264.             // azioni
  21265.             if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  21266.                 if(allarme.getFiltro().getAzione()!=null && !"".equals(allarme.getFiltro().getAzione())){
  21267.                     azioniSelezionataValue = new ArrayList<>();
  21268.                     if(allarme.getFiltro().getAzione().contains(",")) {
  21269.                         String [] tmp = allarme.getFiltro().getAzione().split(",");
  21270.                         for (String az : tmp) {
  21271.                             azioniSelezionataValue.add(az);
  21272.                         }
  21273.                     }
  21274.                     else {
  21275.                         azioniSelezionataValue.add(allarme.getFiltro().getAzione());
  21276.                     }
  21277.                     if(!azioniSelezionataValue.isEmpty()) {
  21278.                         azioniSelezionataLabel = new ArrayList<>();
  21279.                         for (String az : azioniSelezionataValue) {
  21280.                             azioniSelezionataLabel.add(az);
  21281.                         }
  21282.                     }
  21283.                 }
  21284.                 if(azioniSelezionataLabel==null) {
  21285.                     azioniSelezionataLabel = new ArrayList<>();
  21286.                     azioniSelezionataLabel.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI);
  21287.                 }
  21288.             }
  21289.             else {
  21290.                 List<String> azioni = null;
  21291.                 Map<String,String> azioniConLabel = null;
  21292.                 if(configurazione && datiIdentificativiServizioSelezionatoValue!=null) {
  21293.                     if(StringUtils.isNotEmpty(allarme.getFiltro().getTipoServizio()) &&
  21294.                             StringUtils.isNotEmpty(allarme.getFiltro().getNomeServizio()) &&
  21295.                             allarme.getFiltro().getVersioneServizio()!=null && allarme.getFiltro().getVersioneServizio()>0) {
  21296.                         if(StringUtils.isNotEmpty(allarme.getFiltro().getTipoErogatore()) &&
  21297.                                 StringUtils.isNotEmpty(allarme.getFiltro().getNomeErogatore())) {
  21298.                             IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(allarme.getFiltro().getTipoServizio(), allarme.getFiltro().getNomeServizio(),
  21299.                                     allarme.getFiltro().getTipoErogatore(), allarme.getFiltro().getNomeErogatore(),
  21300.                                     allarme.getFiltro().getVersioneServizio());
  21301.                             AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idServizio,false);
  21302.                             AccordoServizioParteComuneSintetico aspc = this.apcCore.getAccordoServizioSintetico(this.idAccordoFactory.getIDAccordoFromUri(asps.getAccordoServizioParteComune()));
  21303.                             azioniConLabel = this.porteDelegateCore.getAzioniConLabel(asps, aspc, false, true, null);
  21304.                         }
  21305.                         else {
  21306.                             List<IDServizio> listServizi = this.confCore.getServizi(protocolloSelezionatoValue, protocolliValue,
  21307.                                     allarme.getFiltro().getTipoServizio(), allarme.getFiltro().getNomeServizio(), allarme.getFiltro().getVersioneServizio(), null);
  21308.                             List<String> uris = new ArrayList<>();
  21309.                             AccordoServizioParteSpecifica aspsRiferimento = null;
  21310.                             if(listServizi!=null && !listServizi.isEmpty()) {
  21311.                                 for (IDServizio idS : listServizi) {
  21312.                                     AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idS,false);
  21313.                                     if(!uris.contains(asps.getAccordoServizioParteComune())) {
  21314.                                         uris.add(asps.getAccordoServizioParteComune());
  21315.                                         if(aspsRiferimento==null) {
  21316.                                             aspsRiferimento = asps;
  21317.                                         }
  21318.                                     }
  21319.                                     if(uris.size()>1) {
  21320.                                         break;
  21321.                                     }
  21322.                                 }
  21323.                             }
  21324.                             if(uris.size()==1) {
  21325.                                 AccordoServizioParteComuneSintetico aspc = this.apcCore.getAccordoServizioSintetico(this.idAccordoFactory.getIDAccordoFromUri(uris.get(0)));
  21326.                                 azioniConLabel = this.porteDelegateCore.getAzioniConLabel(aspsRiferimento, aspc, false, true, null);
  21327.                             }
  21328.                         }
  21329.                     }
  21330.                     azioni = this.confCore.getAzioni(protocolloSelezionatoValue, protocolliValue,
  21331.                             allarme.getFiltro().getTipoErogatore(), allarme.getFiltro().getNomeErogatore(),
  21332.                             allarme.getFiltro().getTipoServizio(), allarme.getFiltro().getNomeServizio(), allarme.getFiltro().getVersioneServizio());
  21333.                 }
  21334.                 else if(delegata) {
  21335.                     IDPortaDelegata idPD = new IDPortaDelegata();
  21336.                     idPD.setNome(allarme.getFiltro().getNomePorta());
  21337.                     PortaDelegata pd = this.porteDelegateCore.getPortaDelegata(idPD);
  21338.                    
  21339.                     MappingFruizionePortaDelegata mappingPD = this.porteDelegateCore.getMappingFruizionePortaDelegata(pd);
  21340.                     IDServizio idServizio = mappingPD.getIdServizio();
  21341.                     AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idServizio,false);
  21342.                     AccordoServizioParteComuneSintetico aspc = this.apcCore.getAccordoServizioSintetico(this.idAccordoFactory.getIDAccordoFromUri(asps.getAccordoServizioParteComune()));
  21343.                    
  21344.                     if(pd.getAzione()!=null && pd.getAzione().sizeAzioneDelegataList()>0) {
  21345.                         azioni = pd.getAzione().getAzioneDelegataList();
  21346.                     }
  21347.                     else {
  21348.                         List<String> azioniAll = this.confCore.getAzioni(protocolloSelezionatoValue, protocolliValue,
  21349.                                 pd.getSoggettoErogatore().getTipo(), pd.getSoggettoErogatore().getNome(),
  21350.                                 pd.getServizio().getTipo(), pd.getServizio().getNome(), pd.getServizio().getVersione());
  21351.                        
  21352.                         IDSoggetto idSoggettoFruitore = mappingPD.getIdFruitore();
  21353.                         List<MappingFruizionePortaDelegata> listaMappingFruizione = this.apsCore.serviziFruitoriMappingList(idSoggettoFruitore, idServizio, null);
  21354.                         List<String> azioniOccupate = new ArrayList<>();
  21355.                         int listaMappingFruizioneSize = listaMappingFruizione != null ? listaMappingFruizione.size() : 0;
  21356.                         if(listaMappingFruizioneSize > 0) {
  21357.                             for (int i = 0; i < listaMappingFruizione.size(); i++) {
  21358.                                 MappingFruizionePortaDelegata mappingFruizionePortaDelegata = listaMappingFruizione.get(i);
  21359.                                 // colleziono le azioni gia' configurate
  21360.                                 PortaDelegata portaDelegataTmp = this.porteDelegateCore.getPortaDelegata(mappingFruizionePortaDelegata.getIdPortaDelegata());
  21361.                                 if(portaDelegataTmp.getAzione() != null && portaDelegataTmp.getAzione().getAzioneDelegataList() != null)
  21362.                                     azioniOccupate.addAll(portaDelegataTmp.getAzione().getAzioneDelegataList());
  21363.                             }
  21364.                         }
  21365.                        
  21366.                         azioni = new ArrayList<>();
  21367.                         for (int i = 0; i < azioniAll.size(); i++) {
  21368.                             String az = azioniAll.get(i);
  21369.                             if(azioniOccupate.contains(az)==false) {
  21370.                                 azioni.add(az);
  21371.                             }
  21372.                         }
  21373.                     }
  21374.                    
  21375.                     azioniConLabel = this.porteDelegateCore.getAzioniConLabel(asps, aspc, false, true, null);
  21376.                 }
  21377.                 else if(applicativa) {
  21378.                     IDPortaApplicativa idPA = new IDPortaApplicativa();
  21379.                     idPA.setNome(allarme.getFiltro().getNomePorta());
  21380.                     PortaApplicativa pa = this.porteApplicativeCore.getPortaApplicativa(idPA);
  21381.                     MappingErogazionePortaApplicativa mappingPA = this.porteApplicativeCore.getMappingErogazionePortaApplicativa(pa);
  21382.                     IDServizio idServizio = mappingPA.getIdServizio();
  21383.                     AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idServizio,false);
  21384.                     AccordoServizioParteComuneSintetico aspc = this.apcCore.getAccordoServizioSintetico(this.idAccordoFactory.getIDAccordoFromUri(asps.getAccordoServizioParteComune()));
  21385.                    
  21386.                     if(pa.getAzione()!=null && pa.getAzione().sizeAzioneDelegataList()>0) {
  21387.                         azioni = pa.getAzione().getAzioneDelegataList();
  21388.                     }
  21389.                     else {
  21390.                         List<String> azioniAll = this.confCore.getAzioni(protocolloSelezionatoValue, protocolliValue,
  21391.                                 pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario(),
  21392.                                 pa.getServizio().getTipo(), pa.getServizio().getNome(), pa.getServizio().getVersione());
  21393.                        
  21394.                         List<MappingErogazionePortaApplicativa> listaMappingErogazione = this.apsCore.mappingServiziPorteAppList(idServizio, null);
  21395.                         List<String> azioniOccupate = new ArrayList<>();
  21396.                         int listaMappingErogazioneSize = listaMappingErogazione != null ? listaMappingErogazione.size() : 0;
  21397.                         if(listaMappingErogazioneSize > 0) {
  21398.                             for (int i = 0; i < listaMappingErogazione.size(); i++) {
  21399.                                 MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa = listaMappingErogazione.get(i);
  21400.                                 // colleziono le azioni gia' configurate
  21401.                                 PortaApplicativa portaApplicativaTmp = this.porteApplicativeCore.getPortaApplicativa(mappingErogazionePortaApplicativa.getIdPortaApplicativa());
  21402.                                 if(portaApplicativaTmp.getAzione() != null && portaApplicativaTmp.getAzione().getAzioneDelegataList() != null)
  21403.                                     azioniOccupate.addAll(portaApplicativaTmp.getAzione().getAzioneDelegataList());
  21404.                             }
  21405.                         }
  21406.                        
  21407.                         azioni = new ArrayList<>();
  21408.                         for (int i = 0; i < azioniAll.size(); i++) {
  21409.                             String az = azioniAll.get(i);
  21410.                             if(azioniOccupate.contains(az)==false) {
  21411.                                 azioni.add(az);
  21412.                             }
  21413.                         }
  21414.                     }
  21415.                    
  21416.                     azioniConLabel = this.porteApplicativeCore.getAzioniConLabel(asps, aspc, false, true, null);
  21417.                 }
  21418.                 else {
  21419.                     azioni = new ArrayList<>();
  21420.                 }
  21421.                 if(allarme.getFiltro().getAzione()!=null && !"".equals(allarme.getFiltro().getAzione())){
  21422.                     azioniSelezionataValue = new ArrayList<>();
  21423.                     if(allarme.getFiltro().getAzione().contains(",")) {
  21424.                         String [] tmp = allarme.getFiltro().getAzione().split(",");
  21425.                         for (String az : tmp) {
  21426.                             if(azioni.contains(az)){
  21427.                                 azioniSelezionataValue.add(az);
  21428.                             }
  21429.                         }
  21430.                     }
  21431.                     else {
  21432.                         if(azioni.contains(allarme.getFiltro().getAzione())){
  21433.                             azioniSelezionataValue.add(allarme.getFiltro().getAzione());
  21434.                         }
  21435.                     }
  21436.                 }
  21437.                 if(azioniSelezionataValue==null || azioniSelezionataValue.isEmpty()) {
  21438.                     azioniSelezionataValue = null;
  21439.                 }
  21440.                 if(azioniConLabel!=null && azioniConLabel.size()>0) {
  21441.                     azioniLabel = new ArrayList<>();
  21442.                     azioniValue = new ArrayList<>();

  21443.                     for (String idAzione : azioniConLabel.keySet()) {
  21444.                         if(azioni.contains(idAzione)) {
  21445.                             azioniValue.add(idAzione);
  21446.                             azioniLabel.add(azioniConLabel.get(idAzione));
  21447.                         }
  21448.                     }
  21449.                    
  21450. //                  azioniLabel = enrichListConLabelQualsiasi(azioniLabel);
  21451. //                  azioniValue = enrichListConValueQualsiasi(azioniValue);
  21452.                 }
  21453.                 else {
  21454. //                  azioniLabel = enrichListConLabelQualsiasi(azioni);
  21455. //                  azioniValue = enrichListConValueQualsiasi(azioni);
  21456.                     azioniLabel = azioni;
  21457.                     azioniValue = azioni;
  21458.                 }
  21459.             }
  21460.                
  21461. //          // servizi applicativi erogatore
  21462. //          if(configurazione) {
  21463. //              if(ruoloPortaFiltro==null ||
  21464. //                      RuoloPorta.ENTRAMBI.equals(ruoloPortaFiltro) ||
  21465. //                      RuoloPorta.APPLICATIVA.equals(ruoloPortaFiltro)){
  21466. //                  if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  21467. //                      if(allarme.getFiltro().getServizioApplicativoErogatore()!=null){
  21468. //                          servizioApplicativoErogatoreSelezionatoValue = allarme.getFiltro().getServizioApplicativoErogatore();
  21469. //                      }
  21470. //                      servizioApplicativoErogatoreSelezionatoLabel = servizioApplicativoErogatoreSelezionatoValue!=null ? servizioApplicativoErogatoreSelezionatoValue :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  21471. //                  }
  21472. //                  else {
  21473. //                      serviziApplicativiErogatoreLabel = new ArrayList<>();
  21474. //                      serviziApplicativiErogatoreValue = new ArrayList<>();
  21475. //                      if(datiIdentificativiErogatoreSelezionatoValue!=null) {
  21476. //                          List<IDServizioApplicativo> listSA = this.confCore.getServiziApplicativiErogatori(protocolloSelezionatoValue, protocolliValue,
  21477. //                                  allarme.getFiltro().getTipoErogatore(), allarme.getFiltro().getNomeErogatore(),
  21478. //                                  allarme.getFiltro().getTipoServizio(), allarme.getFiltro().getNomeServizio(), allarme.getFiltro().getVersioneServizio(),
  21479. //                                  null);
  21480. //                          for (IDServizioApplicativo idServizioApplicativo : listSA) {
  21481. //                              serviziApplicativiErogatoreLabel.add(idServizioApplicativo.getNome());
  21482. //                              serviziApplicativiErogatoreValue.add(idServizioApplicativo.getNome());
  21483. //                          }
  21484. //                      }
  21485. //                      
  21486. //                      if(allarme.getFiltro().getServizioApplicativoErogatore()!=null){
  21487. //                          servizioApplicativoErogatoreSelezionatoValue = allarme.getFiltro().getServizioApplicativoErogatore();
  21488. //                      }
  21489. //                      if(!serviziApplicativiErogatoreValue.contains(servizioApplicativoErogatoreSelezionatoValue)){
  21490. //                          allarme.getFiltro().setServizioApplicativoErogatore(null);
  21491. //                          servizioApplicativoErogatoreSelezionatoValue = null;
  21492. //                      }
  21493. //                      serviziApplicativiErogatoreLabel = enrichListConLabelQualsiasi(serviziApplicativiErogatoreLabel);
  21494. //                      serviziApplicativiErogatoreValue = enrichListConValueQualsiasi(serviziApplicativiErogatoreValue);
  21495. //                  }
  21496. //              }
  21497. //          }
  21498.            
  21499.             // ruolo fruitore (diventa ruolo richiedente nel caso di porta)
  21500.             if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  21501.                 if(allarme.getFiltro().getRuoloFruitore()!=null) {
  21502.                     ruoloFruitoreSelezionatoValue = allarme.getFiltro().getRuoloFruitore();
  21503.                 }
  21504.                 ruoloFruitoreSelezionatoLabel = ruoloFruitoreSelezionatoValue!=null ? ruoloFruitoreSelezionatoValue :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  21505.             }
  21506.             else {
  21507.                 List<String> ruoliFruitore = this.core.getAllRuoli(filtroRuoli);
  21508.                 if(allarme.getFiltro().getRuoloFruitore()!=null) {
  21509.                     ruoloFruitoreSelezionatoValue = allarme.getFiltro().getRuoloFruitore();
  21510.                 }
  21511.                 if(!ruoliFruitore.contains(ruoloFruitoreSelezionatoValue)){
  21512.                     allarme.getFiltro().setRuoloFruitore(null);
  21513.                     ruoloFruitoreSelezionatoValue = null;
  21514.                 }
  21515.                 ruoliFruitoreLabel = enrichListConLabelQualsiasi(ruoliFruitore);
  21516.                 ruoliFruitoreValue = enrichListConValueQualsiasi(ruoliFruitore);
  21517.             }
  21518.            
  21519.             // fruitore
  21520.             if(configurazione || applicativa) {
  21521.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  21522.                     IDSoggetto idSoggetto = null;
  21523.                     if(allarme.getFiltro().getTipoFruitore()!=null && allarme.getFiltro().getNomeFruitore()!=null){
  21524.                         datiIdentificativiFruitoreSelezionatoValue = allarme.getFiltro().getTipoFruitore() + "/" + allarme.getFiltro().getNomeFruitore();
  21525.                         idSoggetto = new IDSoggetto(allarme.getFiltro().getTipoFruitore() , allarme.getFiltro().getNomeFruitore());
  21526.                     }
  21527.                     datiIdentificativiFruitoreSelezionatoLabel = idSoggetto!=null ? this.getLabelNomeSoggetto(idSoggetto) :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  21528.                 }
  21529.                 else {
  21530. //                  List<IDSoggetto> listFruitori = this.confCore.getSoggettiFruitori(protocolloSelezionatoValue, protocolliValue,
  21531. //                          policy.getFiltro().getTipoErogatore(), policy.getFiltro().getNomeErogatore(),
  21532. //                          policy.getFiltro().getTipoServizio(), policy.getFiltro().getNomeServizio(), policy.getFiltro().getVersioneServizio());
  21533.                    
  21534.                     List<IDSoggetto> listSoggetti = new ArrayList<>();
  21535.                     if(configurazione) {
  21536.                         List<IDSoggetto> listSoggettiPreFilterMultitenant = this.confCore.getSoggetti(protocolloSelezionatoValue, protocolliValue);
  21537.                         if(ruoloPortaFiltro!=null && !RuoloPorta.ENTRAMBI.equals(ruoloPortaFiltro)) {
  21538.                             for (IDSoggetto idSoggetto : listSoggettiPreFilterMultitenant) {
  21539.                                 Soggetto s = this.soggettiCore.getSoggettoRegistro(idSoggetto);
  21540.                                 boolean isPddEsterna = this.pddCore.isPddEsterna(s.getPortaDominio());
  21541.                                 if(RuoloPorta.APPLICATIVA.equals(ruoloPortaFiltro)) {
  21542.                                     if(isPddEsterna) {
  21543.                                         listSoggetti.add(idSoggetto);
  21544.                                     }  
  21545.                                     else {
  21546.                                         if(!PddTipologia.ESTERNO.equals(pddTipologiaSoggettoAutenticati)) {
  21547.                                             // multitenant abilitato
  21548.                                             listSoggetti.add(idSoggetto);
  21549.                                         }
  21550.                                     }
  21551.                                 }
  21552.                                 else {
  21553.                                     if(!isPddEsterna) {
  21554.                                         listSoggetti.add(idSoggetto);
  21555.                                     }
  21556.                                 }
  21557.                             }
  21558.                         }
  21559.                         else {
  21560.                             listSoggetti.addAll(listSoggettiPreFilterMultitenant);
  21561.                         }
  21562.                     }
  21563.                     else {
  21564.                    
  21565.                         User user = ServletUtils.getUserFromSession(this.request, this.session);
  21566.                         String userLogin = user.getLogin();
  21567.                        
  21568.                         List<String> tipiSoggettiGestitiProtocollo = this.soggettiCore.getTipiSoggettiGestitiProtocollo(protocolloSelezionatoValue);
  21569.                        
  21570.                         List<IDSoggettoDB> list = null;
  21571.                         if(this.core.isVisioneOggettiGlobale(userLogin)){
  21572.                             list = this.soggettiCore.getSoggettiFromTipoAutenticazione(tipiSoggettiGestitiProtocollo, null, tipoAutenticazione, appId, pddTipologiaSoggettoAutenticati);
  21573.                         }else{
  21574.                             list = this.soggettiCore.getSoggettiFromTipoAutenticazione(tipiSoggettiGestitiProtocollo, userLogin, tipoAutenticazione, appId, pddTipologiaSoggettoAutenticati);
  21575.                         }
  21576.                         if(list!=null && !list.isEmpty() && gestioneErogatori_soggettiAutenticati_escludiSoggettoErogatore) {
  21577.                             for (int i = 0; i < list.size(); i++) {
  21578.                                 IDSoggettoDB soggettoCheck = list.get(i);
  21579.                                 if(soggettoCheck.getTipo().equals(idSoggettoProprietario.getTipo()) && soggettoCheck.getNome().equals(idSoggettoProprietario.getNome())) {
  21580.                                     list.remove(i);
  21581.                                     break;
  21582.                                 }
  21583.                             }
  21584.                         }
  21585.                        
  21586.                         if(list==null) {
  21587.                             list = new ArrayList<>();
  21588.                         }
  21589.                        
  21590.                         // soggetti esterni
  21591.                         boolean isSupportatoAutenticazioneApplicativiEsterni = false;
  21592.                         if(protocolloSelezionatoValue!=null && !"".equals(protocolloSelezionatoValue)) {
  21593.                             isSupportatoAutenticazioneApplicativiEsterni = this.saCore.isSupportatoAutenticazioneApplicativiEsterniErogazione(protocolloSelezionatoValue);
  21594.                         }
  21595.                                                                        
  21596.                         // multitenant: aggiungo soggetti operativi per poi poter selezionare un applicativo
  21597.                         // isSupportatoAutenticazioneApplicativiEsterni: aggiungo i soggettti che possiedono applicativi esterno
  21598.                         if(isSupportatoAutenticazioneApplicativiEsterni || multitenant) {

  21599.                             List<IDSoggetto> listSoggettiPreFilterMultitenant = this.confCore.getSoggetti(protocolloSelezionatoValue, protocolliValue);
  21600.                             for (IDSoggetto idSoggetto : listSoggettiPreFilterMultitenant) {
  21601.                                 Soggetto s = this.soggettiCore.getSoggettoRegistro(idSoggetto);
  21602.                                 boolean isPddEsterna = this.pddCore.isPddEsterna(s.getPortaDominio());
  21603.                                
  21604.                                 boolean found = false;
  21605.                                 if( (multitenant && !isPddEsterna)
  21606.                                         ||
  21607.                                     (isSupportatoAutenticazioneApplicativiEsterni && isPddEsterna)) {
  21608.                                     for (IDSoggettoDB sogg : list) {
  21609.                                         if(sogg.getTipo().equals(s.getTipo()) && sogg.getNome().equals(s.getNome())) {
  21610.                                             found = true;
  21611.                                             break;
  21612.                                         }
  21613.                                     }                                  
  21614.                                 }
  21615.                                
  21616.                                 boolean bothSslAndToken = false;
  21617.                                
  21618.                                 if(!found && multitenant && !isPddEsterna) {
  21619.                                     List<IDServizioApplicativoDB> listServiziApplicativiTmp = this.saCore.soggettiServizioApplicativoList(idSoggetto,userLogin,tipoAutenticazioneConfig, appId,
  21620.                                             CostantiConfigurazione.CLIENT,
  21621.                                             bothSslAndToken, tokenPolicy, tokenPolicyOR);
  21622.                                     if(listServiziApplicativiTmp!=null && !listServiziApplicativiTmp.isEmpty()) {
  21623.                                         IDSoggettoDB idSoggettoDB = new IDSoggettoDB();
  21624.                                         idSoggettoDB.setTipo(s.getTipo());
  21625.                                         idSoggettoDB.setNome(s.getNome());
  21626.                                         idSoggettoDB.setCodicePorta(s.getIdentificativoPorta());
  21627.                                         idSoggettoDB.setId(s.getId());
  21628.                                         list.add(idSoggettoDB);
  21629.                                     }
  21630.                                 }
  21631.                                
  21632.                                 if(!found && isSupportatoAutenticazioneApplicativiEsterni && isPddEsterna) {
  21633.                                     List<IDServizioApplicativoDB> listServiziApplicativiTmp = this.saCore.soggettiServizioApplicativoList(idSoggetto,userLogin,tipoAutenticazioneConfig, appId,
  21634.                                             CostantiConfigurazione.CLIENT,
  21635.                                             bothSslAndToken, tokenPolicy, tokenPolicyOR);
  21636.                                     if(listServiziApplicativiTmp!=null && !listServiziApplicativiTmp.isEmpty()) {
  21637.                                         IDSoggettoDB idSoggettoDB = new IDSoggettoDB();
  21638.                                         idSoggettoDB.setTipo(s.getTipo());
  21639.                                         idSoggettoDB.setNome(s.getNome());
  21640.                                         idSoggettoDB.setCodicePorta(s.getIdentificativoPorta());
  21641.                                         idSoggettoDB.setId(s.getId());
  21642.                                         list.add(idSoggettoDB);
  21643.                                     }
  21644.                                 }
  21645.                                
  21646.                             }
  21647.                         }
  21648.                        
  21649.                         if(!list.isEmpty()) {
  21650.                             for (IDSoggettoDB soggetto : list) {
  21651.                                 listSoggetti.add(new IDSoggetto(soggetto.getTipo(), soggetto.getNome()));
  21652.                             }
  21653.                         }
  21654.                        
  21655.                     }
  21656.                    
  21657.                     fruitoriLabel = new ArrayList<>();
  21658.                     fruitoriValue = new ArrayList<>();
  21659.                     for (IDSoggetto idSoggetto : listSoggetti) {
  21660.                         fruitoriLabel.add(this.getLabelNomeSoggetto(idSoggetto));
  21661.                         fruitoriValue.add(idSoggetto.getTipo()+"/"+idSoggetto.getNome());
  21662.                     }
  21663.                     if(allarme.getFiltro().getTipoFruitore()!=null && allarme.getFiltro().getNomeFruitore()!=null){
  21664.                         datiIdentificativiFruitoreSelezionatoValue = allarme.getFiltro().getTipoFruitore() + "/" + allarme.getFiltro().getNomeFruitore();
  21665.                     }
  21666.                     if(!fruitoriValue.contains(datiIdentificativiFruitoreSelezionatoValue)){
  21667.                         allarme.getFiltro().setTipoFruitore(null);
  21668.                         allarme.getFiltro().setNomeFruitore(null);
  21669.                         datiIdentificativiFruitoreSelezionatoValue = null;
  21670.                     }
  21671.                     fruitoriLabel = enrichListConLabelQualsiasi(fruitoriLabel);
  21672.                     fruitoriValue = enrichListConValueQualsiasi(fruitoriValue);
  21673.                 }
  21674.             }
  21675.             else {
  21676.                 if(delegata) {
  21677.                     if(allarme.getFiltro().getTipoFruitore()!=null && allarme.getFiltro().getNomeFruitore()!=null){
  21678.                         datiIdentificativiFruitoreSelezionatoValue = allarme.getFiltro().getTipoFruitore() + "/" + allarme.getFiltro().getNomeFruitore();
  21679.                     }
  21680.                 }
  21681.             }
  21682.            
  21683.             // servizi applicativi fruitore
  21684.             if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  21685.                 if(allarme.getFiltro().getServizioApplicativoFruitore()!=null){
  21686.                     servizioApplicativoFruitoreSelezionatoValue = allarme.getFiltro().getServizioApplicativoFruitore();
  21687.                 }
  21688.                 servizioApplicativoFruitoreSelezionatoLabel = servizioApplicativoFruitoreSelezionatoValue!=null ? servizioApplicativoFruitoreSelezionatoValue :  ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI;
  21689.             }
  21690.             else {
  21691.                
  21692.                 IDSoggetto soggettoProprietarioServiziApplicativi = null;
  21693.                 if(datiIdentificativiFruitoreSelezionatoValue!=null || !configurazione) {
  21694.                     String tipoFruitore = null;
  21695.                     String nomeFruitore = null;
  21696.                     if(datiIdentificativiFruitoreSelezionatoValue!=null) {
  21697.                         tipoFruitore = allarme.getFiltro().getTipoFruitore();
  21698.                         nomeFruitore = allarme.getFiltro().getNomeFruitore();
  21699.                     }
  21700.                     else {
  21701.                         tipoFruitore = idSoggettoProprietario.getTipo();
  21702.                         nomeFruitore = idSoggettoProprietario.getNome();
  21703.                     }
  21704.                     soggettoProprietarioServiziApplicativi = new IDSoggetto(tipoFruitore, nomeFruitore);
  21705.                 }
  21706.                
  21707.                 if(soggettoProprietarioServiziApplicativi!=null) {
  21708.                     serviziApplicativiFruitoreLabel = new ArrayList<>();
  21709.                     serviziApplicativiFruitoreValue = new ArrayList<>();

  21710.                     List<IDServizioApplicativo> listSA =null;
  21711.                     if(configurazione) {
  21712.                         listSA = this.confCore.getServiziApplicativiFruitore(protocolloSelezionatoValue, protocolliValue,
  21713.                                 soggettoProprietarioServiziApplicativi.getTipo(), soggettoProprietarioServiziApplicativi.getNome());
  21714.                     }
  21715.                     else {
  21716.                        
  21717.                         listSA = new ArrayList<>();
  21718.                        
  21719.                         User user = ServletUtils.getUserFromSession(this.request, this.session);
  21720.                         String userLogin = user.getLogin();
  21721.                        
  21722.                         // soggetti esterni
  21723.                         boolean isSupportatoAutenticazioneApplicativiEsterni = false;
  21724.                         if(protocolloSelezionatoValue!=null && !"".equals(protocolloSelezionatoValue)) {
  21725.                             isSupportatoAutenticazioneApplicativiEsterni = this.saCore.isSupportatoAutenticazioneApplicativiEsterniErogazione(protocolloSelezionatoValue);
  21726.                         }
  21727.                        
  21728.                         boolean bothSslAndToken = false;
  21729.                        
  21730.                         List<IDServizioApplicativoDB> listServiziApplicativiTmp = null;
  21731.                         if(delegata || !multitenant) {
  21732.                             listServiziApplicativiTmp = this.saCore.soggettiServizioApplicativoList(idSoggettoProprietario,userLogin,tipoAutenticazioneConfig,appId,
  21733.                                     CostantiConfigurazione.CLIENT,
  21734.                                     bothSslAndToken, tokenPolicy, tokenPolicyOR);
  21735.                         }
  21736.                         else {
  21737.                             // sull'applicativa con multitenant deve essere stata selezionato un soggetto operativo.
  21738.                             if(allarme.getFiltro().getTipoFruitore()!=null && allarme.getFiltro().getNomeFruitore()!=null) {
  21739.                                 IDSoggetto idSoggettoSelezionato = new IDSoggetto(allarme.getFiltro().getTipoFruitore(), allarme.getFiltro().getNomeFruitore());
  21740.                                 Soggetto s = this.soggettiCore.getSoggettoRegistro(idSoggettoSelezionato);
  21741.                                 boolean isPddEsterna = this.pddCore.isPddEsterna(s.getPortaDominio());
  21742.                                 if(!isPddEsterna || isSupportatoAutenticazioneApplicativiEsterni) {
  21743.                                     listServiziApplicativiTmp = this.saCore.soggettiServizioApplicativoList(idSoggettoSelezionato,userLogin,tipoAutenticazioneConfig,appId,
  21744.                                             CostantiConfigurazione.CLIENT,
  21745.                                             bothSslAndToken, tokenPolicy, tokenPolicyOR);
  21746.                                 }                                  
  21747.                             }
  21748.                         }
  21749.                        
  21750.                         if(listServiziApplicativiTmp!=null && !listServiziApplicativiTmp.isEmpty()) {
  21751.                             for (IDServizioApplicativoDB servizioApplicativo : listServiziApplicativiTmp) {
  21752.                                 IDServizioApplicativo idSA = new IDServizioApplicativo();
  21753.                                 idSA.setIdSoggettoProprietario(idSoggettoProprietario);
  21754.                                 idSA.setNome(servizioApplicativo.getNome());
  21755.                                 listSA.add(idSA);
  21756.                             }
  21757.                         }
  21758.                        
  21759.                     }
  21760.                     for (IDServizioApplicativo idServizioApplicativo : listSA) {
  21761.                         serviziApplicativiFruitoreLabel.add(idServizioApplicativo.getNome());
  21762.                         serviziApplicativiFruitoreValue.add(idServizioApplicativo.getNome());
  21763.                     }
  21764.                    
  21765.                     if(allarme.getFiltro().getServizioApplicativoFruitore()!=null){
  21766.                         servizioApplicativoFruitoreSelezionatoValue = allarme.getFiltro().getServizioApplicativoFruitore();
  21767.                     }
  21768.                     if(!serviziApplicativiFruitoreValue.contains(servizioApplicativoFruitoreSelezionatoValue)){
  21769.                         allarme.getFiltro().setServizioApplicativoFruitore(null);
  21770.                         servizioApplicativoFruitoreSelezionatoValue = null;
  21771.                     }
  21772.                     serviziApplicativiFruitoreLabel = enrichListConLabelQualsiasi(serviziApplicativiFruitoreLabel);
  21773.                     serviziApplicativiFruitoreValue = enrichListConValueQualsiasi(serviziApplicativiFruitoreValue);
  21774.                 }
  21775.             }
  21776.            
  21777.         }

  21778.        
  21779.        
  21780.        
  21781.         DataElement de = new DataElement();
  21782.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILTRO);
  21783.         de.setType(DataElementType.TITLE);
  21784.         dati.add(de);
  21785.        
  21786.         boolean filtroAbilitatoAPI = false;
  21787.         if(ruoloPorta!=null) {
  21788.             boolean first = this.isFirstTimeFromHttpParameters(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FIRST_TIME);
  21789.             if(first) {
  21790.                 String filtro = this.toStringCompactAllarmeFilter(allarme.getFiltro(),ruoloPorta,nomePorta,serviceBinding);
  21791.                 filtroAbilitatoAPI = filtro!=null && !"".equals(filtro) && !CostantiControlStation.LABEL_STATO_DISABILITATO.equals(filtro);
  21792.             }
  21793.             else {
  21794.                 String filtro = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_ENABLED_CONSOLE_ONLY);
  21795.                 filtroAbilitatoAPI = ServletUtils.isCheckBoxEnabled(filtro);
  21796.             }
  21797.         }
  21798.        
  21799.         // stato
  21800.         if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  21801.            
  21802.             addToDatiDataElementStatoReadOnly(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_ENABLED,
  21803.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_ENABLED, allarme.getFiltro().isEnabled(), true,
  21804.                     false, false);
  21805.              
  21806.             if(allarme.getFiltro().isEnabled()){
  21807.                 de = new DataElement();
  21808.                 de.setType(DataElementType.NOTE);
  21809.                 de.setValue("Filtro non modificabile poichè definito per un "+CostantiControlStation.LABEL_PARAMETRO_PROTOCOLLO_DI.toLowerCase()+" non attivo nella console");
  21810.                 dati.add(de);
  21811.             }
  21812.         }
  21813.         else {
  21814.             boolean hidden = ruoloPorta!=null;
  21815.             addToDatiDataElementStato_postBackViaPOST(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_ENABLED,
  21816.                     ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_ENABLED, (allarme!=null && allarme.getFiltro()!=null && allarme.getFiltro().isEnabled()), true,
  21817.                     false, false, hidden);
  21818.            
  21819.             if(ruoloPorta!=null) {
  21820.                 addToDatiDataElementStato_postBackViaPOST(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_ENABLED_CONSOLE_ONLY,
  21821.                         ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_ENABLED, filtroAbilitatoAPI, true,
  21822.                         false, false, false);
  21823.             }
  21824.            
  21825.         }
  21826.        
  21827.         boolean filtroEnabled = allarme!=null && allarme.getFiltro()!=null && allarme.getFiltro().isEnabled();
  21828.         if(ruoloPorta!=null) {
  21829.             filtroEnabled = filtroAbilitatoAPI;
  21830.         }
  21831.        
  21832.         if(!filtroEnabled && ruoloPorta!=null) {
  21833.             // Protocollo
  21834.             de = new DataElement();
  21835.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PROTOCOLLO);
  21836.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PROTOCOLLO);
  21837.             de.setValue(protocolloSelezionatoValue); // un protocollo e' sempre selezionato
  21838.             de.setType(DataElementType.HIDDEN);
  21839.             dati.add(de);
  21840.         }
  21841.        
  21842.         if(filtroEnabled){
  21843.        
  21844.             // Ruolo PdD
  21845.             de = new DataElement();
  21846.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_PDD);
  21847.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_PDD);
  21848.             if(ruoloPortaFiltro!=null){
  21849.                 de.setValue(ruoloPortaFiltro.getValue());
  21850.             }
  21851.             if(filterConfig!=null && filterConfig.isHideGatewayRole()) {
  21852.                 de.setType(DataElementType.HIDDEN);
  21853.                 dati.add(de);
  21854.             }
  21855.             else if(configurazione && filterConfig!=null &&
  21856.                     (filterConfig.isForceInGatewayRole() || filterConfig.isForceOutGatewayRole())) {
  21857.                 de.setType(DataElementType.HIDDEN);
  21858.                 dati.add(de);
  21859.             }
  21860.             else if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  21861.                 de.setType(DataElementType.HIDDEN);
  21862.                 dati.add(de);
  21863.                
  21864.                 if(configurazione) {
  21865.                     de = new DataElement();
  21866.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_PDD+"___LABEL");
  21867.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_PDD);
  21868.                     if(ruoloPortaFiltro!=null){
  21869.                         de.setValue(ruoloPortaFiltro.getValue());
  21870.                     }
  21871.                     else {
  21872.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING_QUALSIASI);
  21873.                     }
  21874.                     de.setType(DataElementType.TEXT);
  21875.                 }
  21876.             }
  21877.             else {
  21878.                 de.setValues(ConfigurazioneCostanti.TIPI_RUOLO_PDD);
  21879.                 de.setLabels(ConfigurazioneCostanti.LABEL_TIPI_RUOLO_PDD);
  21880.                 if(ruoloPortaFiltro!=null){
  21881.                     de.setSelected(ruoloPortaFiltro.getValue());
  21882.                 }
  21883.                 de.setType(DataElementType.SELECT);
  21884.                 de.setPostBack_viaPOST(true);
  21885.             }
  21886.             dati.add(de);
  21887.            
  21888.    
  21889.             // Protocollo
  21890.             de = new DataElement();
  21891.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PROTOCOLLO);
  21892.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PROTOCOLLO);
  21893.             de.setValue(protocolloSelezionatoValue); // un protocollo e' sempre selezionato
  21894.             if(filterConfig!=null && filterConfig.isHideProtocol()) {
  21895.                 de.setType(DataElementType.HIDDEN);
  21896.                 dati.add(de);
  21897.             }
  21898.             else if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  21899.                 de.setType(DataElementType.HIDDEN);
  21900.                 dati.add(de);
  21901.                
  21902.                 if(configurazione) {
  21903.                     de = new DataElement();
  21904.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PROTOCOLLO+"___LABEL");
  21905.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PROTOCOLLO);
  21906.                     de.setValue(protocolloSelezionatoLabel); // un protocollo e' sempre selezionato
  21907.                     de.setType(DataElementType.TEXT);
  21908.                 }
  21909.             }
  21910.             else if(protocolliValue!=null && protocolliValue.size()>1){
  21911.                 de.setValues(protocolliValue);
  21912.                 de.setLabels(protocolliLabel);
  21913.                 de.setSelected(protocolloSelezionatoValue);
  21914.                 de.setType(DataElementType.SELECT);
  21915.                 de.setPostBack_viaPOST(true);
  21916.             }
  21917.             else{
  21918.                 de.setType(DataElementType.HIDDEN);
  21919.                 if(protocolliValue!=null && protocolliValue.size()>0) {
  21920.                     dati.add(de);
  21921.                    
  21922.                     // Si è deciso cmq di farlo vedere
  21923.                     de = new DataElement();
  21924.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PROTOCOLLO+"___LABEL");
  21925.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PROTOCOLLO);
  21926.                     de.setValue(this.getLabelProtocollo(protocolliValue.get(0))); // un protocollo e' sempre selezionato
  21927.                     de.setType(DataElementType.TEXT);
  21928.                 }
  21929.             }
  21930.             dati.add(de);
  21931.            
  21932.             // Ruolo Erogatore
  21933.             de = new DataElement();
  21934.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_EROGATORE);
  21935.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_EROGATORE);
  21936.             if(filterConfig!=null && filterConfig.isHideProviderRole()) {
  21937.                 de.setType(DataElementType.HIDDEN);
  21938.             }
  21939.             else if(datiIdentificativiErogatoreSelezionatoValue!=null) {
  21940.                 de.setType(DataElementType.HIDDEN);
  21941.             }
  21942.             else {
  21943.                 de.setValue(ruoloErogatoreSelezionatoValue);
  21944.                 if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  21945.                     de.setType(DataElementType.HIDDEN);
  21946.                     dati.add(de);
  21947.                    
  21948.                     if(configurazione) {
  21949.                         de = new DataElement();
  21950.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_EROGATORE+"___LABEL");
  21951.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_EROGATORE);
  21952.                         de.setValue(ruoloErogatoreSelezionatoLabel);
  21953.                         de.setType(DataElementType.TEXT);
  21954.                     }
  21955.                 }
  21956.                 else {
  21957.                     de.setLabels(ruoliErogatoreLabel);
  21958.                     de.setValues(ruoliErogatoreValue);
  21959.                     de.setSelected(ruoloErogatoreSelezionatoValue);
  21960.                     de.setType(DataElementType.SELECT);
  21961.                     de.setPostBack_viaPOST(true);
  21962.                 }
  21963.             }
  21964.             dati.add(de);
  21965.            
  21966.             // Erogatore
  21967.             de = new DataElement();
  21968.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_EROGATORE);
  21969.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_EROGATORE);
  21970.             if(filterConfig!=null && filterConfig.isHideProvider()) {
  21971.                 de.setType(DataElementType.HIDDEN);
  21972.             }
  21973.             else if(ruoloErogatoreSelezionatoValue!=null) {
  21974.                 de.setType(DataElementType.HIDDEN);
  21975.             }
  21976.             else {
  21977.                 de.setValue(datiIdentificativiErogatoreSelezionatoValue);
  21978.                 if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  21979.                     de.setType(DataElementType.HIDDEN);
  21980.                     dati.add(de);
  21981.                    
  21982.                     if(configurazione) {
  21983.                         de = new DataElement();
  21984.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_EROGATORE+"___LABEL");
  21985.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_EROGATORE);
  21986.                         de.setValue(datiIdentificativiErogatoreSelezionatoLabel);
  21987.                         de.setType(DataElementType.TEXT);
  21988.                     }
  21989.                 }
  21990.                 else {
  21991.                     de.setLabels(erogatoriLabel);
  21992.                     de.setValues(erogatoriValue);
  21993.                     de.setSelected(datiIdentificativiErogatoreSelezionatoValue);
  21994.                     de.setType(DataElementType.SELECT);
  21995.                     de.setPostBack_viaPOST(true);
  21996.                 }
  21997.             }
  21998.             dati.add(de);
  21999.            
  22000.             // Tag
  22001.             de = new DataElement();
  22002.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_TAG);
  22003.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_TAG);
  22004.             de.setValue(datiIdentificativiTagSelezionatoValue);
  22005.             boolean allarmiFiltroApi = this.core.getAllarmiConfig().isOptionsFilterApi();
  22006.             if(filterConfig!=null && filterConfig.isHideTag()) {
  22007.                 de.setType(DataElementType.HIDDEN);
  22008.                 dati.add(de);
  22009.             }
  22010.             else if(!configurazione) {
  22011.                 de.setType(DataElementType.HIDDEN);
  22012.                 dati.add(de);
  22013.             }
  22014.             else {
  22015.                 de.setValue(datiIdentificativiTagSelezionatoValue);
  22016.                 if(allarmiFiltroApi && datiIdentificativiServizioSelezionatoValue==null ) {
  22017.                     de.setLabels(tagLabel);
  22018.                     de.setValues(tagValue);
  22019.                     de.setSelected(datiIdentificativiTagSelezionatoValue);
  22020.                     de.setType(DataElementType.SELECT);
  22021.                     de.setPostBack_viaPOST(true);
  22022.                 }
  22023.                 else {
  22024.                     de.setType(DataElementType.HIDDEN);
  22025.                 }
  22026.             }
  22027.             dati.add(de);
  22028.            
  22029.             // Servizio
  22030.             de = new DataElement();
  22031.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SERVIZIO);
  22032.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SERVIZIO);
  22033.             de.setValue(datiIdentificativiServizioSelezionatoValue);
  22034.             if(filterConfig!=null && filterConfig.isHideService()) {
  22035.                 de.setType(DataElementType.HIDDEN);
  22036.                 dati.add(de);
  22037.             }
  22038.             else if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  22039.                 de.setType(DataElementType.HIDDEN);
  22040.                 dati.add(de);
  22041.                
  22042.                 if(configurazione) {
  22043.                     de = new DataElement();
  22044.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SERVIZIO+"___LABEL");
  22045.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SERVIZIO);
  22046.                     de.setValue(datiIdentificativiServizioSelezionatoLabel);
  22047.                     if(allarmiFiltroApi) {
  22048.                         de.setType(DataElementType.TEXT);
  22049.                     }
  22050.                     else {
  22051.                         de.setType(DataElementType.HIDDEN);
  22052.                     }
  22053.                 }
  22054.             }
  22055.             else {
  22056.                 de.setValue(datiIdentificativiServizioSelezionatoValue);
  22057.                 if(allarmiFiltroApi) {
  22058.                     de.setLabels(serviziLabel);
  22059.                     de.setValues(serviziValue);
  22060.                     de.setSelected(datiIdentificativiServizioSelezionatoValue);
  22061.                     de.setType(DataElementType.SELECT);
  22062.                     de.setPostBack_viaPOST(true);
  22063.                 }
  22064.                 else {
  22065.                     de.setType(DataElementType.HIDDEN);
  22066.                 }
  22067.             }
  22068.             dati.add(de);
  22069.            
  22070.             // Azione
  22071.             boolean showAzione = true;
  22072.             if(configurazione) {
  22073.                 if(filterConfig!=null && filterConfig.isHideAction()) {
  22074.                     showAzione = false;
  22075.                 }
  22076.                 else if(datiIdentificativiServizioSelezionatoValue==null) {
  22077.                     showAzione = false;
  22078.                 }
  22079.             }
  22080.             else {
  22081.                 if(filterConfig!=null && filterConfig.isHideAction()) {
  22082.                     showAzione = false;
  22083.                 }
  22084.             }
  22085.             if(showAzione) {
  22086.                
  22087.                 boolean azioniAll = false;
  22088.                 boolean first = this.isFirstTimeFromHttpParameters(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FIRST_TIME);
  22089.                 if(first) {
  22090.                     azioniAll = azioniSelezionataValue==null || azioniSelezionataValue.isEmpty();
  22091.                 }
  22092.                 else if(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SERVIZIO.equals(this.getPostBackElementName()) ||
  22093.                         ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_ENABLED_CONSOLE_ONLY.equals(this.getPostBackElementName())) {
  22094.                     azioniAll = true;
  22095.                 }
  22096.                 else {
  22097.                     String azioniAllPart = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE_PUNTUALE);
  22098.                     azioniAll = ServletUtils.isCheckBoxEnabled(azioniAllPart);
  22099.                 }
  22100.                
  22101.                 if(!protocolloAssociatoFiltroNonSelezionatoUtente) {
  22102.                     de = new DataElement();
  22103.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE_PUNTUALE);
  22104.                     de.setPostBack_viaPOST(true);
  22105.                     de.setValues(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE_PUNTUALE_ALL_VALUES);
  22106.                     if(ServiceBinding.REST.equals(serviceBinding)) {
  22107.                         de.setLabels(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE_PUNTUALE_RISORSE_ALL_VALUES);
  22108.                     }
  22109.                     else {
  22110.                         de.setLabels(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE_PUNTUALE_ALL_VALUES);
  22111.                     }
  22112.                     if(azioniAll) {
  22113.                         de.setSelected(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE_PUNTUALE_ALL_VALUE_TRUE);
  22114.                     }
  22115.                     else {
  22116.                         de.setSelected(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE_PUNTUALE_ALL_VALUE_FALSE);
  22117.                     }
  22118.                     if(serviceBinding!=null) {
  22119.                         de.setLabel(this.getLabelAzioni(serviceBinding));
  22120.                     }
  22121.                     else {
  22122.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE);
  22123.                     }
  22124.                     de.setType(DataElementType.SELECT);
  22125.                     dati.add(de);
  22126.                 }
  22127.                
  22128.                 de = new DataElement();
  22129.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE);
  22130.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  22131.                     if(serviceBinding!=null) {
  22132.                         de.setLabel(this.getLabelAzioni(serviceBinding));
  22133.                     }
  22134.                     else {
  22135.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE);
  22136.                     }
  22137.                 }
  22138.                 else {
  22139.                     de.setLabel("");
  22140.                 }
  22141.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  22142.                     de.setValue(allarme.getFiltro().getAzione());
  22143.                     de.setType(DataElementType.HIDDEN);
  22144.                     dati.add(de);
  22145.                    
  22146.                     de = new DataElement();
  22147.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE+"___LABEL");
  22148.                     if(serviceBinding!=null) {
  22149.                         de.setLabel(this.getLabelAzioni(serviceBinding));
  22150.                     }
  22151.                     else {
  22152.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_AZIONE);
  22153.                     }
  22154.                     if(azioniSelezionataLabel!=null && !azioniSelezionataLabel.isEmpty()) {
  22155.                         if(azioniSelezionataLabel.size()==1) {
  22156.                             de.setValue(azioniSelezionataLabel.get(0));
  22157.                         }
  22158.                         else {
  22159.                             de.setValue(azioniSelezionataLabel.toString());
  22160.                         }
  22161.                     }
  22162.                     de.setType(DataElementType.TEXT);
  22163.                 }
  22164.                 else {
  22165.                     if(!azioniAll) {
  22166.                         de.setLabels(azioniLabel);
  22167.                         de.setValues(azioniValue);
  22168.                         de.setSelezionati(azioniSelezionataValue);
  22169.                         de.setType(DataElementType.MULTI_SELECT);
  22170.                         if(azioniValue!=null && azioniValue.size()<=10) {
  22171.                             if(azioniValue.size()<=3) {
  22172.                                 de.setRows(3);
  22173.                             }
  22174.                             else {
  22175.                                 de.setRows(azioniValue.size());
  22176.                             }
  22177.                         }
  22178.                         else {
  22179.                             de.setRows(10);
  22180.                         }
  22181.                         de.setPostBack_viaPOST(true);
  22182.                     }
  22183.                     else {
  22184.                         de.setType(DataElementType.HIDDEN);
  22185.                     }
  22186.                 }
  22187.                 dati.add(de);
  22188.             }
  22189.            
  22190. //          // Servizio Applicativo Erogatore
  22191. //          if(serviziApplicativiErogatoreValue!=null){
  22192. //              de = new DataElement();
  22193. //              de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_EROGATORE);
  22194. //              de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_EROGATORE);
  22195. //              de.setValue(servizioApplicativoErogatoreSelezionatoValue);
  22196. //              if(protocolloAssociatoFiltroNonSelezionatoUtente || !configurazione) {
  22197. //                  de.setType(DataElementType.HIDDEN);
  22198. //                  dati.add(de);
  22199. //                  
  22200. //                  if(configurazione) {
  22201. //                      de = new DataElement();
  22202. //                      de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_EROGATORE+"___LABEL");
  22203. //                      de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_EROGATORE);
  22204. //                      de.setValue(servizioApplicativoErogatoreSelezionatoLabel);
  22205. //                      //de.setType(DataElementType.TEXT);
  22206. //                      de.setType(DataElementType.HIDDEN);
  22207. //                  }
  22208. //              }
  22209. //              else {
  22210. //                  de.setLabels(serviziApplicativiErogatoreLabel);
  22211. //                  de.setValues(serviziApplicativiErogatoreValue);
  22212. //                  de.setSelected(servizioApplicativoErogatoreSelezionatoValue);
  22213. //                  de.setValue(servizioApplicativoErogatoreSelezionatoValue);
  22214. //                  //de.setType(DataElementType.SELECT);
  22215. //                  de.setType(DataElementType.HIDDEN);
  22216. //                  de.setPostBack_viaPOST(true);
  22217. //              }
  22218. //              dati.add(de);
  22219. //          }
  22220.            
  22221.             // Ruolo Fruitore
  22222.             boolean showRuoloRichiedente = false;
  22223.             if(configurazione) {
  22224.                 showRuoloRichiedente = true;
  22225.             }
  22226.             else {
  22227.                 if(serviziApplicativiFruitoreValue!=null && serviziApplicativiFruitoreValue.size()>1){
  22228.                     showRuoloRichiedente = true;
  22229.                 }
  22230.                 else if(fruitoriValue!=null && fruitoriValue.size()>1){
  22231.                     showRuoloRichiedente = true;
  22232.                 }
  22233.             }
  22234.             de = new DataElement();
  22235.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_FRUITORE);
  22236. //          if(configurazione) {
  22237. //              de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_FRUITORE);
  22238. //          }
  22239. //          else {
  22240.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_RICHIEDENTE);
  22241.             //}
  22242.             if(filterConfig!=null && filterConfig.isHideSubscriberRole()) {
  22243.                 de.setType(DataElementType.HIDDEN);
  22244.             }
  22245.             else if((datiIdentificativiFruitoreSelezionatoValue!=null && !delegata) || servizioApplicativoFruitoreSelezionatoValue!=null || !showRuoloRichiedente) {
  22246.                 de.setType(DataElementType.HIDDEN);
  22247.             }
  22248.             else {
  22249.                 de.setValue(ruoloFruitoreSelezionatoValue);
  22250.                 if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  22251.                     de.setType(DataElementType.HIDDEN);
  22252.                     dati.add(de);
  22253.                    
  22254.                     if(configurazione) {
  22255.                         de = new DataElement();
  22256.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_FRUITORE+"___LABEL");
  22257. //                      if(configurazione) {
  22258. //                          de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_FRUITORE);
  22259. //                      }
  22260. //                      else {
  22261.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_RICHIEDENTE);
  22262.                         //}
  22263.                         de.setValue(ruoloFruitoreSelezionatoLabel);
  22264.                         de.setType(DataElementType.TEXT);
  22265.                     }
  22266.                 }
  22267.                 else {
  22268.                     de.setLabels(ruoliFruitoreLabel);
  22269.                     de.setValues(ruoliFruitoreValue);
  22270.                     de.setSelected(ruoloFruitoreSelezionatoValue);
  22271.                     de.setType(DataElementType.SELECT);
  22272.                     de.setPostBack_viaPOST(true);
  22273.                 }
  22274.             }
  22275.             dati.add(de);
  22276.            
  22277.             // Fruitore
  22278.             if(fruitoriValue!=null && fruitoriValue.size()>1){
  22279.                 de = new DataElement();
  22280.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_FRUITORE);
  22281.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_FRUITORE);
  22282.                 if(filterConfig!=null && filterConfig.isHideSubscriber()) {
  22283.                     de.setType(DataElementType.HIDDEN);
  22284.                 }
  22285.                 else if(ruoloFruitoreSelezionatoValue!=null) {
  22286.                     de.setType(DataElementType.HIDDEN);
  22287.                 }
  22288.                 else {
  22289.                     de.setValue(datiIdentificativiFruitoreSelezionatoValue);
  22290.                     if(protocolloAssociatoFiltroNonSelezionatoUtente || delegata) {
  22291.                         de.setType(DataElementType.HIDDEN);
  22292.                         dati.add(de);
  22293.                        
  22294.                         if(configurazione) {
  22295.                             de = new DataElement();
  22296.                             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_FRUITORE+"___LABEL");
  22297.                             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_FRUITORE);
  22298.                             de.setValue(datiIdentificativiFruitoreSelezionatoLabel);
  22299.                             de.setType(DataElementType.TEXT);
  22300.                         }
  22301.                     }
  22302.                     else {
  22303.                         de.setLabels(fruitoriLabel);
  22304.                         de.setValues(fruitoriValue);
  22305.                         de.setSelected(datiIdentificativiFruitoreSelezionatoValue);
  22306.                         de.setType(DataElementType.SELECT);
  22307.                         de.setPostBack_viaPOST(true);
  22308.                     }
  22309.                 }
  22310.                 dati.add(de);
  22311.             }
  22312.            
  22313.             // Servizio Applicativo Fruitore
  22314.             if(serviziApplicativiFruitoreValue!=null && serviziApplicativiFruitoreValue.size()>1){
  22315.                 de = new DataElement();
  22316.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_FRUITORE);
  22317.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_FRUITORE);
  22318.                 if(filterConfig!=null && filterConfig.isHideApplication()) {
  22319.                     de.setType(DataElementType.HIDDEN);
  22320.                 }
  22321.                 else if(ruoloFruitoreSelezionatoValue!=null) {
  22322.                     de.setType(DataElementType.HIDDEN);
  22323.                 }
  22324.                 else {
  22325.                     de.setValue(servizioApplicativoFruitoreSelezionatoValue);
  22326.                     if(protocolloAssociatoFiltroNonSelezionatoUtente) {
  22327.                         de.setType(DataElementType.HIDDEN);
  22328.                         dati.add(de);
  22329.                        
  22330.                         if(configurazione) {
  22331.                             de = new DataElement();
  22332.                             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_FRUITORE+"___LABEL");
  22333.                             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_FRUITORE);
  22334.                             de.setValue(servizioApplicativoFruitoreSelezionatoLabel);
  22335.                             de.setType(DataElementType.TEXT);
  22336.                         }
  22337.                     }
  22338.                     else {
  22339.                         de.setLabels(serviziApplicativiFruitoreLabel);
  22340.                         de.setValues(serviziApplicativiFruitoreValue);
  22341.                         de.setSelected(servizioApplicativoFruitoreSelezionatoValue);
  22342.                         de.setType(DataElementType.SELECT);
  22343.                         de.setPostBack_viaPOST(true);
  22344.                     }
  22345.                 }
  22346.                 dati.add(de);
  22347.             }
  22348.         }
  22349.     }
  22350.    
  22351.     private void addToDatiAllarmeGroupBy(List<DataElement> dati, TipoOperazione tipoOperazione,ConfigurazioneAllarmeBean allarme, Context context, String nomeSezione,  
  22352.             RuoloPorta ruoloPorta, String nomePorta, ServiceBinding serviceBinding,
  22353.             boolean tokenAbilitato) throws Exception {
  22354.    
  22355.         boolean delegata = false;
  22356.         boolean applicativa = false;
  22357.         boolean configurazione = false;
  22358.         if(ruoloPorta!=null) {
  22359.             if(RuoloPorta.DELEGATA.equals(ruoloPorta)) {
  22360.                 delegata = (nomePorta!=null);
  22361.             }
  22362.             else if(RuoloPorta.APPLICATIVA.equals(ruoloPorta)) {
  22363.                 applicativa = (nomePorta!=null);
  22364.             }
  22365.         }
  22366.         configurazione = !delegata && !applicativa;
  22367.        
  22368.        
  22369.                
  22370.         List<String> protocolli = null;
  22371. //      boolean groupByKey = false;
  22372.        
  22373.         if(allarme!=null && allarme.getGroupBy()!=null && allarme.getGroupBy().isEnabled()){
  22374.            
  22375.             // protocollo
  22376.             protocolli = this.confCore.getProtocolli();
  22377.            
  22378.             // group by by key se non sono richiesti campionamenti statistici
  22379. //          if(infoPolicy!=null && infoPolicy.isIntervalloUtilizzaRisorseStatistiche()==false &&
  22380. //                  infoPolicy.isDegradoPrestazionaleUtilizzaRisorseStatistiche()==false){
  22381. //              groupByKey = true;
  22382. //          }
  22383.         }

  22384. //
  22385.         DataElement de = new DataElement();
  22386.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RAGGRUPPAMENTO);
  22387.         de.setType(DataElementType.SUBTITLE);
  22388.         dati.add(de);
  22389.        
  22390.         de = new DataElement();
  22391.         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RAGGRUPPAMENTO_NOTE);
  22392.         de.setType(DataElementType.NOTE);
  22393.         dati.add(de);
  22394.        
  22395.         // stato
  22396.         boolean allarmeGBEnabled = allarme!=null && allarme.getGroupBy()!=null ? allarme.getGroupBy().isEnabled() : false;
  22397.         addToDatiDataElementStato_postBackViaPOST(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_ENABLED,
  22398.                 ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_ENABLED_STATO, allarmeGBEnabled, true, false, false, false);
  22399.        
  22400.         /*
  22401.         de = new DataElement();
  22402.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_ENABLED);
  22403.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_ENABLED);
  22404.         de.setType(DataElementType.SELECT);
  22405.         de.setValues(ConfigurazioneCostanti.CONFIGURAZIONE_STATI_COLLEZIONAMENTO);
  22406.         if(policy.getGroupBy().isEnabled()){
  22407.             de.setSelected(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_COLLEZIONAMENTO_ABILITATO);
  22408.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_COLLEZIONAMENTO_ABILITATO);
  22409.         }
  22410.         else{
  22411.             de.setSelected(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_COLLEZIONAMENTO_DISABILITATO);
  22412.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_COLLEZIONAMENTO_DISABILITATO);
  22413.         }
  22414.         de.setPostBack_viaPOST(true);
  22415.         dati.add(de);
  22416.         */
  22417.        
  22418.         if(allarme!=null && allarme.getGroupBy()!=null && allarme.getGroupBy().isEnabled()){
  22419.        
  22420.             GroupByConfiguration groupByConfig = this.confCore.getGroupByConfiguration(allarme, context);
  22421.            
  22422.            
  22423.             // --- GENERALI ---
  22424.            
  22425.             if(configurazione) {
  22426.                
  22427.                 // Ruolo Gateway
  22428.                 FiltersConfiguration filterConfig = this.confCore.getFiltersConfiguration(allarme, context);
  22429.                 RuoloPorta ruoloPortaFiltro = null;
  22430.                 if(allarme!=null && allarme.getFiltro()!=null && allarme.getFiltro().isEnabled()) {
  22431.                     ruoloPortaFiltro = allarme.getFiltro().getRuoloPorta();
  22432.                 }
  22433.                 if(filterConfig!=null && !filterConfig.isHideGatewayRole() &&
  22434.                         (filterConfig.isForceInGatewayRole() || filterConfig.isForceOutGatewayRole())) {
  22435.                     if(filterConfig.isForceInGatewayRole()) {
  22436.                         ruoloPortaFiltro = RuoloPorta.APPLICATIVA;
  22437.                     }
  22438.                     else if(filterConfig.isForceOutGatewayRole()) {
  22439.                         ruoloPortaFiltro = RuoloPorta.DELEGATA;
  22440.                     }
  22441.                 }
  22442.                
  22443.                 boolean showRuoloPdD = ruoloPortaFiltro==null ||
  22444.                         RuoloPorta.ENTRAMBI.equals(ruoloPortaFiltro);
  22445.                 if(showRuoloPdD) {
  22446.                     if(groupByConfig!=null && groupByConfig.isHideGatewayRole()) {
  22447.                         showRuoloPdD = false;
  22448.                     }
  22449.                 }
  22450.                
  22451.                 boolean showProtocollo = protocolli.size()>1 && (allarme.getFiltro()==null ||
  22452.                         allarme.getFiltro().isEnabled()==false ||
  22453.                         allarme.getFiltro().getProtocollo()==null);
  22454.                 if(showProtocollo) {
  22455.                     if(groupByConfig!=null && groupByConfig.isHideProtocol()) {
  22456.                         showProtocollo = false;
  22457.                     }
  22458.                 }
  22459.                
  22460.                 boolean showErogatore = allarme.getFiltro()==null ||
  22461.                         allarme.getFiltro().isEnabled()==false ||
  22462.                         allarme.getFiltro().getTipoErogatore()==null ||
  22463.                         allarme.getFiltro().getNomeErogatore()==null;
  22464.                 if(showErogatore) {
  22465.                     if(groupByConfig!=null && groupByConfig.isHideProvider()) {
  22466.                         showErogatore = false;
  22467.                     }
  22468.                 }
  22469.                
  22470.                 if(showRuoloPdD || showProtocollo || showErogatore) {
  22471. //                  de = new DataElement();
  22472. //                  de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_GROUPBY_DATI_GENERALI);
  22473. //                  de.setType(DataElementType.NOTE);
  22474. //                  dati.add(de);
  22475.                 }
  22476.                
  22477.                 // Ruolo PdD
  22478.                 if( showRuoloPdD ){
  22479.                     de = new DataElement();
  22480.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_RUOLO_PDD);
  22481.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_RUOLO_PDD_LABEL);
  22482.                     //de.setLabelRight(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_RUOLO_PDD_NOTE);
  22483.                     de.setType(DataElementType.CHECKBOX);
  22484.                     de.setSelected(allarme.getGroupBy().isRuoloPorta());
  22485.                     de.setValue(allarme.getGroupBy().isRuoloPorta()+"");
  22486.                     dati.add(de);
  22487.                 }
  22488.            
  22489.                 // Protocollo
  22490.                 de = new DataElement();
  22491.                 de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PROTOCOLLO);
  22492.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PROTOCOLLO);
  22493.                 if(showProtocollo){
  22494.                     de.setType(DataElementType.CHECKBOX);
  22495.                     de.setSelected(allarme.getGroupBy().isProtocollo());
  22496.                     de.setValue(allarme.getGroupBy().isProtocollo()+"");
  22497.                 }
  22498.                 else{
  22499.                     de.setType(DataElementType.HIDDEN);
  22500.                     if(protocolli.size()==1){
  22501.                         de.setValue("false");
  22502.                     }
  22503.                 }
  22504.                 dati.add(de);
  22505.                
  22506.                 // Erogatore
  22507.                 if( showErogatore ){
  22508.                     de = new DataElement();
  22509.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_EROGATORE);
  22510.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_EROGATORE);
  22511.                     de.setType(DataElementType.CHECKBOX);
  22512.                     de.setSelected(allarme.getGroupBy().isErogatore());
  22513.                     de.setValue(allarme.getGroupBy().isErogatore()+"");
  22514.                     dati.add(de);
  22515.                 }
  22516.                                
  22517.             }

  22518.            
  22519.             // --- API ---
  22520.            
  22521.             boolean showServizio = false;
  22522.            
  22523.             boolean showAzione =  allarme.getFiltro()==null ||
  22524.                     allarme.getFiltro().isEnabled()==false ||
  22525.                     allarme.getFiltro().getAzione()==null ||
  22526.                     "".equals(allarme.getFiltro().getAzione()) ||
  22527.                     allarme.getFiltro().getAzione().contains(",");
  22528.             if(showAzione) {
  22529.                 if(groupByConfig!=null && groupByConfig.isHideAction()) {
  22530.                     showAzione = false;
  22531.                 }
  22532.             }
  22533.            
  22534. //          boolean showSAErogatore = false;
  22535.            
  22536.             if(configurazione) {
  22537.            
  22538.                 if(this.core.getAllarmiConfig().isOptionsGroupByApi()) {
  22539.                     showServizio = allarme.getFiltro()==null ||
  22540.                             allarme.getFiltro().isEnabled()==false ||
  22541.                             allarme.getFiltro().getTipoServizio()==null ||
  22542.                             allarme.getFiltro().getNomeServizio()==null;
  22543.                     if(showServizio) {
  22544.                         if(groupByConfig!=null && groupByConfig.isHideService()) {
  22545.                             showServizio = false;
  22546.                         }
  22547.                     }
  22548.                 }

  22549.                 if(showAzione) {
  22550.                     showAzione = showServizio && allarme.getGroupBy().isServizio(); // l'azione la scelgo se ho prima selezionato una API
  22551.                     if(showAzione) {
  22552.                         if(groupByConfig!=null && groupByConfig.isHideAction()) {
  22553.                             showAzione = false;
  22554.                         }
  22555.                     }
  22556.                 }
  22557.                
  22558. //              showSAErogatore = allarme.getFiltro()==null ||
  22559. //                      allarme.getFiltro().isEnabled()==false ||
  22560. //                      allarme.getFiltro().getRuoloPorta()==null ||
  22561. //                      RuoloPorta.ENTRAMBI.equals(allarme.getFiltro().getRuoloPorta()) ||
  22562. //                      RuoloPorta.APPLICATIVA.equals(allarme.getFiltro().getRuoloPorta());
  22563. //              if(showSAErogatore) {
  22564. //                  showSAErogatore = allarme.getFiltro()==null ||
  22565. //                          allarme.getFiltro().isEnabled()==false ||
  22566. //                          allarme.getFiltro().getServizioApplicativoErogatore()==null;
  22567. //              }
  22568.                
  22569.                 if(showServizio || showAzione) { // || showSAErogatore
  22570.                     if(configurazione) {
  22571. //                      de = new DataElement();
  22572. //                      de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_GROUPBY_API);
  22573. //                      de.setType(DataElementType.NOTE);
  22574. //                      dati.add(de);
  22575.                     }
  22576.                 }
  22577.                        
  22578.                 // Servizio
  22579.                 if( showServizio ){
  22580.                     de = new DataElement();
  22581.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_SERVIZIO);
  22582.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_SERVIZIO);
  22583.                     de.setType(DataElementType.CHECKBOX);
  22584.                     de.setSelected(allarme.getGroupBy().isServizio());
  22585.                     de.setValue(allarme.getGroupBy().isServizio()+"");
  22586.                     de.setPostBack_viaPOST(true);
  22587.                     dati.add(de);
  22588.                 }
  22589.             }
  22590.                
  22591.             // Azione
  22592.             de = new DataElement();
  22593.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_AZIONE);
  22594.             if(serviceBinding!=null) {
  22595.                 de.setLabel(getLabelAzione(serviceBinding));
  22596.             }
  22597.             else {
  22598.                 de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_AZIONE);
  22599.             }
  22600.             if( showAzione ){
  22601.                 de.setType(DataElementType.CHECKBOX);
  22602.                 de.setSelected(allarme.getGroupBy().isAzione());
  22603.             }
  22604.             else {
  22605.                 de.setType(DataElementType.HIDDEN);
  22606.             }
  22607.             de.setValue(allarme.getGroupBy().isAzione()+"");
  22608.             dati.add(de);
  22609.            
  22610.                
  22611.             // Servizio Applicativo Erogatore
  22612. //          if(configurazione) {
  22613. //              if( showSAErogatore ){
  22614. //                  de = new DataElement();
  22615. //                  de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_SA_EROGATORE);
  22616. //                  de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_SA_EROGATORE);
  22617. //                  //de.setType(DataElementType.CHECKBOX);
  22618. //                  de.setType(DataElementType.HIDDEN);
  22619. //                  de.setSelected(allarme.getGroupBy().isServizioApplicativoErogatore());
  22620. //                  de.setValue(allarme.getGroupBy().isServizioApplicativoErogatore()+"");
  22621. //                  dati.add(de);
  22622. //              }
  22623. //          }
  22624.                

  22625.            
  22626.             // --- RICHIEDENTI ---
  22627.            
  22628.             if(configurazione) {
  22629. //              de = new DataElement();
  22630. //              de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI_GROUPBY_MITTENTE);
  22631. //              de.setType(DataElementType.NOTE);
  22632. //              dati.add(de);
  22633.             }
  22634.            
  22635.             // Fruitore
  22636.            
  22637.             if(configurazione) {
  22638.                
  22639.                 boolean showFruitore = allarme.getFiltro()==null ||
  22640.                         allarme.getFiltro().isEnabled()==false ||
  22641.                         allarme.getFiltro().getTipoFruitore()==null ||
  22642.                         allarme.getFiltro().getNomeFruitore()==null;
  22643.                 if(showFruitore) {
  22644.                     if(groupByConfig!=null && groupByConfig.isHideSubscriber()) {
  22645.                         showFruitore = false;
  22646.                     }
  22647.                 }
  22648.                
  22649.                 // Fruitore
  22650.                 if( showFruitore ){
  22651.                     de = new DataElement();
  22652.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_FRUITORE);
  22653.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_FRUITORE);
  22654.                     de.setType(DataElementType.CHECKBOX);
  22655.                     de.setSelected(allarme.getGroupBy().isFruitore());
  22656.                     de.setValue(allarme.getGroupBy().isFruitore()+"");
  22657.                     dati.add(de);
  22658.                 }
  22659.                
  22660.                
  22661.                 boolean showRichiedenteApplicativo = allarme.getFiltro()==null ||
  22662.                         allarme.getFiltro().isEnabled()==false ||
  22663.                         allarme.getFiltro().getRuoloPorta()==null ||
  22664.                         allarme.getFiltro().getServizioApplicativoFruitore()==null;
  22665.                 if(showRichiedenteApplicativo) {
  22666.                     if(groupByConfig!=null && groupByConfig.isHideApplication()) {
  22667.                         showRichiedenteApplicativo = false;
  22668.                     }
  22669.                 }
  22670.                
  22671.                 // Applicativo Fruitore
  22672.                 if( showRichiedenteApplicativo ){
  22673.                     de = new DataElement();
  22674.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_SA_FRUITORE);
  22675.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_SA_FRUITORE);
  22676.                     de.setType(DataElementType.CHECKBOX);
  22677.                     de.setSelected(allarme.getGroupBy().isServizioApplicativoFruitore());
  22678.                     de.setValue(allarme.getGroupBy().isServizioApplicativoFruitore()+"");
  22679.                     dati.add(de);
  22680.                 }
  22681.                
  22682.             }
  22683.             else {
  22684.            
  22685.                 boolean showRichiedente = true;
  22686.                 if(showRichiedente) {
  22687.                     if(groupByConfig!=null && groupByConfig.isHideSenderIdentity()) {
  22688.                         showRichiedente = false;
  22689.                     }
  22690.                 }
  22691.                
  22692.                 // Richiedente API (Significa SoggettoMittente per le erogazioni, Applicativo e Identificativo Autenticato sia per le erogazioni che per le fruizioni)
  22693.                 if(showRichiedente) {
  22694.                     de = new DataElement();
  22695.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_RICHIEDENTE);
  22696.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_RICHIEDENTE);
  22697.                     de.setType(DataElementType.CHECKBOX);
  22698.                     de.setSelected(allarme.getGroupBy().isIdentificativoAutenticato()); // uso isIdentificativoAutenticato come informazione equivalente a isServizioApplicativoFruitore e isSoggettoFruitore
  22699.                     de.setValue(allarme.getGroupBy().isIdentificativoAutenticato()+"");
  22700.                     dati.add(de);
  22701.                 }
  22702.            
  22703.             }
  22704.            

  22705.             // Token
  22706.            
  22707.             if(tokenAbilitato) {
  22708.            
  22709.                 boolean first = this.isFirstTimeFromHttpParameters(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_FIRST_TIME);
  22710.                 String token = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_TOKEN);
  22711.                
  22712.                 String [] tokenSelezionatiDB = null;
  22713.                 if(allarme.getGroupBy().getToken()!=null && !"".equals(allarme.getGroupBy().getToken())) {
  22714.                     tokenSelezionatiDB = allarme.getGroupBy().getToken().split(",");
  22715.                 }
  22716.                 String [] tokenSelezionatiSenzaIssuer = null;
  22717.                 if(tokenSelezionatiDB!=null && tokenSelezionatiDB.length>0) {
  22718.                     List<String> l = new ArrayList<>();
  22719.                     for (int i = 0; i < tokenSelezionatiDB.length; i++) {
  22720.                         TipoCredenzialeMittente tipo = TipoCredenzialeMittente.toEnumConstant(tokenSelezionatiDB[i],true);
  22721.                         if(!TipoCredenzialeMittente.TOKEN_ISSUER.equals(tipo)) {
  22722.                             l.add(tokenSelezionatiDB[i]);
  22723.                         }
  22724.                     }
  22725.                     if(!l.isEmpty()) {
  22726.                         tokenSelezionatiSenzaIssuer = l.toArray(new String[1]);
  22727.                     }
  22728.                 }
  22729.                 boolean groupByToken = false;
  22730.                 if(first) {
  22731.                     groupByToken = (tokenSelezionatiDB!=null && tokenSelezionatiDB.length>0);
  22732.                 }
  22733.                 else {
  22734.                     groupByToken = ServletUtils.isCheckBoxEnabled(token);
  22735.                 }
  22736.                
  22737.                 boolean showToken = true;
  22738.                 if(showToken) {
  22739.                     if(groupByConfig!=null && groupByConfig.isHideToken()) {
  22740.                         showToken = false;
  22741.                     }
  22742.                 }
  22743.                
  22744.                 if(showToken) {
  22745.                     de = new DataElement();
  22746.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_TOKEN);
  22747.                     de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_TOKEN);
  22748.                     de.setType(DataElementType.CHECKBOX);
  22749.                     de.setSelected(groupByToken); // uso isIdentificativoAutenticato come informazione equivalente a isServizioApplicativoFruitore e isSoggettoFruitore
  22750.                     de.setValue(groupByToken+"");
  22751.                     de.setPostBack_viaPOST(true);
  22752.                     dati.add(de);
  22753.                    
  22754.                     boolean showTokenClaims = true;
  22755.                     if(showTokenClaims) {
  22756.                         if(groupByConfig!=null && groupByConfig.isHideTokenClaims()) {
  22757.                             showTokenClaims = false;
  22758.                         }
  22759.                     }
  22760.                    
  22761.                     if(showTokenClaims && groupByToken) {
  22762.                         de = new DataElement();
  22763.                         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_TOKEN_CLAIMS);
  22764.                         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_TOKEN_CLAIMS);
  22765.                         de.setValues(CostantiControlStation.TOKEN_VALUES_WITHOUT_ISSUER);
  22766.                         de.setLabels(CostantiControlStation.LABEL_TOKEN_VALUES_WITHOUT_ISSUER);
  22767.                         de.setSelezionati(tokenSelezionatiSenzaIssuer);
  22768.                         de.setType(DataElementType.MULTI_SELECT);
  22769.                         de.setRows(4);
  22770.                         de.setRequired(true);
  22771.                         dati.add(de);
  22772.                     }
  22773.                 }
  22774.                
  22775.             }
  22776.            
  22777. //          if(groupByKey){
  22778. //          
  22779. //              // per chiave
  22780. //              
  22781. //              if(allarme.getGroupBy().isInformazioneApplicativaEnabled()){
  22782. //                  de = new DataElement();
  22783. //                  de.setValue(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_ENABLED_NOTE);
  22784. //                  de.setType(DataElementType.NOTE);
  22785. //                  dati.add(de);
  22786. //              }
  22787. //              
  22788. //              de = new DataElement();
  22789. //              de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_ENABLED);
  22790. //              if(allarme.getGroupBy().isInformazioneApplicativaEnabled()){
  22791. //                  de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO);
  22792. //              }
  22793. //              else{
  22794. //                  //de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_ENABLED_LABEL);
  22795. //                  de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_ENABLED_LABEL);
  22796. //                  //de.setLabelRight(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_ENABLED_NOTE);
  22797. //              }
  22798. //              de.setType(DataElementType.CHECKBOX);
  22799. //              de.setSelected(allarme.getGroupBy().isInformazioneApplicativaEnabled());
  22800. //              de.setValue(allarme.getGroupBy().isInformazioneApplicativaEnabled()+"");
  22801. //              de.setPostBack_viaPOST(true);
  22802. //              dati.add(de);
  22803. //              
  22804. //              if(allarme.getGroupBy().isInformazioneApplicativaEnabled()){
  22805. //                  
  22806. //                  TipoFiltroApplicativo tipoChiaveGroupBy = null;
  22807. //                  if(allarme.getGroupBy().getInformazioneApplicativaTipo()!=null && !"".equals(allarme.getGroupBy().getInformazioneApplicativaTipo())){
  22808. //                      tipoChiaveGroupBy = TipoFiltroApplicativo.toEnumConstant(allarme.getGroupBy().getInformazioneApplicativaTipo());
  22809. //                  }
  22810. //                  if(tipoChiaveGroupBy==null){
  22811. //                      tipoChiaveGroupBy = TipoFiltroApplicativo.toEnumConstant(ConfigurazioneCostanti.ALLARMI_GROUPBY_PER_CHIAVE_TIPO_DEFAULT);
  22812. //                  }
  22813. //                  
  22814. //                  de = new DataElement();
  22815. //                  de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_TIPO);
  22816. //                  de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_TIPO);
  22817. //                  de.setValues(TipoFiltroApplicativo.toStringArray());
  22818. //                  de.setLabels(ConfigurazioneCostanti.LABEL_RATE_LIMITING_FILTRO_APPLICATIVO);
  22819. //                  de.setSelected(allarme.getGroupBy().getInformazioneApplicativaTipo());
  22820. //                  de.setValue(allarme.getGroupBy().getInformazioneApplicativaTipo());
  22821. //                  de.setType(DataElementType.SELECT);
  22822. //                  de.setPostBack_viaPOST(true);
  22823. //                  dati.add(de);
  22824. //                  
  22825. //                  de = new DataElement();
  22826. //                  de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_GROUPBY_PER_CHIAVE_NOME);
  22827. //                  de.setLabel(this.getLabelTipoInformazioneApplicativaGroupBy(allarme.getGroupBy().getInformazioneApplicativaTipo()));
  22828. //                  de.setValue(allarme.getGroupBy().getInformazioneApplicativaNome());
  22829. //                  if(tipoChiaveGroupBy==null ||
  22830. //                          TipoFiltroApplicativo.SOAPACTION_BASED.equals(tipoChiaveGroupBy)  ||
  22831. //                          TipoFiltroApplicativo.INDIRIZZO_IP.equals(tipoChiaveGroupBy) ||
  22832. //                          TipoFiltroApplicativo.INDIRIZZO_IP_FORWARDED.equals(tipoChiaveGroupBy)){
  22833. //                      de.setType(DataElementType.HIDDEN);
  22834. //                  }
  22835. //                  else if(TipoFiltroApplicativo.URLBASED.equals(tipoChiaveGroupBy) ||
  22836. //                          TipoFiltroApplicativo.CONTENT_BASED.equals(tipoChiaveGroupBy)) {
  22837. //                      de.setRequired(true);
  22838. //                      de.setType(DataElementType.TEXT_AREA);
  22839. //                  }
  22840. //                  else{
  22841. //                      de.setRequired(true);
  22842. //                      de.setType(DataElementType.TEXT_EDIT);
  22843. //                  }
  22844. //                  dati.add(de);
  22845. //              }
  22846. //              
  22847. //          }
  22848.         }
  22849.     }
  22850.    
  22851.     public String toStringCompactAllarmeFilter(AllarmeFiltro filtro, RuoloPorta ruoloPorta, String nomePorta, ServiceBinding serviceBinding) throws Exception {
  22852.        
  22853.         boolean delegata = false;
  22854.         boolean applicativa = false;
  22855.         boolean configurazione = false;
  22856.         if(ruoloPorta!=null) {
  22857.             if(RuoloPorta.DELEGATA.equals(ruoloPorta)) {
  22858.                 delegata = (nomePorta!=null);
  22859.             }
  22860.             else if(RuoloPorta.APPLICATIVA.equals(ruoloPorta)) {
  22861.                 applicativa = (nomePorta!=null);
  22862.             }
  22863.         }
  22864.         configurazione = !delegata && !applicativa;
  22865.        
  22866.         StringBuilder bf = new StringBuilder("");
  22867.         if(filtro.isEnabled()){

  22868.             if(configurazione) {
  22869.                 if( (filtro.getRuoloPorta()!=null && !RuoloPorta.ENTRAMBI.equals(filtro.getRuoloPorta())) ){
  22870.                     if(bf.length()>0){
  22871.                         bf.append(", ");
  22872.                     }
  22873.                     if(RuoloPorta.DELEGATA.equals(filtro.getRuoloPorta())){
  22874.                         bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_PDD).append(": ");
  22875.                         bf.append(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RUOLO_PORTA_DELEGATA);
  22876.                     }
  22877.                     else if(RuoloPorta.APPLICATIVA.equals(filtro.getRuoloPorta())){
  22878.                         bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_PDD).append(": ");
  22879.                         bf.append(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RUOLO_PORTA_APPLICATIVA);
  22880.                     }
  22881.                 }
  22882.             }

  22883.             if(configurazione) {
  22884.                 if( !(filtro.getProtocollo()==null || "".equals(filtro.getProtocollo())) ){
  22885.                     if(bf.length()>0){
  22886.                         bf.append(", ");
  22887.                     }
  22888.                     bf.append(CostantiControlStation.LABEL_PARAMETRO_PROTOCOLLO_COMPACT+": ");
  22889.                     bf.append(this.getLabelProtocollo(filtro.getProtocollo()));
  22890.                 }
  22891.             }
  22892.                
  22893.             if(configurazione) {
  22894.                 if( !(filtro.getNomePorta()==null || "".equals(filtro.getNomePorta())) ){
  22895.                     if(bf.length()>0){
  22896.                         bf.append(", ");
  22897.                     }
  22898.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_PORTA).append(": ");
  22899.                     bf.append(filtro.getNomePorta());
  22900.                 }
  22901.             }
  22902.                        
  22903.             if(configurazione) {
  22904.                 if(filtro.getRuoloErogatore()!=null) {
  22905.                     if(bf.length()>0){
  22906.                         bf.append(", ");
  22907.                     }
  22908.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_EROGATORE).append(": ");
  22909.                     bf.append(filtro.getRuoloErogatore());
  22910.                 }
  22911.                 else if( !( (filtro.getTipoErogatore()==null || "".equals(filtro.getTipoErogatore()))
  22912.                         ||
  22913.                         (filtro.getNomeErogatore()==null || "".equals(filtro.getNomeErogatore())) ) ){
  22914.                     if(bf.length()>0){
  22915.                         bf.append(", ");
  22916.                     }
  22917.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_EROGATORE_COMPACT).append(": ");
  22918.                     IDSoggetto idSoggetto = new IDSoggetto(filtro.getTipoErogatore(), filtro.getNomeErogatore());
  22919.                     bf.append(this.getLabelNomeSoggetto(idSoggetto));
  22920.                 }
  22921.             }

  22922.             if(configurazione) {
  22923.                 if( !(filtro.getTag()==null || "".equals(filtro.getTag())) ){
  22924.                     if(bf.length()>0){
  22925.                         bf.append(", ");
  22926.                     }
  22927.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_TAG).append(": ");
  22928.                     bf.append(filtro.getTag());
  22929.                 }
  22930.             }
  22931.            
  22932.             if(configurazione) {
  22933.                 if( !( (filtro.getTipoServizio()==null || "".equals(filtro.getTipoServizio()))
  22934.                         ||
  22935.                         (filtro.getNomeServizio()==null || "".equals(filtro.getNomeServizio()))
  22936.                         ||
  22937.                         (filtro.getVersioneServizio()==null)
  22938.                         ||
  22939.                         (filtro.getTipoErogatore()==null || "".equals(filtro.getTipoErogatore()))
  22940.                         ||
  22941.                         (filtro.getNomeErogatore()==null || "".equals(filtro.getNomeErogatore()))
  22942.                         ) ){
  22943.                     if(bf.length()>0){
  22944.                         bf.append(", ");
  22945.                     }
  22946.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SERVIZIO).append(": ");
  22947.                     IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(filtro.getTipoServizio(), filtro.getNomeServizio(),
  22948.                             filtro.getTipoErogatore(), filtro.getNomeErogatore(),
  22949.                             filtro.getVersioneServizio());
  22950.                     bf.append(this.getLabelIdServizio(idServizio));
  22951.                 }
  22952.             }
  22953.            
  22954.             if( !(filtro.getAzione()==null || "".equals(filtro.getAzione())) ){
  22955.                 if(bf.length()>0){
  22956.                     bf.append(", ");
  22957.                 }
  22958.                 bf.append(this.getLabelAzione(serviceBinding)).append(": ");
  22959.                 bf.append(filtro.getAzione());
  22960.             }
  22961.            
  22962.             if(configurazione || applicativa) {
  22963.                 if(filtro.getRuoloFruitore()!=null) {
  22964.                     if(bf.length()>0){
  22965.                         bf.append(", ");
  22966.                     }
  22967.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_RUOLO_FRUITORE).append(": ");
  22968.                     bf.append(filtro.getRuoloFruitore());
  22969.                 }
  22970.                 else if( !( (filtro.getTipoFruitore()==null || "".equals(filtro.getTipoFruitore()))
  22971.                         ||
  22972.                         (filtro.getNomeFruitore()==null || "".equals(filtro.getNomeFruitore())) ) ){
  22973.                     if(bf.length()>0){
  22974.                         bf.append(", ");
  22975.                     }
  22976.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_FRUITORE_COMPACT).append(": ");
  22977.                     IDSoggetto idSoggetto = new IDSoggetto(filtro.getTipoFruitore(), filtro.getNomeFruitore());
  22978.                     bf.append(this.getLabelNomeSoggetto(idSoggetto));
  22979.                 }
  22980.             }

  22981.             if(configurazione || delegata) {
  22982.                 if( !(filtro.getServizioApplicativoFruitore()==null || "".equals(filtro.getServizioApplicativoFruitore())) ){
  22983.                     if(bf.length()>0){
  22984.                         bf.append(", ");
  22985.                     }
  22986.                     bf.append(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_FILTRO_SA_FRUITORE_COMPACT).append(": ");
  22987.                     bf.append(filtro.getServizioApplicativoFruitore());
  22988.                 }
  22989.             }
  22990.            
  22991.         }
  22992.         else{
  22993.             bf.append(CostantiControlStation.LABEL_STATO_DISABILITATO);
  22994.         }

  22995.         if(bf.length()<=0 && (delegata || applicativa)) {
  22996.             bf.append(CostantiControlStation.LABEL_STATO_DISABILITATO);
  22997.         }
  22998.        
  22999.         return bf.toString();
  23000.     }
  23001.    
  23002.     public void savePluginIntoSession(HttpServletRequest request, HttpSession session, Plugin plugin){
  23003.         ServletUtils.setObjectIntoSession(request, session, plugin, ConfigurazioneCostanti.SESSION_PARAMETRO_OLD_PLUGIN);
  23004.     }
  23005.    
  23006.     public void removePluginFromSession(HttpServletRequest request, HttpSession session){
  23007.         ServletUtils.removeObjectFromSession(request, session, ConfigurazioneCostanti.SESSION_PARAMETRO_OLD_PLUGIN);
  23008.     }

  23009.     public Plugin readPluginFromSession(HttpServletRequest request, HttpSession session){
  23010.         return ServletUtils.getObjectFromSession(request, session, Plugin.class, ConfigurazioneCostanti.SESSION_PARAMETRO_OLD_PLUGIN);
  23011.     }
  23012.    
  23013.     public void saveParametriIntoSession(HttpServletRequest request, HttpSession session, List<org.openspcoop2.monitor.sdk.parameters.Parameter<?>> parameters){
  23014.         ServletUtils.setObjectIntoSession(request, session, parameters, ConfigurazioneCostanti.SESSION_PARAMETRO_OLD_PARAMETRI );
  23015.     }
  23016.    
  23017.     public void removeParametriFromSession(HttpServletRequest request, HttpSession session){
  23018.         ServletUtils.removeObjectFromSession(request, session, ConfigurazioneCostanti.SESSION_PARAMETRO_OLD_PARAMETRI);
  23019.     }

  23020.     @SuppressWarnings("unchecked")
  23021.     public List<org.openspcoop2.monitor.sdk.parameters.Parameter<?>> readParametriFromSession(HttpServletRequest request, HttpSession session){
  23022.         Object obj = ServletUtils.getObjectFromSession(request, session, ConfigurazioneCostanti.SESSION_PARAMETRO_OLD_PARAMETRI);

  23023.         if(obj == null)
  23024.             return null;

  23025.         return (List<org.openspcoop2.monitor.sdk.parameters.Parameter<?>>) obj;
  23026.     }
  23027.    
  23028.    
  23029.     public void prepareAllarmiHistoryList(ConsoleSearch ricerca, List<ConfigurazioneAllarmeHistoryBean> lista, ConfigurazioneAllarmeBean allarme,
  23030.             RuoloPorta ruoloPorta, String nomePorta, ServiceBinding serviceBinding) throws Exception{
  23031.         try {
  23032.            
  23033.             List<Parameter> lstParAllarme = new ArrayList<>();
  23034.             Parameter parRuoloPorta = null;
  23035.             if(ruoloPorta!=null) {
  23036.                 parRuoloPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA, ruoloPorta.getValue());
  23037.                 lstParAllarme.add(parRuoloPorta);
  23038.             }
  23039.             Parameter parNomePorta = null;
  23040.             if(nomePorta!=null) {
  23041.                 parNomePorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA, nomePorta);
  23042.                 lstParAllarme.add(parNomePorta);
  23043.             }
  23044.             Parameter parServiceBinding = null;
  23045.             if(serviceBinding!=null) {
  23046.                 parServiceBinding = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING, serviceBinding.name());
  23047.                 lstParAllarme.add(parServiceBinding);
  23048.             }
  23049.            
  23050.             ServletUtils.addListElementIntoSession(this.request, this.session, ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_ALLARMI_HISTORY);

  23051.             int idLista = Liste.CONFIGURAZIONE_ALLARMI_HISTORY;
  23052.             int limit = ricerca.getPageSize(idLista);
  23053.             int offset = ricerca.getIndexIniziale(idLista);
  23054.            
  23055.             Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_ID_ALLARME, allarme.getId() + "");
  23056.             lstParAllarme.add(pId);
  23057.            
  23058.             this.pd.setIndex(offset);
  23059.             this.pd.setPageSize(limit);
  23060.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  23061.             ServletUtils.disabledPageDataSearch(this.pd);
  23062.            
  23063.             List<Parameter> lstParamPorta = null;
  23064.             if(ruoloPorta!=null) {
  23065.                 lstParamPorta = getTitleListAllarmi(ruoloPorta, nomePorta, serviceBinding, allarme.getNome());
  23066.             }
  23067.            
  23068.             // setto la barra del titolo
  23069.             List<Parameter> lstParam = null;
  23070.             if(lstParamPorta!=null) {
  23071.                 lstParam = lstParamPorta;
  23072.                 lstParam.set((lstParam.size() -1),
  23073.                         new Parameter(allarme.getNome(), ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParAllarme.toArray(new Parameter[lstParAllarme.size()])));
  23074.                
  23075.             } else {
  23076.                 lstParam = new ArrayList<>();
  23077.                 lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_LIST));
  23078.                 lstParam.add(new Parameter(allarme.getNome(), ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_CHANGE, lstParAllarme.toArray(new Parameter[lstParAllarme.size()])));
  23079.             }

  23080.             lstParam.add(new Parameter(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ARCHIVIO_STATI, null));
  23081.            
  23082.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  23083.            
  23084.             // setto le label delle colonne
  23085.             List<String> lstLabels = new ArrayList<>();
  23086.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_DATA_AGGIORNAMENTO);
  23087.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO);
  23088.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_STATO);
  23089.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_ACKNOWLEDGED);
  23090.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_DETTAGLIO);
  23091.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_ALLARMI_UTENTE);
  23092.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  23093.             // preparo i dati
  23094.             List<List<DataElement>> dati = new ArrayList<>();
  23095.            
  23096.            

  23097.             if (lista != null) {
  23098.                 Iterator<ConfigurazioneAllarmeHistoryBean> it = lista.iterator();
  23099.                
  23100.                 while (it.hasNext()) {
  23101.                     ConfigurazioneAllarmeHistoryBean entry = it.next();
  23102.                    
  23103.                     List<DataElement> e = new ArrayList<>();
  23104.                    
  23105.                     // Data Aggiornamento
  23106.                     DataElement de = new DataElement();
  23107.                     Date timestampUpdate = entry.getTimestampUpdate();
  23108.                    
  23109.                     String dataValue = DateUtils.getSimpleDateFormat(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PLUGINS_ARCHIVI_FORMATO_DATA).format(timestampUpdate);
  23110.                     de.setToolTip(dataValue);
  23111.                     de.setValue(dataValue);
  23112.                     e.add(de);
  23113.                    
  23114.                     // Abilitato
  23115.                     de = new DataElement();
  23116.                     de.setWidthPx(10);
  23117.                     if(entry.getEnabled() == 1){
  23118.                         de.setValue(ConfigurazioneCostanti.LABEL_VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO_SI);
  23119.                     }
  23120.                     else{
  23121.                         de.setValue(ConfigurazioneCostanti.LABEL_VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_ABILITATO_NO);
  23122.                     }
  23123.                     e.add(de);
  23124.                    
  23125.                     // Stato
  23126.                     de = new DataElement();
  23127.                    
  23128.                     if(entry.getEnabled() == 1) {
  23129.                         if(entry.getStato()!=null && (allarme.getStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_OK.intValue())) {
  23130.                             de.setToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_OK);
  23131.                             de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_OK);
  23132.                         } else if(entry.getStato()!=null && (allarme.getStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_ERROR.intValue())) {
  23133.                             de.setToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_ERROR);
  23134.                             de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_ERROR);
  23135.                         } else if(entry.getStato()!=null && (allarme.getStato().intValue() == ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_STATO_WARNING.intValue())) {
  23136.                             de.setToolTip(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_WARNING);
  23137.                             de.setValue(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_WARNING);
  23138.                         }
  23139.                     } else {
  23140.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  23141.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  23142.                     }
  23143.                    
  23144.                     e.add(de);
  23145.                    
  23146.                     // ack
  23147.                     de = new DataElement();
  23148. //                  de.setWidthPx(10);
  23149.                     if(entry.getAcknowledged() == 1){
  23150.                         de.setToolTip(ConfigurazioneCostanti.LABEL_VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_ACKNOWLEDGE_SI);
  23151.                         de.setValue(ConfigurazioneCostanti.LABEL_VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_ACKNOWLEDGE_SI);
  23152.                     }
  23153.                     else{
  23154.                         de.setToolTip(ConfigurazioneCostanti.LABEL_VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_ACKNOWLEDGE_NO);
  23155.                         de.setValue(ConfigurazioneCostanti.LABEL_VALUE_PARAMETRO_CONFIGURAZIONE_ALLARMI_ACKNOWLEDGE_NO);
  23156.                     }
  23157.                     e.add(de);
  23158.                    
  23159.                     // dettaglio
  23160.                     de = new DataElement();
  23161.                     de.setValue(entry.getDettaglioStatoAbbr());
  23162.                     de.setToolTip(entry.getDettaglioStatoHtmlEscaped());
  23163.                     e.add(de);
  23164.                    
  23165.                     // utente
  23166.                     de = new DataElement();
  23167.                     de.setValue(entry.getUtente());
  23168.                     de.setToolTip(entry.getUtente());
  23169.                     e.add(de);
  23170.                    
  23171.                     dati.add(e);
  23172.                 }
  23173.             }
  23174.            
  23175.             this.pd.setDati(dati);
  23176.             this.pd.setAddButton(false);
  23177.             this.pd.setRemoveButton(false);
  23178.             this.pd.setSelect(false);
  23179.         } catch (Exception e) {
  23180.             this.logError("Exception: " + e.getMessage(), e);
  23181.             throw new DriverControlStationException(e);
  23182.         }
  23183.     }
  23184.    
  23185.    
  23186.     public void prepareHandlersRichiestaList(ConsoleSearch ricerca, List<ConfigurazioneHandlerBean> lista, TipoPdD ruoloPorta, String idPortaS, ServiceBinding serviceBinding, String tipologia) throws Exception {
  23187.         String objectName = ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_HANDLERS_RICHIESTA;
  23188.         String servletListURL = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_HANDLERS_RICHIESTA_LIST;
  23189.         String servletChangeURL = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_HANDLERS_RICHIESTA_CHANGE;
  23190.         String labelHandler = getLabelTipologiaFromFaseMessageHandler(tipologia,true);
  23191.         String labelHandlerDi = labelHandler + " di ";
  23192.        
  23193.         int idLista = Liste.CONFIGURAZIONE_HANDLERS_RICHIESTA;
  23194.         String searchLabel = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_HANDLERS_LABEL;
  23195.        
  23196.         prepareHandlersList(ricerca, lista, ruoloPorta, idPortaS, serviceBinding, tipologia, objectName, servletListURL, servletChangeURL, labelHandler, labelHandlerDi, idLista, searchLabel);
  23197.     }
  23198.    
  23199.     public void prepareHandlersRispostaList(ConsoleSearch ricerca, List<ConfigurazioneHandlerBean> lista, TipoPdD ruoloPorta, String idPortaS, ServiceBinding serviceBinding, String tipologia) throws Exception {
  23200.         String objectName = ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_HANDLERS_RISPOSTA;
  23201.         String servletListURL = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_HANDLERS_RISPOSTA_LIST;
  23202.         String servletChangeURL = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_HANDLERS_RISPOSTA_CHANGE;
  23203.         String labelHandler = getLabelTipologiaFromFaseMessageHandler(tipologia,false);
  23204.         String labelHandlerDi = labelHandler + " di ";
  23205.        
  23206.         int idLista = Liste.CONFIGURAZIONE_HANDLERS_RISPOSTA;
  23207.         String searchLabel = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_HANDLERS_LABEL;
  23208.        
  23209.         prepareHandlersList(ricerca, lista, ruoloPorta, idPortaS, serviceBinding, tipologia, objectName, servletListURL, servletChangeURL, labelHandler, labelHandlerDi, idLista, searchLabel);
  23210.     }
  23211.    
  23212.     public void prepareHandlersServizioList(ConsoleSearch ricerca, List<ConfigurazioneHandlerBean> lista, TipoPdD ruoloPorta, String idPortaS, ServiceBinding serviceBinding, String tipologia) throws Exception {
  23213.         String objectName = ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_HANDLERS_SERVIZIO;
  23214.         String servletListURL = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_HANDLERS_SERVIZIO_LIST;
  23215.         String servletChangeURL = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_HANDLERS_SERVIZIO_CHANGE;
  23216.         String labelHandler = getLabelTipologiaFromFaseServiceHandler(tipologia);
  23217.         String labelHandlerDi = labelHandler + " di ";
  23218.        
  23219.         int idLista = Liste.CONFIGURAZIONE_HANDLERS_SERVIZIO;
  23220.         String searchLabel = ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_HANDLERS_LABEL;
  23221.        
  23222.         prepareHandlersList(ricerca, lista, ruoloPorta, idPortaS, serviceBinding, tipologia, objectName, servletListURL, servletChangeURL, labelHandler, labelHandlerDi, idLista, searchLabel);
  23223.     }
  23224.    
  23225.    
  23226.     private void prepareHandlersList(ConsoleSearch ricerca, List<ConfigurazioneHandlerBean> lista, TipoPdD ruoloPorta,
  23227.             String idPortaS, ServiceBinding serviceBinding, String tipologia, String objectName, String servletListURL,
  23228.             String servletChangeURL, String labelHandler, String labelHandlerDi, int idLista, String searchLabel)
  23229.             throws Exception {
  23230.         try {
  23231.             List<Parameter> lstParamSession = new ArrayList<>();

  23232.             Parameter parRuoloPorta = null;
  23233.             if(ruoloPorta!=null) {
  23234.                 parRuoloPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_RUOLO_PORTA, ruoloPorta.getTipo());
  23235.                 lstParamSession.add(parRuoloPorta);
  23236.             }
  23237.             Parameter parIdPorta = null;
  23238.             if(idPortaS!=null) {
  23239.                 parIdPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_ID_PORTA, idPortaS);
  23240.                 lstParamSession.add(parIdPorta);
  23241.             }
  23242.             Parameter parServiceBinding = null;
  23243.             if(serviceBinding!=null) {
  23244.                 parServiceBinding = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_SERVICE_BINDING, serviceBinding.name());
  23245.                 lstParamSession.add(parServiceBinding);
  23246.             }
  23247.             Parameter parTipologia = null;
  23248.             if(tipologia!=null) {
  23249.                 parTipologia = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_FASE, tipologia);
  23250.                 lstParamSession.add(parTipologia);
  23251.             }
  23252.            
  23253.             ServletUtils.addListElementIntoSession(this.request, this.session, objectName, lstParamSession);
  23254.            
  23255.             int limit = ricerca.getPageSize(idLista);
  23256.             int offset = ricerca.getIndexIniziale(idLista);
  23257.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  23258.             this.pd.setIndex(offset);
  23259.             this.pd.setPageSize(limit);
  23260.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  23261.            
  23262.            
  23263.             List<Parameter> lstParamPorta = null;
  23264.             if(ruoloPorta!=null) {
  23265.                 lstParamPorta = getTitleListHandler(tipologia, ruoloPorta, idPortaS, serviceBinding, null, servletListURL, labelHandlerDi, labelHandler);
  23266.             }
  23267.            
  23268.            
  23269.             this.pd.setSearchLabel(searchLabel);
  23270.            
  23271.             if(search.equals("")){
  23272.                 this.pd.setSearchDescription("");
  23273.             }

  23274.             // setto la barra del titolo
  23275.             List<Parameter> lstParam = null;
  23276.             if(lstParamPorta!=null) {
  23277.                 lstParam = lstParamPorta;
  23278.             } else {
  23279.                 lstParam = new ArrayList<>();
  23280.                 lstParam.add(new Parameter(labelHandler, null));
  23281.             }
  23282.            
  23283.             if(ruoloPorta == null) {
  23284.                 lstParam.add(0,new Parameter(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE, ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE));
  23285.             }
  23286.            
  23287.             if(!search.equals("")){
  23288.                 if(lstParamSession.size() > 0) {
  23289.                     lstParam.set((lstParam.size() -1), new Parameter(labelHandler, servletListURL, lstParamSession.toArray(new Parameter[lstParamSession.size()])));
  23290.                 } else {
  23291.                     lstParam.set((lstParam.size() -1), new Parameter(labelHandler, servletListURL));
  23292.                 }
  23293.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  23294.             }
  23295.            
  23296.             ServletUtils.setPageDataTitle(this.pd, lstParam);
  23297.            
  23298.             if(ruoloPorta!=null) {
  23299.                 this.impostaComandiMenuContestualeHandler(ruoloPorta, idPortaS);
  23300.             }
  23301.            
  23302.             // controllo eventuali risultati ricerca
  23303.             if (!search.equals("")) {
  23304.                 ServletUtils.enabledPageDataSearch(this.pd, labelHandler, search);
  23305.             }
  23306.        
  23307.             // setto le label delle colonne
  23308.             List<String> lstLabels = new ArrayList<>();
  23309.             if(lista != null && lista.size() > 1)
  23310.                 lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_HANDLERS_POSIZIONE);
  23311.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_HANDLERS_STATO);
  23312.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_HANDLERS_LABEL);
  23313.             lstLabels.add(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_HANDLERS_DESCRIZIONE);
  23314.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  23315.             // preparo i dati
  23316.             List<List<DataElement>> dati = new ArrayList<>();

  23317.             if (lista != null) {
  23318.                 Iterator<ConfigurazioneHandlerBean> it = lista.iterator();
  23319.                 int numeroElementi = lista.size();
  23320.                 int i = 0;
  23321.                 while (it.hasNext()) {
  23322.                     ConfigurazioneHandlerBean handler = it.next();
  23323.                    
  23324.                     Parameter pId = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_ID_HANDLER, handler.getId() + "");
  23325.                     List<Parameter> lstParamEntry = new ArrayList<>();
  23326.                     lstParamEntry.add(pId);
  23327.                     if(lstParamSession.size() > 0) {
  23328.                         lstParamEntry.addAll(lstParamSession);
  23329.                     }
  23330.                    
  23331.                     List<DataElement> e = new ArrayList<>();
  23332.                    
  23333.                     // Posizione
  23334.                     if(lista.size() > 1) {
  23335.                         DataElement de = new DataElement();
  23336.                         de.setWidthPx(48);
  23337.                         de.setType(DataElementType.IMAGE);
  23338.                         DataElementImage imageUp = new DataElementImage();
  23339.                         Parameter pDirezioneSu = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_POSIZIONE,
  23340.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SU);
  23341.                         Parameter pDirezioneGiu = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_POSIZIONE,
  23342.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_GIU);
  23343.                        
  23344.                         List<Parameter> lstParamDirezioneSu = new ArrayList<>();
  23345.                         lstParamDirezioneSu.addAll(lstParamEntry);
  23346.                         lstParamDirezioneSu.add(pDirezioneSu);
  23347.                         List<Parameter> lstParamDirezioneGiu = new ArrayList<>();
  23348.                         lstParamDirezioneGiu.addAll(lstParamEntry);
  23349.                         lstParamDirezioneGiu.add(pDirezioneGiu);
  23350.                        
  23351.                         if(i > 0) {
  23352.                             imageUp.setImage(CostantiControlStation.ICONA_FRECCIA_SU);
  23353.                             imageUp.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_SU);
  23354.                             imageUp.setUrl(servletListURL, lstParamDirezioneSu.toArray(new Parameter[lstParamDirezioneSu.size()]));
  23355.                         }
  23356.                         else {
  23357.                             imageUp.setImage(CostantiControlStation.ICONA_PLACEHOLDER);
  23358.                         }
  23359.                         de.addImage(imageUp);
  23360.                        
  23361.                         if(i < numeroElementi -1) {
  23362.                             DataElementImage imageDown = new DataElementImage();
  23363.                             imageDown.setImage(CostantiControlStation.ICONA_FRECCIA_GIU);
  23364.                             imageDown.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_GIU);
  23365.                             imageDown.setUrl(servletListURL, lstParamDirezioneGiu.toArray(new Parameter[lstParamDirezioneGiu.size()]));
  23366.                             de.addImage(imageDown);
  23367.                         }
  23368.                         de.setValue(handler.getPosizione()+"");
  23369.                         e.add(de);
  23370.                     }
  23371.                    
  23372.                     // Stato
  23373.                     DataElement de = new DataElement();
  23374.                     de.setWidthPx(10);
  23375.                     de.setType(DataElementType.CHECKBOX);
  23376.                     if(handler.getStato()==null // backward compatibility
  23377.                             ||
  23378.                             StatoFunzionalita.ABILITATO.equals(handler.getStato())){
  23379.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  23380.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  23381.                         de.setSelected(CheckboxStatusType.CONFIG_ENABLE);
  23382.                     }
  23383.                     else{
  23384.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  23385.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  23386.                         de.setSelected(CheckboxStatusType.CONFIG_DISABLE);
  23387.                     }
  23388.                     e.add(de);
  23389.                    
  23390.                    
  23391.                     // label
  23392.                     de = new DataElement();
  23393.                     de.setIdToRemove(handler.getTipo());
  23394.                     de.setValue(handler.getNome());
  23395.                     de.setToolTip(handler.getNome());
  23396.                     de.setUrl(servletChangeURL, lstParamEntry.toArray(new Parameter[lstParamEntry.size()]));
  23397.                     e.add(de);

  23398.                     // descrizione
  23399.                     de = new DataElement();
  23400.                     de.setValue(handler.getDescrizioneAbbr());
  23401.                     de.setToolTip(handler.getDescrizione());
  23402.                     e.add(de);
  23403.                    
  23404.                     dati.add(e);
  23405.                     i++;
  23406.                 }
  23407.             }
  23408.            
  23409.             this.pd.setDati(dati);
  23410.             this.pd.setAddButton(true);
  23411.         } catch (Exception e) {
  23412.             this.logError("Exception: " + e.getMessage(), e);
  23413.             throw new DriverControlStationException(e);
  23414.         }
  23415.     }
  23416.    
  23417.     public List<Parameter> getTitleListHandler(String tipologia, TipoPdD ruoloPorta, String idPortaS, ServiceBinding serviceBinding, String nomeOggetto,
  23418.             String servletURL, String labelHandlerDi, String labelHandler) throws Exception{
  23419.         List<Parameter> lstParamPorta = null;
  23420.         if(ruoloPorta!=null) {
  23421.             Long idPorta = Long.parseLong(idPortaS);
  23422.             String labelPerPorta = null;
  23423.             if(TipoPdD.DELEGATA.equals(ruoloPorta)) {
  23424.                 // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  23425.                 Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  23426.                 if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  23427.                
  23428.                 PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(idPorta);
  23429.                 String idporta = myPD.getNome();
  23430.                
  23431.                 MappingFruizionePortaDelegata mappingPD = this.porteDelegateCore.getMappingFruizionePortaDelegata(myPD);
  23432.                 long idSoggetto = myPD.getIdSoggetto().longValue();
  23433.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPD.getIdServizio());
  23434.                 long idFruizione = this.apsCore.getIdFruizioneAccordoServizioParteSpecifica(mappingPD.getIdFruitore(),mappingPD.getIdServizio());
  23435.                
  23436.                 PorteDelegateHelper porteDelegateHelper = new PorteDelegateHelper(this.request, this.pd, this.session);
  23437.                 lstParamPorta = porteDelegateHelper.getTitoloPD(parentPD,idSoggetto +"", idAsps+"", idFruizione+"");
  23438.                
  23439.                 String labelOpzioniAvanzate = null;
  23440.                 if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  23441.                     labelOpzioniAvanzate = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  23442.                             PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_OPZIONI_AVANZATE_DI,
  23443.                             PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_OPZIONI_AVANZATE,
  23444.                             myPD);
  23445.                 }
  23446.                 else {
  23447.                     labelOpzioniAvanzate = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_OPZIONI_AVANZATE_DI+idporta;
  23448.                 }
  23449.                
  23450.                 Parameter pIdPD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + myPD.getId());
  23451.                 Parameter pNomePD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome());
  23452.                 Parameter pIdSoggPD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, myPD.getIdSoggetto() + "");
  23453.                 Parameter pConfigurazioneAltroPorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_ALTRO_PORTA, Costanti.CHECK_BOX_ENABLED_TRUE);
  23454.                 Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps+"");
  23455.                 Parameter pIdFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, idFruizione+ "");
  23456.                 // link alle opzioni avanzate
  23457.                 lstParamPorta.add(new Parameter(labelOpzioniAvanzate, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,
  23458.                         pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneAltroPorta));
  23459.                
  23460.                 labelPerPorta = labelHandler;
  23461.             }
  23462.             else {
  23463.                 Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, this.session, this.request);
  23464.                
  23465.                 PortaApplicativa myPA = this.porteApplicativeCore.getPortaApplicativa(idPorta);
  23466.                 String idporta = myPA.getNome();
  23467.                
  23468.                 MappingErogazionePortaApplicativa mappingPA = this.porteApplicativeCore.getMappingErogazionePortaApplicativa(myPA);
  23469.                 long idSoggetto = myPA.getIdSoggetto().longValue();
  23470.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPA.getIdServizio());
  23471.                
  23472.                 PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(this.request, this.pd, this.session);
  23473.                 lstParamPorta = porteApplicativeHelper.getTitoloPA(parentPA, idSoggetto+"", idAsps+"");
  23474.                
  23475.                 String labelOpzioniAvanzate = null;
  23476.                 if(parentPA!=null && (parentPA.intValue() == PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE)) {
  23477.                     labelOpzioniAvanzate = this.porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  23478.                             PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_OPZIONI_AVANZATE_DI,
  23479.                             PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_OPZIONI_AVANZATE,
  23480.                             myPA);
  23481.                 }
  23482.                 else {
  23483.                     labelOpzioniAvanzate = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_OPZIONI_AVANZATE_DI+idporta;
  23484.                 }
  23485.                
  23486.                 // link alle opzioni avanzate
  23487.                 Parameter pNomePorta = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_PORTA, myPA.getNome());
  23488.                 Parameter pIdSogg = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idSoggetto + "");
  23489.                 Parameter pIdPorta = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, ""+idPorta);
  23490.                 Parameter pIdAsps = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, idAsps+"");
  23491.                 Parameter pConfigurazioneAltroPorta = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONFIGURAZIONE_ALTRO_PORTA, Costanti.CHECK_BOX_ENABLED_TRUE);

  23492.                 lstParamPorta.add(new Parameter(labelOpzioniAvanzate, PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CHANGE,
  23493.                         pIdSogg, pNomePorta, pIdPorta,pIdAsps,pConfigurazioneAltroPorta));
  23494.                
  23495.                 labelPerPorta = labelHandler;
  23496.             }
  23497.            
  23498.             if(nomeOggetto==null) {
  23499.                 lstParamPorta.add(new Parameter(labelPerPorta,null));
  23500.             }
  23501.             else {
  23502.                 List<Parameter> list = new ArrayList<>();
  23503.                 list.add(new Parameter( ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_FASE, tipologia));
  23504.                 list.add(new Parameter( ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_RUOLO_PORTA, ruoloPorta.getTipo()));
  23505.                 list.add(new Parameter( ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_ID_PORTA, idPortaS));
  23506.                 if(serviceBinding!=null) {
  23507.                     list.add(new Parameter( ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_SERVICE_BINDING,serviceBinding.name()));
  23508.                 }
  23509.                 lstParamPorta.add(new Parameter(labelPerPorta, servletURL,  list));
  23510.                 lstParamPorta.add(new Parameter(nomeOggetto,null));
  23511.             }
  23512.         }
  23513.        
  23514.         return lstParamPorta;
  23515.     }
  23516.    
  23517.     public void impostaComandiMenuContestualeHandler(TipoPdD ruoloPorta, String idPortaS) throws Exception{
  23518.        
  23519.         if(ruoloPorta!=null) {
  23520.             Long idPorta = Long.parseLong(idPortaS);
  23521.             if(TipoPdD.DELEGATA.equals(ruoloPorta)) {
  23522.                 PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(idPorta);
  23523.                
  23524.                 MappingFruizionePortaDelegata mappingPD = this.porteDelegateCore.getMappingFruizionePortaDelegata(myPD);
  23525.                 long idSoggetto = myPD.getIdSoggetto().longValue();
  23526.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPD.getIdServizio());
  23527.                 long idFruizione = this.apsCore.getIdFruizioneAccordoServizioParteSpecifica(mappingPD.getIdFruitore(),mappingPD.getIdServizio());
  23528.                
  23529.                 PorteDelegateHelper porteDelegateHelper = new PorteDelegateHelper(this.request, this.pd, this.session);
  23530.                 porteDelegateHelper.impostaComandiMenuContestualePD(idSoggetto +"", idAsps+"", idFruizione+"");
  23531.             }
  23532.             else {
  23533.                 PortaApplicativa myPA = this.porteApplicativeCore.getPortaApplicativa(idPorta);
  23534.                
  23535.                 MappingErogazionePortaApplicativa mappingPA = this.porteApplicativeCore.getMappingErogazionePortaApplicativa(myPA);
  23536.                 long idSoggetto = myPA.getIdSoggetto().longValue();
  23537.                 long idAsps = this.apsCore.getIdAccordoServizioParteSpecifica(mappingPA.getIdServizio());
  23538.                
  23539.                 PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(this.request, this.pd, this.session);
  23540.                 porteApplicativeHelper.impostaComandiMenuContestualePA(idSoggetto+"", idAsps+"");
  23541.             }
  23542.         }
  23543.     }
  23544.    
  23545.     public String getLabelTipologiaFromFaseMessageHandler(String fase, boolean request) {
  23546.         if(fase != null) {
  23547.             return getLabelTipologiaFromFaseMessageHandler(FaseMessageHandler.toEnumConstant(fase), request);
  23548.         }
  23549.         return null;
  23550.     }
  23551.     public String getLabelTipologiaFromFaseMessageHandler(FaseMessageHandler fase, boolean request) {
  23552.         if(fase != null) {
  23553.             String prefix = request ? ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_HANDLERS_RICHIESTA_TITOLO : ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_HANDLERS_RISPOSTA_TITOLO;
  23554.            
  23555.             switch (fase) {
  23556.             case IN:
  23557.                 return MessageFormat.format(prefix, PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_IN_SHORT);
  23558.             case IN_PROTOCOL_INFO:
  23559.                 return MessageFormat.format(prefix, PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_IN_PROTOCOL_INFO_SHORT);
  23560.             case OUT:
  23561.                 return MessageFormat.format(prefix, PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_OUT_SHORT);
  23562.             case POST_OUT:
  23563.                 return MessageFormat.format(prefix, PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_POST_OUT_SHORT);
  23564.             case PRE_IN:
  23565.                 return MessageFormat.format(prefix, PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_PRE_IN_SHORT);
  23566.             }
  23567.         }
  23568.        
  23569.         return null;
  23570.     }
  23571.    
  23572.     public String getLabelTipologiaFromFaseServiceHandler(String fase) {
  23573.         if(fase != null) {
  23574.             return getLabelTipologiaFromFaseServiceHandler(FaseServiceHandler.toEnumConstant(fase));
  23575.         }
  23576.         return null;
  23577.     }
  23578.     public String getLabelTipologiaFromFaseServiceHandler(FaseServiceHandler fase) {
  23579.         if(fase != null) {
  23580.             String prefix = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_HANDLERS_SERVIZIO_TITOLO;
  23581.             switch (fase) {
  23582.             case EXIT:
  23583.                 return MessageFormat.format(prefix, PluginCostanti.FILTRO_SERVICE_HANDLER_LABEL_EXIT);
  23584.             case INIT:
  23585.                 return MessageFormat.format(prefix, PluginCostanti.FILTRO_SERVICE_HANDLER_LABEL_INIT);
  23586.             case INTEGRATION_MANAGER_REQUEST:
  23587.                 return MessageFormat.format(prefix, PluginCostanti.FILTRO_SERVICE_HANDLER_LABEL_INTEGRATION_MANAGER_REQUEST);
  23588.             case INTEGRATION_MANAGER_RESPONSE:
  23589.                 return MessageFormat.format(prefix, PluginCostanti.FILTRO_SERVICE_HANDLER_LABEL_INTEGRATION_MANAGER_RESPONSE);
  23590.             }
  23591.         }
  23592.        
  23593.         return null;
  23594.     }

  23595.     public void addHandlerRichiestaToDati(List<DataElement> dati, TipoOperazione tipoOperazione, String idHandlerS, String nomePlugin,
  23596.             String stato,TipoPdD ruoloPorta, String idPortaS,
  23597.             ServiceBinding serviceBinding, String fase, List<String> tipiPluginGiaUtilizzati, String messaggioValoriNonDisponibili) throws Exception{
  23598.         this.addHandlerToDati(dati, tipoOperazione, idHandlerS, nomePlugin, stato, ruoloPorta, idPortaS,
  23599.                 serviceBinding, fase, PluginCostanti.FILTRO_RUOLO_MESSAGE_HANDLER_VALORE_RICHIESTA, TipoPlugin.MESSAGE_HANDLER, tipiPluginGiaUtilizzati, messaggioValoriNonDisponibili);
  23600.     }
  23601.    
  23602.     public void addHandlerRispostaToDati(List<DataElement> dati, TipoOperazione tipoOperazione, String idHandlerS, String nomePlugin,
  23603.             String stato,  TipoPdD ruoloPorta, String idPortaS,
  23604.             ServiceBinding serviceBinding, String fase, List<String> tipiPluginGiaUtilizzati, String messaggioValoriNonDisponibili) throws Exception{
  23605.         this.addHandlerToDati(dati, tipoOperazione, idHandlerS, nomePlugin, stato, ruoloPorta, idPortaS,
  23606.                 serviceBinding, fase, PluginCostanti.FILTRO_RUOLO_MESSAGE_HANDLER_VALORE_RISPOSTA, TipoPlugin.MESSAGE_HANDLER, tipiPluginGiaUtilizzati, messaggioValoriNonDisponibili);
  23607.     }
  23608.    
  23609.     public void addHandlerServizioToDati(List<DataElement> dati, TipoOperazione tipoOperazione, String idHandlerS, String nomePlugin,
  23610.             String stato, TipoPdD ruoloPorta, String idPortaS,
  23611.             ServiceBinding serviceBinding, String fase, List<String> tipiPluginGiaUtilizzati, String messaggioValoriNonDisponibili) throws Exception{
  23612.         this.addHandlerToDati(dati, tipoOperazione, idHandlerS, nomePlugin, stato, ruoloPorta, idPortaS,
  23613.                 serviceBinding, fase, null, TipoPlugin.SERVICE_HANDLER, tipiPluginGiaUtilizzati, messaggioValoriNonDisponibili);
  23614.     }

  23615.     public void addHandlerToDati(List<DataElement> dati, TipoOperazione tipoOperazione, String idHandlerS, String nomePlugin,
  23616.             String stato, TipoPdD ruoloPorta, String idPortaS,
  23617.             ServiceBinding serviceBinding, String fase, String ruoloHandler, TipoPlugin tipoPlugin, List<String> tipiPluginGiaUtilizzati, String messaggioValoriNonDisponibili) throws Exception{

  23618.        
  23619. //      boolean first = this.isFirstTimeFromHttpParameters(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_FIRST_TIME);
  23620.         DataElement de;
  23621.        
  23622.         // id
  23623.         de = new DataElement();
  23624.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_HANDLERS_ID_HANDLER);
  23625.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_ID_HANDLER);
  23626.         de.setType(DataElementType.HIDDEN);
  23627.         if(tipoOperazione.equals(TipoOperazione.ADD)) {
  23628.             de.setValue("");
  23629.         } else {
  23630.             de.setValue(idHandlerS);
  23631.         }
  23632.         dati.add(de);
  23633.        
  23634.         de = new DataElement();
  23635.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_RUOLO_PORTA);
  23636.         de.setValue(ruoloPorta!=null ? ruoloPorta.getTipo() : null);
  23637.         de.setType(DataElementType.HIDDEN);
  23638.         dati.add(de);
  23639.        
  23640.         de = new DataElement();
  23641.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_ID_PORTA);
  23642.         de.setValue(idPortaS);
  23643.         de.setType(DataElementType.HIDDEN);
  23644.         dati.add(de);
  23645.        
  23646.         if(serviceBinding!=null) {
  23647.             de = new DataElement();
  23648.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_SERVICE_BINDING);
  23649.             de.setValue(serviceBinding.name());
  23650.             de.setType(DataElementType.HIDDEN);
  23651.             dati.add(de);
  23652.         }
  23653.        
  23654.         de = new DataElement();
  23655.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_FASE);
  23656.         de.setValue(fase);
  23657.         de.setType(DataElementType.HIDDEN);
  23658.         dati.add(de);
  23659.        
  23660.         // Informazioni Generali
  23661.         de = new DataElement();
  23662.         de.setType(DataElementType.TITLE);
  23663.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_HANDLERS_INFORMAZIONI_GENERALI);
  23664.         dati.add(de);
  23665.        
  23666.         if(tipoOperazione.equals(TipoOperazione.ADD)) {
  23667.         // plugin select
  23668.         this.addCustomFieldConValoriDaEscludere(tipoPlugin, ruoloHandler, fase, "", ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_PLUGIN, GruppoIntegrazione.PLUGIN.getCompactLabel(),
  23669.                 nomePlugin, false, dati, false, tipiPluginGiaUtilizzati, messaggioValoriNonDisponibili);
  23670.         } else {
  23671.             de = new DataElement();
  23672.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_PLUGIN);
  23673.             de.setValue(nomePlugin);
  23674.             de.setType(DataElementType.HIDDEN);
  23675.             dati.add(de);
  23676.            
  23677.             de = new DataElement();
  23678.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_PLUGIN + "txt");
  23679.             de.setValue(nomePlugin);
  23680.             de.setType(DataElementType.TEXT);
  23681.             de.setLabel(GruppoIntegrazione.PLUGIN.getCompactLabel());
  23682.             dati.add(de);
  23683.            
  23684.         }
  23685.         // stato
  23686.         de = new DataElement();
  23687.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_HANDLERS_STATO);
  23688.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_STATO);
  23689.         de.setType(DataElementType.SELECT);
  23690.         String [] statoValues = CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA;
  23691.         de.setSelected(stato);
  23692.         de.setLabels(statoValues);
  23693.         de.setValues(statoValues);
  23694.         dati.add(de);
  23695.        
  23696.     }
  23697.     public boolean handlerRichiestaCheckData(TipoOperazione tipoOp, ConfigurazioneHandlerBean oldHandler, String nomePlugin, String stato,
  23698.             TipoPdD ruoloPorta, Long idPorta, String fase, String tipo, String messaggioHandlerRichiestaDuplicato) throws Exception{
  23699.         return handlerCheckData(tipoOp, oldHandler, nomePlugin, stato, ruoloPorta, idPorta, fase, tipo, messaggioHandlerRichiestaDuplicato);
  23700.     }
  23701.    
  23702.     public boolean handlerRispostaCheckData(TipoOperazione tipoOp, ConfigurazioneHandlerBean oldHandler, String nomePlugin, String stato,
  23703.             TipoPdD ruoloPorta, Long idPorta, String fase, String tipo, String messaggioHandlerRichiestaDuplicato) throws Exception{
  23704.         return handlerCheckData(tipoOp, oldHandler, nomePlugin, stato, ruoloPorta, idPorta, fase, tipo, messaggioHandlerRichiestaDuplicato);
  23705.     }
  23706.    
  23707.     public boolean handlerServizioCheckData(TipoOperazione tipoOp, ConfigurazioneHandlerBean oldHandler, String nomePlugin, String stato,
  23708.             TipoPdD ruoloPorta, Long idPorta, String fase, String tipo, String messaggioHandlerRichiestaDuplicato) throws Exception{
  23709.         return handlerCheckData(tipoOp, oldHandler, nomePlugin, stato, ruoloPorta, idPorta, fase, tipo, messaggioHandlerRichiestaDuplicato);
  23710.     }
  23711.    
  23712.     private boolean handlerCheckData(TipoOperazione tipoOp, ConfigurazioneHandlerBean oldHandler, String nomePlugin, String stato,
  23713.             TipoPdD ruoloPorta, Long idPorta, String fase, String tipo, String messaggioHandlerRichiestaDuplicato) throws Exception{
  23714.         try {
  23715.            
  23716.             /* ******** CONTROLLO PLUGIN *************** */
  23717.            
  23718.             if(nomePlugin == null || nomePlugin.equals(CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_VALORE_UNDEFINED)) {
  23719.                 this.pd.setMessage("Indicare un valore nel campo '"+GruppoIntegrazione.PLUGIN.getCompactLabel()+"'");
  23720.                 return false;
  23721.             }
  23722.            
  23723.             // stato
  23724.             if(stato == null) {
  23725.                 this.pd.setMessage("Indicare un valore nel campo '"+ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_HANDLERS_STATO+"'");
  23726.                 return false;
  23727.             }

  23728.            
  23729.             // altri parametri
  23730.             boolean existsHandler = this.confCore.existsHandlerRichiesta(fase, ruoloPorta, idPorta, tipo);
  23731.             // controllo esistenza handler con lo stesso nome          
  23732.             if (tipoOp.equals(TipoOperazione.ADD)) {
  23733.                 if (existsHandler) {
  23734.                     this.pd.setMessage(messaggioHandlerRichiestaDuplicato);
  23735.                     return false;
  23736.                 }
  23737.             }
  23738.            
  23739.             return true;
  23740.         } catch (Exception e) {
  23741.             this.logError("Exception: " + e.getMessage(), e);
  23742.             throw new DriverControlStationException(e);
  23743.         }
  23744.     }
  23745.     public void updateHandler(ConfigurazioneHandler handlerDestinazione, ConfigurazioneHandler handlerSorgente,
  23746.             TipoOperazione tipoOperazione) {
  23747.         handlerDestinazione.setPosizione(handlerSorgente.getPosizione());
  23748.         handlerDestinazione.setStato(handlerSorgente.getStato());
  23749.         handlerDestinazione.setTipo(handlerSorgente.getTipo());
  23750.         //handlerDestinazione.setId(handlerSorgente.getId());
  23751.     }
  23752.    
  23753.     public void addDescrizioneVerificaConnettivitaToDati(List<DataElement> dati, GenericProperties genericProperties,
  23754.             String server, boolean registro, String aliasConnettore) throws Exception {
  23755.        
  23756.         List<Connettore> l = ConnettoreCheck.convertPolicyToConnettore(genericProperties, this.log);
  23757.         if(l!=null && !l.isEmpty()) {
  23758.             for (Connettore connettore : l) {
  23759.                
  23760.                 String tipo = ConnettoreCheck.getPropertyValue(connettore, ConnettoreCheck.POLICY_TIPO_ENDPOINT);
  23761.                                
  23762.                 List<Parameter> downloadCertServerParameters = new ArrayList<>();
  23763.                
  23764.                 downloadCertServerParameters.add(new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_CERTIFICATI_SERVER_TOKEN_NOME, genericProperties.getNome()));
  23765.                 downloadCertServerParameters.add(new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_CERTIFICATI_SERVER_TOKEN_TIPOLOGIA, genericProperties.getTipologia()));
  23766.                 downloadCertServerParameters.add(new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_CERTIFICATI_SERVER_TOKEN_TIPO, tipo!=null ? tipo : ""));
  23767.                
  23768.                 this.addDescrizioneVerificaConnettivitaToDati(dati, connettore,
  23769.                         server, registro, aliasConnettore,
  23770.                         downloadCertServerParameters,
  23771.                         true, true);
  23772.                                
  23773.             }
  23774.         }
  23775.        
  23776.     }
  23777.     public List<DataElement> addTokenPolicyHiddenToDati(List<DataElement> dati, String id, String infoType) {
  23778.        
  23779.         DataElement de = new DataElement();
  23780.         de.setLabel(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_ID);
  23781.         de.setValue(id);
  23782.         de.setType(DataElementType.HIDDEN);
  23783.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_ID);
  23784.         dati.add(de);
  23785.        
  23786.         de = new DataElement();
  23787.         de.setLabel(ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE);
  23788.         de.setValue(infoType);
  23789.         de.setType(DataElementType.HIDDEN);
  23790.         de.setName(ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE);
  23791.         dati.add(de);
  23792.        
  23793.         return dati;
  23794.     }
  23795.    
  23796.     public void addVisualizzaRuntimeButton(List<DataElement> e, String servletName, List<Parameter> parameters) {
  23797.         this.addAzioneButton(e, DataElementType.IMAGE,
  23798.                 ConfigurazioneCostanti.ICONA_VISUALIZZA_RUNTIME_ALLARME_TOOLTIP,
  23799.                 ConfigurazioneCostanti.ICONA_VISUALIZZA_RUNTIME_ALLARME, servletName,parameters);
  23800.     }
  23801. }