ConsoleHelper.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;

  21. import java.io.ByteArrayInputStream;
  22. import java.io.ByteArrayOutputStream;
  23. import java.io.File;
  24. import java.io.FileInputStream;
  25. import java.io.FileOutputStream;
  26. import java.io.InputStream;
  27. import java.lang.reflect.Constructor;
  28. import java.net.URL;
  29. import java.sql.Connection;
  30. import java.text.MessageFormat;
  31. import java.util.ArrayList;
  32. import java.util.Arrays;
  33. import java.util.Collections;
  34. import java.util.Date;
  35. import java.util.Enumeration;
  36. import java.util.HashMap;
  37. import java.util.Iterator;
  38. import java.util.List;
  39. import java.util.Map;
  40. import java.util.Properties;
  41. import java.util.Scanner;
  42. import java.util.UUID;
  43. import java.util.stream.Collectors;

  44. import javax.mail.BodyPart;
  45. import javax.servlet.http.HttpServletRequest;
  46. import javax.servlet.http.HttpSession;

  47. import org.apache.commons.io.FilenameUtils;
  48. import org.apache.commons.io.IOUtils;
  49. import org.apache.commons.lang.StringEscapeUtils;
  50. import org.apache.commons.lang.StringUtils;
  51. import org.openspcoop2.core.allarmi.Allarme;
  52. import org.openspcoop2.core.allarmi.constants.RuoloPorta;
  53. import org.openspcoop2.core.allarmi.constants.StatoAllarme;
  54. import org.openspcoop2.core.allarmi.utils.AllarmiConverterUtils;
  55. import org.openspcoop2.core.commons.DBUtils;
  56. import org.openspcoop2.core.commons.Filtri;
  57. import org.openspcoop2.core.commons.ISearch;
  58. import org.openspcoop2.core.commons.Liste;
  59. import org.openspcoop2.core.commons.ModalitaIdentificazione;
  60. import org.openspcoop2.core.commons.SearchUtils;
  61. import org.openspcoop2.core.config.AttributeAuthority;
  62. import org.openspcoop2.core.config.AutorizzazioneScope;
  63. import org.openspcoop2.core.config.CanaleConfigurazione;
  64. import org.openspcoop2.core.config.CanaliConfigurazione;
  65. import org.openspcoop2.core.config.Configurazione;
  66. import org.openspcoop2.core.config.ConfigurazionePortaHandler;
  67. import org.openspcoop2.core.config.ConfigurazioneTracciamentoPorta;
  68. import org.openspcoop2.core.config.ConfigurazioneUrlInvocazione;
  69. import org.openspcoop2.core.config.Connettore;
  70. import org.openspcoop2.core.config.CorrelazioneApplicativa;
  71. import org.openspcoop2.core.config.CorrelazioneApplicativaRisposta;
  72. import org.openspcoop2.core.config.CorsConfigurazione;
  73. import org.openspcoop2.core.config.CorsConfigurazioneHeaders;
  74. import org.openspcoop2.core.config.CorsConfigurazioneMethods;
  75. import org.openspcoop2.core.config.CorsConfigurazioneOrigin;
  76. import org.openspcoop2.core.config.Dump;
  77. import org.openspcoop2.core.config.DumpConfigurazione;
  78. import org.openspcoop2.core.config.DumpConfigurazioneRegola;
  79. import org.openspcoop2.core.config.GenericProperties;
  80. import org.openspcoop2.core.config.GestioneToken;
  81. import org.openspcoop2.core.config.MessageSecurity;
  82. import org.openspcoop2.core.config.MtomProcessor;
  83. import org.openspcoop2.core.config.MtomProcessorFlowParameter;
  84. import org.openspcoop2.core.config.PortaApplicativa;
  85. import org.openspcoop2.core.config.PortaApplicativaAutorizzazioneToken;
  86. import org.openspcoop2.core.config.PortaApplicativaServizioApplicativo;
  87. import org.openspcoop2.core.config.PortaDelegata;
  88. import org.openspcoop2.core.config.PortaDelegataAutorizzazioneToken;
  89. import org.openspcoop2.core.config.PortaDelegataLocalForward;
  90. import org.openspcoop2.core.config.PortaTracciamento;
  91. import org.openspcoop2.core.config.Property;
  92. import org.openspcoop2.core.config.Proprieta;
  93. import org.openspcoop2.core.config.ResponseCachingConfigurazione;
  94. import org.openspcoop2.core.config.ResponseCachingConfigurazioneControl;
  95. import org.openspcoop2.core.config.ResponseCachingConfigurazioneGenerale;
  96. import org.openspcoop2.core.config.ResponseCachingConfigurazioneHashGenerator;
  97. import org.openspcoop2.core.config.ResponseCachingConfigurazioneRegola;
  98. import org.openspcoop2.core.config.ServizioApplicativo;
  99. import org.openspcoop2.core.config.Soggetto;
  100. import org.openspcoop2.core.config.TrasformazioneRegola;
  101. import org.openspcoop2.core.config.TrasformazioneRegolaRichiesta;
  102. import org.openspcoop2.core.config.TrasformazioneRegolaRisposta;
  103. import org.openspcoop2.core.config.TrasformazioneSoap;
  104. import org.openspcoop2.core.config.TrasformazioneSoapRisposta;
  105. import org.openspcoop2.core.config.Trasformazioni;
  106. import org.openspcoop2.core.config.ValidazioneContenutiApplicativi;
  107. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  108. import org.openspcoop2.core.config.constants.MTOMProcessorType;
  109. import org.openspcoop2.core.config.constants.PluginCostanti;
  110. import org.openspcoop2.core.config.constants.RuoloTipoMatch;
  111. import org.openspcoop2.core.config.constants.ScopeTipoMatch;
  112. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  113. import org.openspcoop2.core.config.constants.StatoFunzionalitaBloccante;
  114. import org.openspcoop2.core.config.constants.StatoFunzionalitaCacheDigestQueryParameter;
  115. import org.openspcoop2.core.config.constants.StatoFunzionalitaConPersonalizzazione;
  116. import org.openspcoop2.core.config.constants.StatoFunzionalitaConWarning;
  117. import org.openspcoop2.core.config.constants.TipoAutenticazione;
  118. import org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal;
  119. import org.openspcoop2.core.config.constants.TipoAutorizzazione;
  120. import org.openspcoop2.core.config.constants.TipoBehaviour;
  121. import org.openspcoop2.core.config.constants.TipoGestioneCORS;
  122. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  123. import org.openspcoop2.core.config.driver.DriverConfigurazioneNotFound;
  124. import org.openspcoop2.core.config.driver.db.IDServizioApplicativoDB;
  125. import org.openspcoop2.core.config.utils.TracciamentoCompatibilitaFiltroEsiti;
  126. import org.openspcoop2.core.constants.CostantiConnettori;
  127. import org.openspcoop2.core.constants.CostantiDB;
  128. import org.openspcoop2.core.constants.CostantiLabel;
  129. import org.openspcoop2.core.constants.TipiConnettore;
  130. import org.openspcoop2.core.constants.TipoPdD;
  131. import org.openspcoop2.core.controllo_traffico.AttivazionePolicy;
  132. import org.openspcoop2.core.controllo_traffico.ConfigurazionePolicy;
  133. import org.openspcoop2.core.controllo_traffico.constants.RuoloPolicy;
  134. import org.openspcoop2.core.controllo_traffico.constants.TipoRisorsaPolicyAttiva;
  135. import org.openspcoop2.core.controllo_traffico.driver.PolicyGroupByActiveThreadsType;
  136. import org.openspcoop2.core.id.IDAccordo;
  137. import org.openspcoop2.core.id.IDAccordoCooperazione;
  138. import org.openspcoop2.core.id.IDFruizione;
  139. import org.openspcoop2.core.id.IDGruppo;
  140. import org.openspcoop2.core.id.IDPortaApplicativa;
  141. import org.openspcoop2.core.id.IDPortaDelegata;
  142. import org.openspcoop2.core.id.IDRuolo;
  143. import org.openspcoop2.core.id.IDServizio;
  144. import org.openspcoop2.core.id.IDServizioApplicativo;
  145. import org.openspcoop2.core.id.IDSoggetto;
  146. import org.openspcoop2.core.mapping.MappingErogazionePortaApplicativa;
  147. import org.openspcoop2.core.mapping.MappingFruizionePortaDelegata;
  148. import org.openspcoop2.core.mvc.properties.Config;
  149. import org.openspcoop2.core.mvc.properties.constants.ItemType;
  150. import org.openspcoop2.core.mvc.properties.provider.ExternalResources;
  151. import org.openspcoop2.core.mvc.properties.provider.ProviderException;
  152. import org.openspcoop2.core.mvc.properties.provider.ProviderValidationException;
  153. import org.openspcoop2.core.mvc.properties.utils.ConfigManager;
  154. import org.openspcoop2.core.mvc.properties.utils.PropertiesSourceConfiguration;
  155. import org.openspcoop2.core.plugins.Plugin;
  156. import org.openspcoop2.core.plugins.constants.TipoPlugin;
  157. import org.openspcoop2.core.registry.AccordoCooperazione;
  158. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  159. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  160. import org.openspcoop2.core.registry.Azione;
  161. import org.openspcoop2.core.registry.Documento;
  162. import org.openspcoop2.core.registry.Fruitore;
  163. import org.openspcoop2.core.registry.Operation;
  164. import org.openspcoop2.core.registry.PortType;
  165. import org.openspcoop2.core.registry.ProprietaOggetto;
  166. import org.openspcoop2.core.registry.ProtocolProperty;
  167. import org.openspcoop2.core.registry.Resource;
  168. import org.openspcoop2.core.registry.Ruolo;
  169. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  170. import org.openspcoop2.core.registry.beans.ResourceSintetica;
  171. import org.openspcoop2.core.registry.constants.CostantiRegistroServizi;
  172. import org.openspcoop2.core.registry.constants.FormatoSpecifica;
  173. import org.openspcoop2.core.registry.constants.HttpMethod;
  174. import org.openspcoop2.core.registry.constants.RuoliDocumento;
  175. import org.openspcoop2.core.registry.constants.RuoloContesto;
  176. import org.openspcoop2.core.registry.constants.RuoloTipologia;
  177. import org.openspcoop2.core.registry.constants.ScopeContesto;
  178. import org.openspcoop2.core.registry.constants.StatiAccordo;
  179. import org.openspcoop2.core.registry.constants.TipiDocumentoSicurezza;
  180. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  181. import org.openspcoop2.core.registry.driver.DriverRegistroServiziNotFound;
  182. import org.openspcoop2.core.registry.driver.FiltroRicercaAccordi;
  183. import org.openspcoop2.core.registry.driver.FiltroRicercaGruppi;
  184. import org.openspcoop2.core.registry.driver.FiltroRicercaRuoli;
  185. import org.openspcoop2.core.registry.driver.FiltroRicercaScope;
  186. import org.openspcoop2.core.registry.driver.IDAccordoCooperazioneFactory;
  187. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  188. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  189. import org.openspcoop2.core.transazioni.utils.PropertiesSerializator;
  190. import org.openspcoop2.generic_project.exception.NotFoundException;
  191. import org.openspcoop2.message.constants.MessageType;
  192. import org.openspcoop2.message.constants.ServiceBinding;
  193. import org.openspcoop2.monitor.engine.alarm.wrapper.ConfigurazioneAllarmeBean;
  194. import org.openspcoop2.monitor.engine.condition.EsitoUtils;
  195. import org.openspcoop2.pdd.config.CostantiProprieta;
  196. import org.openspcoop2.pdd.core.autenticazione.ParametriAutenticazioneApiKey;
  197. import org.openspcoop2.pdd.core.autenticazione.ParametriAutenticazionePrincipal;
  198. import org.openspcoop2.pdd.core.autorizzazione.CostantiAutorizzazione;
  199. import org.openspcoop2.pdd.core.behaviour.built_in.load_balance.ConfigurazioneLoadBalancer;
  200. import org.openspcoop2.pdd.core.behaviour.built_in.load_balance.LoadBalancerType;
  201. import org.openspcoop2.pdd.core.behaviour.built_in.load_balance.sticky.StickyUtils;
  202. import org.openspcoop2.pdd.core.behaviour.conditional.ConditionalUtils;
  203. import org.openspcoop2.pdd.core.connettori.ConnettoreCheck;
  204. import org.openspcoop2.pdd.core.connettori.ConnettoreNULL;
  205. import org.openspcoop2.pdd.core.connettori.ConnettoreNULLEcho;
  206. import org.openspcoop2.pdd.core.connettori.ConnettoreStatus;
  207. import org.openspcoop2.pdd.core.controllo_traffico.policy.config.PolicyConfiguration;
  208. import org.openspcoop2.pdd.core.dynamic.DynamicHelperCostanti;
  209. import org.openspcoop2.pdd.core.dynamic.DynamicUtils;
  210. import org.openspcoop2.pdd.core.integrazione.GruppoIntegrazione;
  211. import org.openspcoop2.pdd.core.integrazione.TipoIntegrazione;
  212. import org.openspcoop2.pdd.core.token.TokenUtilities;
  213. import org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione;
  214. import org.openspcoop2.pdd.logger.LogLevels;
  215. import org.openspcoop2.protocol.engine.ProtocolFactoryManager;
  216. import org.openspcoop2.protocol.engine.utils.NamingUtils;
  217. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  218. import org.openspcoop2.protocol.sdk.ProtocolException;
  219. import org.openspcoop2.protocol.sdk.constants.ArchiveType;
  220. import org.openspcoop2.protocol.sdk.constants.ConsoleItemType;
  221. import org.openspcoop2.protocol.sdk.constants.ConsoleItemValueType;
  222. import org.openspcoop2.protocol.sdk.constants.ConsoleOperationType;
  223. import org.openspcoop2.protocol.sdk.constants.EsitoTransazioneName;
  224. import org.openspcoop2.protocol.sdk.constants.FunzionalitaProtocollo;
  225. import org.openspcoop2.protocol.sdk.properties.AbstractConsoleItem;
  226. import org.openspcoop2.protocol.sdk.properties.AbstractProperty;
  227. import org.openspcoop2.protocol.sdk.properties.BaseConsoleItem;
  228. import org.openspcoop2.protocol.sdk.properties.BinaryConsoleItem;
  229. import org.openspcoop2.protocol.sdk.properties.BinaryProperty;
  230. import org.openspcoop2.protocol.sdk.properties.BooleanConsoleItem;
  231. import org.openspcoop2.protocol.sdk.properties.BooleanProperty;
  232. import org.openspcoop2.protocol.sdk.properties.ConsoleConfiguration;
  233. import org.openspcoop2.protocol.sdk.properties.IConsoleDynamicConfiguration;
  234. import org.openspcoop2.protocol.sdk.properties.IConsoleHelper;
  235. import org.openspcoop2.protocol.sdk.properties.NumberConsoleItem;
  236. import org.openspcoop2.protocol.sdk.properties.NumberProperty;
  237. import org.openspcoop2.protocol.sdk.properties.ProtocolProperties;
  238. import org.openspcoop2.protocol.sdk.properties.ProtocolPropertiesFactory;
  239. import org.openspcoop2.protocol.sdk.properties.ProtocolPropertiesUtils;
  240. import org.openspcoop2.protocol.sdk.properties.StringConsoleItem;
  241. import org.openspcoop2.protocol.sdk.properties.StringProperty;
  242. import org.openspcoop2.protocol.sdk.properties.SubtitleConsoleItem;
  243. import org.openspcoop2.protocol.sdk.properties.TitleConsoleItem;
  244. import org.openspcoop2.protocol.sdk.registry.IConfigIntegrationReader;
  245. import org.openspcoop2.protocol.sdk.registry.IRegistryReader;
  246. import org.openspcoop2.protocol.sdk.validator.ValidazioneResult;
  247. import org.openspcoop2.protocol.utils.EsitiConfigUtils;
  248. import org.openspcoop2.protocol.utils.EsitiProperties;
  249. import org.openspcoop2.protocol.utils.ModIUtils;
  250. import org.openspcoop2.utils.BooleanNullable;
  251. import org.openspcoop2.utils.UtilsException;
  252. import org.openspcoop2.utils.certificate.byok.BYOKManager;
  253. import org.openspcoop2.utils.certificate.ocsp.OCSPManager;
  254. import org.openspcoop2.utils.mime.MimeMultipart;
  255. import org.openspcoop2.utils.properties.PropertiesUtilities;
  256. import org.openspcoop2.utils.regexp.RegExpException;
  257. import org.openspcoop2.utils.regexp.RegExpNotFoundException;
  258. import org.openspcoop2.utils.regexp.RegExpNotValidException;
  259. import org.openspcoop2.utils.regexp.RegularExpressionEngine;
  260. import org.openspcoop2.utils.resources.Charset;
  261. import org.openspcoop2.utils.resources.FileSystemUtilities;
  262. import org.openspcoop2.utils.transport.http.HttpRequestMethod;
  263. import org.openspcoop2.utils.xml.AbstractXPathExpressionEngine;
  264. import org.openspcoop2.utils.xml.XPathExpressionEngine;
  265. import org.openspcoop2.utils.xml2json.JsonXmlPathExpressionEngine;
  266. import org.openspcoop2.web.ctrlstat.config.ConsoleProperties;
  267. import org.openspcoop2.web.ctrlstat.core.AutorizzazioneUtilities;
  268. import org.openspcoop2.web.ctrlstat.core.Connettori;
  269. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  270. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  271. import org.openspcoop2.web.ctrlstat.core.ControlStationLogger;
  272. import org.openspcoop2.web.ctrlstat.core.DBManager;
  273. import org.openspcoop2.web.ctrlstat.core.InitListener;
  274. import org.openspcoop2.web.ctrlstat.core.Utilities;
  275. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  276. import org.openspcoop2.web.ctrlstat.costanti.InUsoType;
  277. import org.openspcoop2.web.ctrlstat.costanti.TipologiaConnettori;
  278. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationException;
  279. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationNotFound;
  280. import org.openspcoop2.web.ctrlstat.plugins.ExtendedMenuItem;
  281. import org.openspcoop2.web.ctrlstat.plugins.IExtendedMenu;
  282. import org.openspcoop2.web.ctrlstat.servlet.ac.AccordiCooperazioneCore;
  283. import org.openspcoop2.web.ctrlstat.servlet.ac.AccordiCooperazioneCostanti;
  284. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCore;
  285. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCostanti;
  286. import org.openspcoop2.web.ctrlstat.servlet.apc.api.ApiCostanti;
  287. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCore;
  288. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCostanti;
  289. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaFruitoriPorteDelegateMappingInfo;
  290. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaPorteApplicativeMappingInfo;
  291. import org.openspcoop2.web.ctrlstat.servlet.aps.erogazioni.ErogazioniCostanti;
  292. import org.openspcoop2.web.ctrlstat.servlet.archivi.ArchiviCore;
  293. import org.openspcoop2.web.ctrlstat.servlet.archivi.ArchiviCostanti;
  294. import org.openspcoop2.web.ctrlstat.servlet.archivi.ExporterUtils;
  295. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  296. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCostanti;
  297. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCore;
  298. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCostanti;
  299. import org.openspcoop2.web.ctrlstat.servlet.gruppi.GruppiCore;
  300. import org.openspcoop2.web.ctrlstat.servlet.gruppi.GruppiCostanti;
  301. import org.openspcoop2.web.ctrlstat.servlet.monitor.MonitorCostanti;
  302. import org.openspcoop2.web.ctrlstat.servlet.operazioni.OperazioniCore;
  303. import org.openspcoop2.web.ctrlstat.servlet.operazioni.OperazioniCostanti;
  304. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCore;
  305. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCostanti;
  306. import org.openspcoop2.web.ctrlstat.servlet.pd.PorteDelegateCore;
  307. import org.openspcoop2.web.ctrlstat.servlet.pd.PorteDelegateCostanti;
  308. import org.openspcoop2.web.ctrlstat.servlet.pdd.PddCore;
  309. import org.openspcoop2.web.ctrlstat.servlet.pdd.PddCostanti;
  310. import org.openspcoop2.web.ctrlstat.servlet.protocol_properties.ProtocolPropertiesCore;
  311. import org.openspcoop2.web.ctrlstat.servlet.protocol_properties.ProtocolPropertiesCostanti;
  312. import org.openspcoop2.web.ctrlstat.servlet.protocol_properties.ProtocolPropertiesUtilities;
  313. import org.openspcoop2.web.ctrlstat.servlet.remote_stores.RemoteStoresCore;
  314. import org.openspcoop2.web.ctrlstat.servlet.remote_stores.RemoteStoresCostanti;
  315. import org.openspcoop2.web.ctrlstat.servlet.ruoli.RuoliCore;
  316. import org.openspcoop2.web.ctrlstat.servlet.ruoli.RuoliCostanti;
  317. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCore;
  318. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCostanti;
  319. import org.openspcoop2.web.ctrlstat.servlet.scope.ScopeCore;
  320. import org.openspcoop2.web.ctrlstat.servlet.scope.ScopeCostanti;
  321. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  322. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCostanti;
  323. import org.openspcoop2.web.ctrlstat.servlet.utenti.UtentiCore;
  324. import org.openspcoop2.web.ctrlstat.servlet.utenti.UtentiCostanti;
  325. import org.openspcoop2.web.ctrlstat.servlet.utils.UtilsCostanti;
  326. import org.openspcoop2.web.lib.audit.web.AuditCostanti;
  327. import org.openspcoop2.web.lib.audit.web.AuditHelper;
  328. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  329. import org.openspcoop2.web.lib.mvc.CheckboxStatusType;
  330. import org.openspcoop2.web.lib.mvc.Costanti;
  331. import org.openspcoop2.web.lib.mvc.DataElement;
  332. import org.openspcoop2.web.lib.mvc.DataElement.STATO_APERTURA_SEZIONI;
  333. import org.openspcoop2.web.lib.mvc.DataElementInfo;
  334. import org.openspcoop2.web.lib.mvc.DataElementType;
  335. import org.openspcoop2.web.lib.mvc.Dialog;
  336. import org.openspcoop2.web.lib.mvc.Dialog.BodyElement;
  337. import org.openspcoop2.web.lib.mvc.MenuEntry;
  338. import org.openspcoop2.web.lib.mvc.PageData;
  339. import org.openspcoop2.web.lib.mvc.Parameter;
  340. import org.openspcoop2.web.lib.mvc.ServletUtils;
  341. import org.openspcoop2.web.lib.mvc.TargetType;
  342. import org.openspcoop2.web.lib.mvc.TipoOperazione;
  343. import org.openspcoop2.web.lib.mvc.properties.beans.BaseItemBean;
  344. import org.openspcoop2.web.lib.mvc.properties.beans.ConfigBean;
  345. import org.openspcoop2.web.lib.mvc.properties.exception.UserInputValidationException;
  346. import org.openspcoop2.web.lib.users.dao.InterfaceType;
  347. import org.openspcoop2.web.lib.users.dao.PermessiUtente;
  348. import org.openspcoop2.web.lib.users.dao.User;
  349. import org.slf4j.Logger;

  350. /**
  351.  * ctrlstatHelper
  352.  *
  353.  * @author Andrea Poli (apoli@link.it)
  354.  * @author Stefano Corallo (corallo@link.it)
  355.  * @author Sandra Giangrandi (sandra@link.it)
  356.  * @author $Author$
  357.  * @version $Rev$, $Date$
  358.  *
  359.  */
  360. public class ConsoleHelper implements IConsoleHelper {
  361.    
  362.     protected HttpServletRequest request;
  363.     @Override
  364.     public HttpServletRequest getRequest() {
  365.         return this.request;
  366.     }
  367.     protected PageData pd;
  368.     public PageData getPd() {
  369.         return this.pd;
  370.     }
  371.     protected HttpSession session;
  372.     @Override
  373.     public HttpSession getSession() {
  374.         return this.session;
  375.     }
  376.    
  377.     protected void logError(String msg,Throwable e) {
  378.         if(this.log!=null) {
  379.             this.log.error(msg,e);
  380.         }
  381.     }
  382.     protected void logError(String msg) {
  383.         if(this.log!=null) {
  384.             this.log.error(msg);
  385.         }
  386.     }
  387.    
  388.     @Override
  389.     public void setMessage(String message, boolean append) throws DriverControlStationException {
  390.         this.setMessage(message, append, null);
  391.     }
  392.     @Override
  393.     public void setMessage(String message, boolean append, String type) throws DriverControlStationException {
  394.        
  395.         org.openspcoop2.web.lib.mvc.MessageType messageType = org.openspcoop2.web.lib.mvc.MessageType.ERROR;
  396.         if(type!=null) {
  397.             try {
  398.                 messageType = org.openspcoop2.web.lib.mvc.MessageType.fromValue(type);
  399.             }catch(Exception t) {
  400.                 // ignore
  401.             }
  402.             if(messageType==null) {
  403.                 try {
  404.                     messageType = org.openspcoop2.web.lib.mvc.MessageType.valueOf(type.toUpperCase());
  405.                 }catch(Exception t) {
  406.                     // ignore
  407.                 }
  408.             }
  409.             if(messageType==null) {
  410.                 messageType = org.openspcoop2.web.lib.mvc.MessageType.ERROR;
  411.             }
  412.         }
  413.        
  414.         if(this.pd!=null) {
  415.             StringBuilder sb = new StringBuilder();
  416.             if(append) {
  417.                 String actualMsg = this.pd.getMessage();
  418.                 if(actualMsg!=null && StringUtils.isNotEmpty(actualMsg)) {
  419.                     sb.append(actualMsg);
  420.                     sb.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  421.                 }
  422.             }
  423.             sb.append(message);
  424.             this.pd.setMessage(message, messageType);
  425.         }
  426.     }
  427.    
  428.     @Override
  429.     public boolean isEditModeInProgress() throws DriverControlStationException{
  430.         String editMode = this.getParameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME);
  431.         return ServletUtils.isEditModeInProgress(editMode);    
  432.     }

  433.     @Override
  434.     public boolean isEditModeFinished() throws DriverControlStationException{
  435.         String editMode = this.getParameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME);
  436.         return ServletUtils.isEditModeFinished(editMode);      
  437.     }
  438.    
  439.     @Override
  440.     public String getPostBackElementName() throws DriverControlStationException{
  441.         return this.getParameter(Costanti.POSTBACK_ELEMENT_NAME);
  442.     }
  443.    
  444.     @Override
  445.     public boolean isPostBack() throws DriverControlStationException{
  446.         String postbackElementName = this.getPostBackElementName();
  447.         return postbackElementName!=null && !"".equals(postbackElementName);
  448.     }
  449.    
  450.     @Override
  451.     public boolean isPostBackFilterElement() throws DriverControlStationException{
  452.         String postbackElementName = this.getPostBackElementName();
  453.         return postbackElementName!=null && postbackElementName.startsWith(Costanti.PARAMETRO_FILTER_VALUE);
  454.     }
  455.    
  456.     @Override
  457.     public <T> T getAttributeFromSession(String attributeName, Class<T> type){
  458.         return ServletUtils.getObjectFromSession(this.request, this.session, type, attributeName);
  459.     }
  460.    
  461.     public void clearFiltroSoggettoByPostBackProtocollo(int posizioneFiltroProtocollo, ISearch ricerca, int idLista) throws DriverControlStationException {
  462.         String postBackElement = this.getPostBackElementName();
  463.         if((Costanti.PARAMETRO_FILTER_VALUE+posizioneFiltroProtocollo).equals(postBackElement)) {
  464.             // verifico se si tratta del profilo di interoperabilita.
  465.             if(Filtri.FILTRO_PROTOCOLLO.equals(this.getParameter((Costanti.PARAMETRO_FILTER_NAME+posizioneFiltroProtocollo)))) {
  466.                 String value = this.getParameter((Costanti.PARAMETRO_FILTER_VALUE+posizioneFiltroProtocollo));
  467.                 if( (value==null ||
  468.                         //"".equals(value) ||
  469.                         CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PROTOCOLLO_QUALSIASI.equals(value))){
  470.                     ricerca.clearFilter(idLista, Filtri.FILTRO_SOGGETTO);
  471.                 }
  472.             }
  473.         }
  474.     }
  475.    
  476.     protected ControlStationCore core = null;
  477.     public ControlStationCore getCore() {
  478.         return this.core;
  479.     }
  480.     protected PddCore pddCore = null;
  481.     protected SoggettiCore soggettiCore = null;
  482.     protected UtentiCore utentiCore = null;
  483.     protected ServiziApplicativiCore saCore = null;
  484.     protected ArchiviCore archiviCore = null;
  485.     protected AccordiServizioParteComuneCore apcCore = null;
  486.     protected AccordiServizioParteSpecificaCore apsCore = null;
  487.     protected PorteDelegateCore porteDelegateCore = null;
  488.     protected PorteApplicativeCore porteApplicativeCore = null;
  489.     protected AccordiCooperazioneCore acCore = null;
  490.     protected ConfigurazioneCore confCore = null;
  491.     protected ConnettoriCore connettoriCore = null;
  492.     protected OperazioniCore operazioniCore = null;
  493.     protected ProtocolPropertiesCore protocolPropertiesCore = null;
  494.     protected RuoliCore ruoliCore = null;
  495.     protected ScopeCore scopeCore = null;
  496.     protected GruppiCore gruppiCore = null;
  497.     protected RemoteStoresCore remoteStoresCore= null;

  498.     protected AuditHelper auditHelper;
  499.     public AuditHelper getAuditHelper() {
  500.         return this.auditHelper;
  501.     }
  502.    
  503.     /** Gestione dei parametri unica sia per le chiamate multipart che per quelle normali*/
  504.     private boolean multipart = false;
  505.     public boolean isMultipart() {
  506.         return this.multipart;
  507.     }
  508.     private String contentType = null;
  509.     public String getContentType() {
  510.         return this.contentType;
  511.     }
  512.     private MimeMultipart mimeMultipart = null;
  513.     private Map<String, List<InputStream>> mapParametri = null;
  514.     private Map<String, Object> mapParametriReaded = null;
  515.     private Map<String, List<String>> mapNomiFileParametri = null;
  516.     private List<String> idBinaryParameterRicevuti = null;
  517.    
  518.     /** Logger utilizzato per debug. */
  519.     protected Logger log = null;

  520.     protected IDAccordoCooperazioneFactory idAccordoCooperazioneFactory = null;
  521.     protected IDAccordoFactory idAccordoFactory = null;
  522.     protected IDServizioFactory idServizioFactory = null;
  523.    
  524.     private static String tmpDirectory = null;
  525.    
  526.     public static String getTmpDir() throws DriverControlStationException {
  527.         if(tmpDirectory == null)
  528.             initTmpDir();
  529.        
  530.         return tmpDirectory;
  531.     }
  532.    
  533.     public static synchronized void initTmpDir() throws DriverControlStationException {
  534.         if(tmpDirectory == null){
  535.             File file = null;
  536.             try {
  537.                 file = FileSystemUtilities.createTempFile(CostantiControlStation.TEMP_FILE_PREFIX, CostantiControlStation.TEMP_FILE_SUFFIX);
  538.             }catch(Exception e) {
  539.                 throw new DriverControlStationException(e.getMessage(),e);
  540.             }
  541.             tmpDirectory = FilenameUtils.getFullPath(file.getAbsolutePath());
  542.             if(file.exists()) {
  543.                 try {
  544.                     java.nio.file.Files.delete(file.toPath());
  545.                 }catch(Exception eIgnore) {
  546.                     // ignore
  547.                 }
  548.             }
  549.         }
  550.     }
  551.    
  552.     /** Lunghezza label */
  553.     protected int size = 50;
  554.    
  555.    
  556.     /** Modalita Interfaccia */
  557.    
  558.     private static InterfaceType tipoInterfacciaAPI = null; // api rest
  559.     public static InterfaceType getTipoInterfacciaAPI() {
  560.         return tipoInterfacciaAPI;
  561.     }
  562.     public static void setTipoInterfacciaAPI(InterfaceType tipoInterfacciaAPI) {
  563.         ConsoleHelper.tipoInterfacciaAPI = tipoInterfacciaAPI;
  564.     }

  565.     public InterfaceType getTipoInterfaccia() {
  566.         if(tipoInterfacciaAPI!=null) {
  567.             return tipoInterfacciaAPI;
  568.         }
  569.         User user = ServletUtils.getUserFromSession(this.request, this.session);
  570.         if(user!=null) {
  571.             return user.getInterfaceType();
  572.         }
  573.         else {
  574.             return InterfaceType.STANDARD; // default
  575.         }
  576.     }

  577.     @Override
  578.     public boolean isModalitaCompleta() {
  579.         return InterfaceType.equals(this.getTipoInterfaccia(),
  580.                 InterfaceType.COMPLETA);
  581.     }
  582.     @Override
  583.     public boolean isModalitaAvanzata() {
  584.         // considero anche l'interfaccia completa
  585.         return InterfaceType.equals(this.getTipoInterfaccia(),
  586.                 InterfaceType.AVANZATA,InterfaceType.COMPLETA);
  587.     }
  588.     @Override
  589.     public boolean isModalitaStandard() {
  590.         return InterfaceType.equals(this.getTipoInterfaccia(),
  591.                 InterfaceType.STANDARD);
  592.     }

  593.     /** Soggetto Selezionato */
  594.     public boolean isSoggettoMultitenantSelezionato() {
  595.         return this.core.isMultitenant() && StringUtils.isNotEmpty(this.getSoggettoMultitenantSelezionato());
  596.     }
  597.     @Override
  598.     public String getSoggettoMultitenantSelezionato() {
  599.         return ServletUtils.getUserFromSession(this.request, this.session).getSoggettoSelezionatoPddConsole();
  600.     }
  601.    
  602.     /** Soggetto Selezionato da govwayMonitor */
  603.     public boolean isSoggettoMultitenantSelezionatoConsoleMonitoraggio() {
  604.         return this.core.isMultitenant() && StringUtils.isNotEmpty(this.getSoggettoMultitenantSelezionatoConsoleMonitoraggio());
  605.     }
  606.     public String getSoggettoMultitenantSelezionatoConsoleMonitoraggio() {
  607.         return ServletUtils.getUserFromSession(this.request, this.session).getSoggettoSelezionatoPddMonitor();
  608.     }
  609.    
  610.     private boolean errorInit = false;
  611.     private Exception eErrorInit;
  612.    
  613.     public ConsoleHelper(HttpServletRequest request, PageData pd, HttpSession session) {
  614.         ControlStationCore core = null;
  615.         try {
  616.             core = new ControlStationCore();
  617.         } catch (Exception e) {
  618.             if(this.log!=null) {
  619.                 this.logError("Exception ctrlstatHelper: " + e.getMessage(), e);
  620.             }
  621.             this.errorInit = true;
  622.             this.eErrorInit = e;
  623.         }
  624.         this.init(core, request, pd, session);
  625.         try {
  626.             if(this.isPostBack()) {
  627.                 pd.setPostBackResult(true);
  628.             }
  629.         } catch (Exception e) {
  630.             this.logError("Exception ctrlstatHelper: " + e.getMessage(), e);
  631.         }
  632.     }
  633.     public ConsoleHelper(ControlStationCore core, HttpServletRequest request, PageData pd, HttpSession session) {
  634.         this.init(core, request, pd, session);
  635.     }
  636.     private void init(ControlStationCore core, HttpServletRequest request, PageData pd, HttpSession session) {
  637.         this.request = request;
  638.         this.pd = pd;
  639.         this.session = session;
  640.         this.log = ControlStationLogger.getPddConsoleCoreLogger();
  641.         try {
  642.            
  643.             if (this.request.getCharacterEncoding() == null) {
  644.                 this.request.setCharacterEncoding(Charset.UTF_8.getValue());
  645.             }
  646.                        
  647.             this.core = core;
  648.             this.pddCore = new PddCore(this.core);
  649.             this.utentiCore = new UtentiCore(this.core);
  650.             this.soggettiCore = new SoggettiCore(this.core);
  651.             this.saCore = new ServiziApplicativiCore(this.core);
  652.             this.archiviCore = new ArchiviCore(this.core);
  653.             this.apcCore = new AccordiServizioParteComuneCore(this.core);
  654.             this.apsCore = new AccordiServizioParteSpecificaCore(this.core);
  655.             this.porteDelegateCore = new PorteDelegateCore(this.core);
  656.             this.porteApplicativeCore = new PorteApplicativeCore(this.core);
  657.             this.acCore = new AccordiCooperazioneCore(this.core);
  658.             this.confCore = new ConfigurazioneCore(this.core);
  659.             this.connettoriCore = new ConnettoriCore(this.core);
  660.             this.operazioniCore = new OperazioniCore(this.core);
  661.             this.protocolPropertiesCore = new ProtocolPropertiesCore(this.core);
  662.             this.ruoliCore = new RuoliCore(this.core);
  663.             this.scopeCore = new ScopeCore(this.core);
  664.             this.gruppiCore = new GruppiCore(this.core);
  665.             this.remoteStoresCore = new RemoteStoresCore(this.core);
  666.            
  667.             this.auditHelper = new AuditHelper(request, pd, session);

  668.             this.idBinaryParameterRicevuti = new ArrayList<>();
  669.             // analisi dei parametri della request
  670.             this.contentType = request.getContentType();
  671.             if ((this.contentType != null) && (this.contentType.indexOf(Costanti.MULTIPART) != -1)) {
  672.                 this.multipart = true;
  673.                 this.mimeMultipart = new MimeMultipart(request.getInputStream(), this.contentType);
  674.                 this.mapParametri = new HashMap<>();
  675.                 this.mapParametriReaded = new HashMap<>();
  676.                 this.mapNomiFileParametri = new HashMap<>();

  677.                 for(int i = 0 ; i < this.mimeMultipart.countBodyParts() ;  i ++) {
  678.                     BodyPart bodyPart = this.mimeMultipart.getBodyPart(i);
  679.                     String partName = getBodyPartName(bodyPart);
  680.                    
  681.                     if(partName==null) {
  682.                         throw new DriverControlStationException("Part name non trovato per body part alla posizione '"+i+"'");
  683.                     }
  684.                    
  685.                     List<InputStream> list = null;
  686.                     if(this.mapParametri.containsKey(partName)) {
  687.                         list = this.mapParametri.get(partName);
  688.                     }
  689.                     else {
  690.                         list = new ArrayList<>();
  691.                         this.mapParametri.put(partName, list);
  692.                     }
  693.                    
  694.                     //if(!this.mapParametri.containsKey(partName)) {
  695.                     if(partName.startsWith(Costanti.PARAMETER_FILEID_PREFIX)){
  696.                         this.idBinaryParameterRicevuti.add(partName);
  697.                     }
  698.                     //this.mapParametri.put(partName, bodyPart.getInputStream());
  699.                     list.add(bodyPart.getInputStream());
  700.                     String fileName = getBodyPartFileName(bodyPart);
  701.                     if(fileName != null) {
  702.                         List<String> nomiFiles = null;
  703.                         if(this.mapNomiFileParametri.containsKey(partName)) {
  704.                             nomiFiles = this.mapNomiFileParametri.get(partName);
  705.                         } else {
  706.                             nomiFiles = new ArrayList<>();
  707.                             this.mapNomiFileParametri.put(partName, nomiFiles);
  708.                         }
  709.                        
  710.                         nomiFiles.add(fileName);
  711.                     }
  712.                     //}
  713.                     //else throw new DriverControlStationException("Parametro ["+partName+"] Duplicato.");
  714.                 }
  715.             } else {
  716.                 Enumeration<String> parameterNames = this.request.getParameterNames();
  717.                 while (parameterNames.hasMoreElements()) {
  718.                     String param = (String) parameterNames.nextElement();
  719.                     if(param.startsWith(Costanti.PARAMETER_FILEID_PREFIX)){
  720.                         this.idBinaryParameterRicevuti.add(param);
  721.                     }
  722.                 }
  723.             }
  724.            
  725.             try {
  726.                 if(!ControlStationCore.isAPIMode()) {
  727.                     ConsoleProperties consoleProperties = ConsoleProperties.getInstance();
  728.                     this.size = consoleProperties.getConsoleLunghezzaLabel();
  729.                 }
  730.             }catch(Exception e) {
  731.                 this.size = 50;
  732.             }
  733.            
  734.             // inizializzo l'id tab
  735.             this.getTabId();
  736.         } catch (Exception e) {
  737.             this.logError("Exception ctrlstatHelper: " + e.getMessage(), e);
  738.             this.errorInit = true;
  739.             this.eErrorInit = e;
  740.         }
  741.         this.idAccordoCooperazioneFactory = IDAccordoCooperazioneFactory.getInstance();
  742.         this.idAccordoFactory = IDAccordoFactory.getInstance();
  743.         this.idServizioFactory = IDServizioFactory.getInstance();
  744.     }
  745.    
  746.     public String getTabId() throws DriverControlStationException {
  747.         return getTabId(this.log, this, this.request);
  748.     }
  749.    
  750.     public static String getTabId(Logger log, ConsoleHelper helper, HttpServletRequest request) throws DriverControlStationException {
  751.         Object idTabObj = request.getAttribute(Costanti.PARAMETER_TAB_KEY);
  752.        
  753.         if(idTabObj == null) {
  754.             log.trace("CHECKTABID: non trovato come attributo");
  755.             String idTab = helper != null ? helper.getParameter(Costanti.PARAMETER_TAB_KEY) : request.getParameter(Costanti.PARAMETER_TAB_KEY);
  756.            
  757.             if(idTab == null) { // nuovoTab o nuova finestra o primo accesso
  758.                 log.trace("CHECKTABID: non trovato come parametro");
  759.                 idTab = UUID.randomUUID().toString().replace("-", "");
  760.                 request.setAttribute(Costanti.PARAMETER_TAB_KEY, idTab);
  761.                 log.debug("CHECKTABID: generato nuovo id: ["+idTab+"]");
  762.                 return idTab;
  763.             }
  764.            
  765.             request.setAttribute(Costanti.PARAMETER_TAB_KEY, idTab);
  766.             log.trace("CHECKTABID: trovato come parametro: ["+idTab+"]");
  767.             return idTab;
  768.         }
  769.        
  770.         log.trace("CHECKTABID: trovato come attributo: ["+((String)idTabObj)+"]");
  771.         return (String) idTabObj;
  772.     }
  773.    
  774. //  public boolean isUseIdSogg() {
  775. //      // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  776. //      return ServletUtils.getBooleanAttributeFromSession(CostantiControlStation.PARAMETRO_USAIDSOGG , this.session, false);
  777. //  }
  778.    
  779.     public boolean isShowGestioneWorkflowStatoDocumenti() {
  780.         return this.core.isShowGestioneWorkflowStatoDocumenti(this);
  781.     }
  782.    
  783.     public IDAccordo getIDAccordoFromValues(String nomeAS, String soggettoReferente, String versione) throws DriverControlStationException{
  784.         try {
  785.             Soggetto s = this.soggettiCore.getSoggetto(Integer.parseInt(soggettoReferente));            
  786.             IDSoggetto assr = new IDSoggetto();
  787.             assr.setTipo(s.getTipo());
  788.             assr.setNome(s.getNome());
  789.             int versioneInt = 1;
  790.             if(versione!=null && !"".equals(versione)) {
  791.                 versioneInt = Integer.parseInt(versione);
  792.             }
  793.             return this.idAccordoFactory.getIDAccordoFromValues(nomeAS, assr, versioneInt);
  794.         }catch(Exception e) {
  795.             throw new DriverControlStationException(e.getMessage(),e);
  796.         }
  797.     }
  798.    
  799.     public IDServizio getIDServizioFromValues(String tipo, String nome, String soggettoErogatore, String versione) throws DriverControlStationException{
  800.         try {
  801.             Soggetto s = this.soggettiCore.getSoggetto(Integer.parseInt(soggettoErogatore));            
  802.             IDSoggetto assr = new IDSoggetto();
  803.             assr.setTipo(s.getTipo());
  804.             assr.setNome(s.getNome());
  805.             int versioneInt = 1;
  806.             if(versione!=null && !"".equals(versione)) {
  807.                 versioneInt = Integer.parseInt(versione);
  808.             }
  809.             return this.idServizioFactory.getIDServizioFromValues(tipo, nome, assr, versioneInt);
  810.         }catch(Exception e) {
  811.             throw new DriverControlStationException(e.getMessage(),e);
  812.         }
  813.     }
  814.    
  815.     public IDServizio getIDServizioFromValues(String tipo, String nome, String tipoSoggettoErogatore, String soggettoErogatore, String versione) throws DriverControlStationException{
  816.         try {
  817.             IDSoggetto assr = new IDSoggetto();
  818.             assr.setTipo(tipoSoggettoErogatore);
  819.             assr.setNome(soggettoErogatore);
  820.             int versioneInt = 1;
  821.             if(versione!=null && !"".equals(versione)) {
  822.                 versioneInt = Integer.parseInt(versione);
  823.             }
  824.             return this.idServizioFactory.getIDServizioFromValues(tipo, nome, assr,versioneInt);
  825.         }catch(Exception e) {
  826.             throw new DriverControlStationException(e.getMessage(),e);
  827.         }
  828.     }
  829.    
  830.     public IDAccordo getIDAccordoFromUri(String uriAccordo) throws DriverControlStationException{
  831.         try {
  832.             return this.idAccordoFactory.getIDAccordoFromUri(uriAccordo);
  833.         }catch(Exception e) {
  834.             throw new DriverControlStationException(e.getMessage(),e);
  835.         }
  836.     }
  837.    
  838.     public int getSize() {
  839.         return this.size;
  840.     }

  841.     private String getBodyPartName (BodyPart bodyPart) throws DriverControlStationException{
  842.         String partName =  null;
  843.         String[] headers = null;
  844.         try {
  845.             headers = bodyPart.getHeader(CostantiControlStation.PARAMETRO_CONTENT_DISPOSITION);
  846.         }catch(Exception e) {
  847.             throw new DriverControlStationException(e.getMessage(),e);
  848.         }
  849.         if(headers != null && headers.length > 0){
  850.             String header = headers[0];

  851.             // in due parti perche il suffisso con solo " imbrogliava il controllo
  852.             int prefixIndex = header.indexOf(CostantiControlStation.PREFIX_CONTENT_DISPOSITION) + CostantiControlStation.PREFIX_CONTENT_DISPOSITION.length();
  853.             partName = header.substring(prefixIndex);

  854.             int suffixIndex = partName.indexOf(CostantiControlStation.SUFFIX_CONTENT_DISPOSITION);
  855.             partName = partName.substring(0,suffixIndex);
  856.         }

  857.         return partName;
  858.     }

  859.     private String getBodyPartFileName (BodyPart bodyPart) throws DriverControlStationException{
  860.         String partName =  null;
  861.         String[] headers = null;
  862.         try {
  863.             headers = bodyPart.getHeader(CostantiControlStation.PARAMETRO_CONTENT_DISPOSITION);
  864.         }catch(Exception e) {
  865.             throw new DriverControlStationException(e.getMessage(),e);
  866.         }
  867.         if(headers != null && headers.length > 0){
  868.             String header = headers[0];

  869.             // in due parti perche il suffisso con solo " imbrogliava il controllo
  870.             int prefixIndex = header.indexOf(CostantiControlStation.PREFIX_FILENAME);
  871.             if(prefixIndex > -1){
  872.                 partName = header.substring(prefixIndex + CostantiControlStation.PREFIX_FILENAME.length());

  873.                 int suffixIndex = partName.indexOf(CostantiControlStation.SUFFIX_FILENAME);
  874.                 partName = partName.substring(0,suffixIndex);
  875.                
  876.                 // 20220621 IE invia l'intero path invece che il solo filename, bisogna estrarlo
  877.                 partName = FilenameUtils.getName(partName);
  878.             }
  879.         }

  880.         return partName;
  881.     }

  882.     private void checkErrorInit() throws DriverControlStationException {
  883.         if(this.errorInit) {
  884.             throw new DriverControlStationException("Inizializzazione fallita: "+this.eErrorInit.getMessage(),this.eErrorInit);
  885.         }
  886.     }
  887.    
  888.     @Override
  889.     public Enumeration<?> getParameterNames() throws DriverControlStationException {
  890.         this.checkErrorInit();
  891.         if(this.multipart){
  892.             throw new DriverControlStationException("Not Implemented");
  893.         }
  894.         else {
  895.             return this.request.getParameterNames();
  896.         }
  897.     }
  898.    
  899.     @Override
  900.     public String [] getParameterValues(String parameterName) throws DriverControlStationException {
  901.         this.checkErrorInit();
  902.         if(this.multipart){
  903.            
  904.             String [] array = null;
  905.             if(this.mapParametriReaded.containsKey(parameterName)) {
  906.                 array = (String[]) this.mapParametriReaded.get(parameterName);
  907.             }
  908.             else {
  909.                 List<InputStream> list = this.mapParametri.get(parameterName);
  910.                 if(list != null && !list.isEmpty()){
  911.                     StringBuilder sb = new StringBuilder();
  912.                     for (InputStream inputStream : list) {
  913.                         if(inputStream != null){
  914.                             ByteArrayOutputStream baos = new ByteArrayOutputStream();
  915.                             try {
  916.                                 IOUtils.copy(inputStream, baos);
  917.                                 baos.flush();
  918.                                 baos.close();
  919.                             }catch(Exception e) {
  920.                                 throw new DriverControlStationException(e.getMessage(),e);
  921.                             }
  922.                             if(sb.length()>0) {
  923.                                 sb.append(",");
  924.                             }
  925.                             sb.append(baos.toString());
  926.                         }
  927.                     }
  928.                     if(sb.length()>0) {
  929.                         String v = sb.toString();
  930.                         array = v.split(",");
  931.                         this.mapParametriReaded.put(parameterName, array);
  932.                     }
  933.                 }
  934.             }
  935.             return array;
  936.            
  937.         }
  938.         else {
  939.             return this.request.getParameterValues(parameterName);
  940.         }
  941.     }
  942.    
  943.     @Override
  944.     public String getParameter(String parameterName) throws DriverControlStationException {
  945.         return getParameter(parameterName, String.class, null);
  946.     }

  947.     @Override
  948.     public <T> T getParameter(String parameterName, Class<T> type) throws DriverControlStationException {
  949.         return getParameter(parameterName, type, null);
  950.     }

  951.     @Override
  952.     public <T> T getParameter(String parameterName, Class<T> type, T defaultValue) throws DriverControlStationException {
  953.        
  954.         this.checkErrorInit();
  955.        
  956.        
  957.         T toReturn = null;

  958.         if(type == byte[].class){
  959.             throw new DriverControlStationException("Per leggere un parametro di tipo byte[] utilizzare il metodo getBinaryParameter");
  960.         }

  961.         String paramAsString = null;

  962.         if(this.multipart){
  963.             if(this.mapParametriReaded.containsKey(parameterName)) {
  964.                 paramAsString = (String) this.mapParametriReaded.get(parameterName);
  965.             }
  966.             else {
  967.                 // La lista dovrebbe al massimo avere sempre un solo valore
  968.                 List<InputStream> list = this.mapParametri.get(parameterName);
  969.                 if(list != null && !list.isEmpty()){
  970.                    
  971.                     if(list.size()>1) {
  972.                         throw new DriverControlStationException("Parametro ["+parameterName+"] Duplicato.");
  973.                     }
  974.                     InputStream inputStream = list.get(0);
  975.                     if(inputStream != null){
  976.                         ByteArrayOutputStream baos = new ByteArrayOutputStream();
  977.                         try {
  978.                             IOUtils.copy(inputStream, baos);
  979.                             baos.flush();
  980.                             baos.close();
  981.                         }catch(Exception e) {
  982.                             throw new DriverControlStationException(e.getMessage(),e);
  983.                         }
  984.                         paramAsString = baos.toString();
  985.                         this.mapParametriReaded.put(parameterName, paramAsString);
  986.                     }
  987.                 }
  988.             }
  989.         }else{
  990.             paramAsString = this.request.getParameter(parameterName);
  991.         }

  992.         if(paramAsString != null) {
  993.            
  994.             // Fix: textarea un ritorno a capo viene codificato con \r\n, anche se il valore fornito iniziale possedeva solo lo \n.
  995.             while(paramAsString.contains("\r\n")) {
  996.                 paramAsString = paramAsString.replace("\r\n", "\n");
  997.             }
  998.                        
  999.             try {
  1000.                 Constructor<T> constructor = type.getConstructor(String.class);
  1001.                 if(constructor != null)
  1002.                     toReturn = constructor.newInstance(paramAsString);
  1003.                 else
  1004.                     toReturn = type.cast(paramAsString);
  1005.             }catch(Exception e) {
  1006.                 throw new DriverControlStationException(e.getMessage(),e);
  1007.             }
  1008.         }

  1009.         if(toReturn == null && defaultValue != null)
  1010.             return defaultValue;


  1011.         return toReturn;
  1012.     }
  1013.    
  1014.     @Override
  1015.     public byte[] getBinaryParameterContent(String parameterName) throws DriverControlStationException {
  1016.                
  1017.         byte [] b = null;
  1018.        
  1019.         List<byte[]> bpContents = this._getBinaryParameterContent(parameterName);
  1020.        
  1021.         if(bpContents != null && !bpContents.isEmpty())
  1022.             return bpContents.get(0);
  1023.        
  1024.         return b;
  1025.     }
  1026.    
  1027.     @SuppressWarnings("unchecked")
  1028.     public List<byte[]> _getBinaryParameterContent(String parameterName) throws DriverControlStationException {
  1029.        
  1030.         this.checkErrorInit();
  1031.        
  1032.         List<byte[]> bpContents = null;
  1033.         if(this.multipart){
  1034.             if(this.mapParametriReaded.containsKey(parameterName)) {
  1035.                 return (List<byte[]>) this.mapParametriReaded.get(parameterName);
  1036.             }
  1037.             else {
  1038.                 // La lista dovrebbe al massimo avere sempre un solo valore
  1039.                 List<InputStream> list = this.mapParametri.get(parameterName);
  1040.                 if(list != null && !list.isEmpty()){
  1041.                    
  1042.                     bpContents = new ArrayList<byte[]>();
  1043.                     for (InputStream inputStream : list) {
  1044.                         if(inputStream != null){
  1045.                             ByteArrayOutputStream baosInner = new ByteArrayOutputStream();
  1046.                             try {
  1047.                                 IOUtils.copy(inputStream, baosInner);
  1048.                             }catch(Exception e) {
  1049.                                 throw new DriverControlStationException(e.getMessage(),e);
  1050.                             }
  1051.                             byte[] b = baosInner.toByteArray();
  1052.                             bpContents.add(b);
  1053.                         }
  1054.                     }
  1055.                     if(!bpContents.isEmpty()) {
  1056.                         this.mapParametriReaded.put(parameterName, bpContents);
  1057.                         return bpContents;
  1058.                     }
  1059.                 }
  1060.             }
  1061.         }else{
  1062.             // caso che non dovrebbe mai succedere
  1063.             String[] paramAsString = this.request.getParameterValues(parameterName);
  1064.             if(paramAsString != null) {
  1065.                 List<String> tmpStrings = Arrays.asList(paramAsString);
  1066.                 bpContents = tmpStrings.stream().map(e -> e.getBytes()).collect(Collectors.toList());
  1067.             }
  1068.         }

  1069.         return bpContents;
  1070.     }

  1071.     @Override
  1072.     public String getFileNameParameter(String parameterName) throws DriverControlStationException {
  1073.        
  1074.         this.checkErrorInit();
  1075.                
  1076.         if(this.multipart){
  1077.             List<String> tmp = this.mapNomiFileParametri.get(parameterName);
  1078.             return (tmp != null && tmp.size() > 0) ? tmp.get(0) : null;
  1079.         } else
  1080.             return this.request.getParameter(parameterName);

  1081.     }
  1082.    
  1083.     public List<String> getFileNamesParameter(String parameterName) throws DriverControlStationException {
  1084.        
  1085.         this.checkErrorInit();
  1086.                
  1087.         if(this.multipart){
  1088.             List<String> tmp = this.mapNomiFileParametri.get(parameterName);
  1089.             return tmp;
  1090.         } else {
  1091.             String[] tmp = this.request.getParameterValues(parameterName);
  1092.             return (tmp != null && tmp.length > 0) ? Arrays.asList(tmp): null;
  1093.         }

  1094.     }
  1095.    
  1096.     private HashMap<String, byte[]> customBinaryParameters = new HashMap<>();
  1097.     public void registerBinaryParameter(String parameterName, byte[] content) {
  1098.         this.customBinaryParameters.put(parameterName, content);
  1099.     }
  1100.    
  1101.    
  1102.     public BinaryParameter newBinaryParameter(String parameterName) throws DriverControlStationException {
  1103.         BinaryParameter bp = new BinaryParameter();
  1104.         bp.setName(parameterName);
  1105.         return bp;
  1106.     }
  1107.     public BinaryParameter getBinaryParameter(String parameterName) throws DriverControlStationException {
  1108.        
  1109.         this.checkErrorInit();
  1110.                
  1111.         BinaryParameter bp = newBinaryParameter(parameterName);
  1112.         String filename = null;
  1113.         String fileId = null;
  1114.         File file = null;
  1115.         FileOutputStream fos =  null;
  1116.         FileInputStream fis =  null;
  1117.         ByteArrayInputStream bais = null;
  1118.         ByteArrayOutputStream baos = null;
  1119.        
  1120.         byte [] bpContent = null;
  1121.        
  1122.         // 0. provo a prelevarlo dai custom parameters (servizio rs)
  1123.         if(this.customBinaryParameters.containsKey(parameterName)) {
  1124.             bpContent = this.customBinaryParameters.get(parameterName);
  1125.         }
  1126.         else {
  1127.             // 1. provo a prelevare il valore dalla request
  1128.             bpContent = this.getBinaryParameterContent(parameterName);
  1129.         }
  1130.        
  1131.         if(bpContent != null && bpContent.length > 0) {
  1132.             //  cancello eventuale vecchio contenuto
  1133.             filename = this.getParameter(ProtocolPropertiesCostanti.PARAMETER_FILENAME_PREFIX + parameterName);
  1134.             fileId = this.getParameter(ProtocolPropertiesCostanti.PARAMETER_FILEID_PREFIX+ parameterName);
  1135.             if(StringUtils.isNotBlank(fileId) && StringUtils.isNotBlank(filename)){
  1136.                 file = new File(getTmpDir() + File.separator + CostantiControlStation.TEMP_FILE_PREFIX +  fileId + CostantiControlStation.TEMP_FILE_SUFFIX);
  1137.                 if(file.exists()) {
  1138.                     if(!file.delete()) {
  1139.                         // ignore
  1140.                     }
  1141.                 }
  1142.             }

  1143.             //salvataggio nuovo contenuto
  1144.             filename = this.getFileNameParameter(parameterName);
  1145.             try {
  1146.                 file = FileSystemUtilities.createTempFile(CostantiControlStation.TEMP_FILE_PREFIX, CostantiControlStation.TEMP_FILE_SUFFIX);
  1147.             }catch(Exception e) {
  1148.                 throw new DriverControlStationException(e.getMessage(),e);
  1149.             }
  1150.             fileId = file.getName().substring(0, file.getName().indexOf(CostantiControlStation.TEMP_FILE_SUFFIX));
  1151.             fileId = fileId.substring(fileId.indexOf(CostantiControlStation.TEMP_FILE_PREFIX) + CostantiControlStation.TEMP_FILE_PREFIX.length());
  1152.            
  1153.             try{
  1154.                 bais = new ByteArrayInputStream(bpContent);
  1155.                 fos = new FileOutputStream(file);
  1156.                
  1157.                 IOUtils.copy(bais, fos);
  1158.             }catch(Exception e) {
  1159.                 throw new DriverControlStationException(e.getMessage(),e);
  1160.             }
  1161.             finally {
  1162.                 try {
  1163.                     if(bais!=null) {
  1164.                         bais.close();
  1165.                     }
  1166.                 }catch(Exception e) {
  1167.                     // ignore
  1168.                 }
  1169.                 try {
  1170.                     if(fos!=null) {
  1171.                         fos.close();
  1172.                     }
  1173.                 }catch(Exception e) {
  1174.                     // ignore
  1175.                 }
  1176.             }
  1177.            
  1178.            
  1179.         } else {
  1180.             // provo a ricostruire il valore dai campi hidden
  1181.             filename = this.getParameter(ProtocolPropertiesCostanti.PARAMETER_FILENAME_PREFIX + parameterName);
  1182.             fileId = this.getParameter(ProtocolPropertiesCostanti.PARAMETER_FILEID_PREFIX+ parameterName);
  1183.            
  1184.             if(StringUtils.isNotBlank(fileId) && StringUtils.isNotBlank(filename)){
  1185.                 file = new File(getTmpDir() + File.separator + CostantiControlStation.TEMP_FILE_PREFIX + fileId + CostantiControlStation.TEMP_FILE_SUFFIX);
  1186.                
  1187.                 // puo' non esistere allora il valore e' vuoto
  1188.                 if(file.exists()){
  1189.                     try{
  1190.                         fis = new FileInputStream(file);
  1191.                         baos = new ByteArrayOutputStream();
  1192.                        
  1193.                         IOUtils.copy(fis, baos);
  1194.                        
  1195.                         baos.flush();
  1196.                         bpContent = baos.toByteArray();
  1197.                        
  1198.                     }catch(Exception e) {
  1199.                         throw new DriverControlStationException(e.getMessage(),e);
  1200.                     }
  1201.                     finally {
  1202.                         try {
  1203.                             if(fis!=null) {
  1204.                                 fis.close();
  1205.                             }
  1206.                         }catch(Exception e) {
  1207.                             // ignore
  1208.                         }
  1209.                         try {
  1210.                             if(baos!=null) {
  1211.                                 baos.close();
  1212.                             }
  1213.                         }catch(Exception e) {
  1214.                             // ignore
  1215.                         }
  1216.                     }
  1217.                 } else {
  1218.                     bpContent = null;
  1219.                 }
  1220.             } else {
  1221.                 bpContent = null;
  1222.                 filename = null;
  1223.                 fileId = null;
  1224.             }
  1225.         }
  1226.        
  1227.         bp.setValue(bpContent);
  1228.         bp.setFilename(filename);
  1229.         bp.setId(fileId);  
  1230.        
  1231.         // se ho provocato io l'evento di cancellazione via postback allora svuoto il contenuto
  1232.         if(this.isPostBack()) {
  1233.             String postBackElementName = this.getPostBackElementName();
  1234.             if(postBackElementName!=null && postBackElementName.startsWith(parameterName) && postBackElementName.contains(Costanti.PARAMETER_FILENAME_REMOVE_PLACEHOLDER)) {
  1235.                 bp.setValue(null);
  1236.                 bp.setFilename(null);
  1237.                 bp.setId(null);  
  1238.             }
  1239.         }
  1240.        
  1241.         return bp;
  1242.     }
  1243.    
  1244.    
  1245.     public List<BinaryParameter> getBinaryParameters(String parameterName) throws DriverControlStationException {
  1246.        
  1247.         this.checkErrorInit();
  1248.                
  1249. //      BinaryParameter bp = newBinaryParameter(parameterName);
  1250.         String filename = null;
  1251.         String fileId = null;
  1252.         File file = null;
  1253.         FileOutputStream fos =  null;
  1254.         FileInputStream fis =  null;
  1255.         ByteArrayInputStream bais = null;
  1256.         ByteArrayOutputStream baos = null;
  1257.        
  1258.         byte [] bpContent = null;
  1259.        
  1260.         List<byte[]> bpContents = this._getBinaryParameterContent(parameterName);
  1261. //      // 0. provo a prelevarlo dai custom parameters (servizio rs)
  1262. //      if(this.customBinaryParameters.containsKey(parameterName)) {
  1263. //          bpContent = this.customBinaryParameters.get(parameterName);
  1264. //      }
  1265. //      else {
  1266. //          // 1. provo a prelevare il valore dalla request
  1267. //          bpContent = this.getBinaryParameterContent(parameterName);
  1268. //      }
  1269.        
  1270.         List<BinaryParameter> toRet = new ArrayList<BinaryParameter>();
  1271.        
  1272.         // in questa fase dopo la submit successiva alla scelta del file tramite una postback ricevo un array di contenuti vuoti
  1273.         // che devo ignorare per prelevare i valori dai file temporanei
  1274.         boolean ricevutoContenuto = bpContents != null && bpContents.size() >0;
  1275.         if(ricevutoContenuto) {
  1276.             for (int i = 0; i < bpContents.size() ; i++ ) {
  1277.                 bpContent = bpContents.get(i);
  1278.                 // come nel caso singolo, ma questa volta sull'array dei file
  1279.                 if(!(bpContent != null && bpContent.length > 0)) {
  1280.                     ricevutoContenuto = false;
  1281.                     break;
  1282.                 }
  1283.             }
  1284.         }
  1285.        
  1286.         if(ricevutoContenuto) {
  1287.             String fileNames = this.getParameter(ProtocolPropertiesCostanti.PARAMETER_FILENAME_PREFIX + parameterName);
  1288.             String fileIds = this.getParameter(ProtocolPropertiesCostanti.PARAMETER_FILEID_PREFIX+ parameterName);
  1289.             if(StringUtils.isNotBlank(fileIds) && StringUtils.isNotBlank(fileNames)){
  1290.                 String[] ids = fileIds.split(",");
  1291.                 for (String id : ids) {
  1292.                     file = new File(getTmpDir() + File.separator + CostantiControlStation.TEMP_FILE_PREFIX +  id + CostantiControlStation.TEMP_FILE_SUFFIX);
  1293.                     if(file.exists()) {
  1294.                         if(!file.delete()) {
  1295.                             // ignore
  1296.                         }
  1297.                     }
  1298.                 }
  1299.             }
  1300.            
  1301.             List<String> fileNamesParameter = this.getFileNamesParameter(parameterName);
  1302.             //salvataggio nuovo contenuto
  1303.             for (int i = 0; i < bpContents.size() ; i++ ) {
  1304.                 bpContent = bpContents.get(i);
  1305.                 filename = fileNamesParameter.get(i);
  1306.                 try {
  1307.                     file = FileSystemUtilities.createTempFile(CostantiControlStation.TEMP_FILE_PREFIX, CostantiControlStation.TEMP_FILE_SUFFIX);
  1308.                 }catch(Exception e) {
  1309.                     throw new DriverControlStationException(e.getMessage(),e);
  1310.                 }
  1311.                 fileId = file.getName().substring(0, file.getName().indexOf(CostantiControlStation.TEMP_FILE_SUFFIX));
  1312.                 fileId = fileId.substring(fileId.indexOf(CostantiControlStation.TEMP_FILE_PREFIX) + CostantiControlStation.TEMP_FILE_PREFIX.length());
  1313.                
  1314.                 try{
  1315.                     bais = new ByteArrayInputStream(bpContent);
  1316.                     fos = new FileOutputStream(file);
  1317.                    
  1318.                     IOUtils.copy(bais, fos);
  1319.                 }catch(Exception e) {
  1320.                     throw new DriverControlStationException(e.getMessage(),e);
  1321.                 }
  1322.                 finally {
  1323.                     try {
  1324.                         if(bais!=null) {
  1325.                             bais.close();
  1326.                         }
  1327.                     }catch(Exception e) {
  1328.                         // ignore
  1329.                     }
  1330.                     try {
  1331.                         if(fos!=null) {
  1332.                             fos.close();
  1333.                         }
  1334.                     }catch(Exception e) {
  1335.                         // ignore
  1336.                     }
  1337.                 }
  1338.                
  1339.                 BinaryParameter bp = newBinaryParameter(parameterName);
  1340.                 bp.setValue(bpContent);
  1341.                 bp.setFilename(filename);
  1342.                 bp.setId(fileId);  
  1343.                
  1344.                 toRet.add(bp);
  1345.             }
  1346.         } else {
  1347.             // provo a ricostruire il valore dai campi hidden
  1348.             String fileNames = this.getParameter(ProtocolPropertiesCostanti.PARAMETER_FILENAME_PREFIX + parameterName);
  1349.             String fileIds = this.getParameter(ProtocolPropertiesCostanti.PARAMETER_FILEID_PREFIX+ parameterName);
  1350.            
  1351.             if(StringUtils.isNotBlank(fileIds) && StringUtils.isNotBlank(fileNames)){
  1352.                 List<String> ids = Arrays.asList(fileIds.split(","));
  1353.                 List<String> fileNamesParameter = Arrays.asList(fileNames.split(","));
  1354.                
  1355.                 for (int i = 0; i < ids.size() ; i++ ) {
  1356.                     fileId = ids.get(i);
  1357.                     filename = fileNamesParameter.get(i);
  1358.                     file = new File(getTmpDir() + File.separator + CostantiControlStation.TEMP_FILE_PREFIX + fileId + CostantiControlStation.TEMP_FILE_SUFFIX);
  1359.                    
  1360.                     // puo' non esistere allora il valore e' vuoto
  1361.                     if(file.exists()){
  1362.                         try{
  1363.                             fis = new FileInputStream(file);
  1364.                             baos = new ByteArrayOutputStream();
  1365.                            
  1366.                             IOUtils.copy(fis, baos);
  1367.                            
  1368.                             baos.flush();
  1369.                             bpContent = baos.toByteArray();
  1370.                            
  1371.                         }catch(Exception e) {
  1372.                             throw new DriverControlStationException(e.getMessage(),e);
  1373.                         }
  1374.                         finally {
  1375.                             try {
  1376.                                 if(fis!=null) {
  1377.                                     fis.close();
  1378.                                 }
  1379.                             }catch(Exception e) {
  1380.                                 // ignore
  1381.                             }
  1382.                             try {
  1383.                                 if(baos!=null) {
  1384.                                     baos.close();
  1385.                                 }
  1386.                             }catch(Exception e) {
  1387.                                 // ignore
  1388.                             }
  1389.                         }
  1390.                     } else {
  1391.                         bpContent = null;
  1392.                     }
  1393.                    
  1394.                     BinaryParameter bp = newBinaryParameter(parameterName);
  1395.                     bp.setValue(bpContent);
  1396.                     bp.setFilename(filename);
  1397.                     bp.setId(fileId);  
  1398.                    
  1399.                     toRet.add(bp);
  1400.                 }
  1401.                
  1402.             }else {
  1403.                 // serve per creare il caso del primo accesso
  1404.                 bpContent = null;
  1405.                 filename = null;
  1406.                 fileId = null;
  1407.                
  1408.                 BinaryParameter bp = newBinaryParameter(parameterName);
  1409.                 bp.setValue(bpContent);
  1410.                 bp.setFilename(filename);
  1411.                 bp.setId(fileId);  
  1412.                
  1413.                 toRet.add(bp);
  1414.             }
  1415.            
  1416.         }
  1417.        
  1418.         // se ho provocato io l'evento di cancellazione via postback allora svuoto il contenuto
  1419.         if(this.isPostBack()) {
  1420.             String postBackElementName = this.getPostBackElementName();
  1421.             if(postBackElementName!=null && postBackElementName.startsWith(parameterName) && postBackElementName.contains(Costanti.PARAMETER_FILENAME_REMOVE_PLACEHOLDER)) {
  1422.                 String[] split = postBackElementName.split(Costanti.PARAMETER_FILENAME_REMOVE_PLACEHOLDER);
  1423.                 try {
  1424.                     int pos = Integer.parseInt(split[1]);
  1425.                     toRet.get(pos).setValue(null);
  1426.                     toRet.get(pos).setFilename(null);
  1427.                     toRet.get(pos).setId(null);  
  1428.                 }catch(Exception e) {
  1429.                    
  1430.                 }
  1431.             }
  1432.         }
  1433.        
  1434.         return toRet;
  1435.     }
  1436.    
  1437.     public String getLockedParameter(String parameterName) throws UtilsException, DriverControlStationException {
  1438.         return getLockedParameter(parameterName, true) ;
  1439.     }
  1440.     public String getLockedParameter(String parameterName, boolean unwrap) throws UtilsException, DriverControlStationException {
  1441.         // 1. leggo il valore del parametro associato all'elemento di tipo password
  1442.         String inputValue = this.getParameter(parameterName);
  1443.        
  1444.         // 2. pwd puo' essere null se non c'e' oppure se e' postback, se viene fatta la submit e' impostata e se corrisponde alla costante allora provo a leggere il valore del parametro hidden associato
  1445.         if( inputValue == null || Costanti.PARAMETER_LOCK_DEFAULT_VALUE.equals(inputValue)) {
  1446.             String lockHiddenValue = this.getParameter(Costanti.PARAMETER_LOCK_PREFIX + parameterName);
  1447.            
  1448.             // 3. unwrap
  1449.             if(this.core.getDriverBYOKUtilities().isEnabledBYOK() && unwrap) {
  1450.                 return this.core.getDriverBYOKUtilities().unwrap(lockHiddenValue);
  1451.             }
  1452.             else {
  1453.                 return lockHiddenValue;
  1454.             }
  1455.         }
  1456.                
  1457.         return inputValue;              
  1458.     }
  1459.    
  1460.     /***
  1461.      * cancella i file temporanei dei parametri binari del protocollo, da usare dopo il salvataggio dell'oggetto.
  1462.      *
  1463.      * @param protocolProperties
  1464.      * @throws DriverControlStationException
  1465.      */
  1466.     public void deleteBinaryProtocolPropertiesTmpFiles(ProtocolProperties protocolProperties) throws DriverControlStationException{
  1467.        
  1468.         this.checkErrorInit();
  1469.                
  1470.         if(protocolProperties!= null)
  1471.             for (int i = 0; i < protocolProperties.sizeProperties(); i++) {
  1472.                 AbstractProperty<?> property = protocolProperties.getProperty(i);
  1473.                 if(property instanceof BinaryProperty){
  1474.                     BinaryProperty bProp = (BinaryProperty) property;
  1475.                     BinaryParameter bp = new BinaryParameter();
  1476.                     bp.setName(bProp.getId());
  1477.                     bp.setFilename(bProp.getFileName());
  1478.                     bp.setId(bProp.getFileId());
  1479.                     bp.setValue(bProp.getValue());
  1480.                    
  1481.                     this.deleteBinaryParameter(bp);
  1482.                 }
  1483.             }
  1484.     }
  1485.    
  1486.     /***
  1487.      *
  1488.      * cancella il file temporaneo del parametro binari del protocollo con id passato come parametro, da usare dopo il salvataggio dell'oggetto.
  1489.      *
  1490.      * @param protocolProperties
  1491.      * @param propertyId
  1492.      * @throws DriverControlStationException
  1493.      */
  1494.     public void deleteBinaryProtocolPropertyTmpFiles(ProtocolProperties protocolProperties, String propertyId) throws DriverControlStationException{
  1495.        
  1496.         this.checkErrorInit();
  1497.                
  1498.         if(protocolProperties!= null)
  1499.             for (int i = 0; i < protocolProperties.sizeProperties(); i++) {
  1500.                 AbstractProperty<?> property = protocolProperties.getProperty(i);
  1501.                 if(property instanceof BinaryProperty && property.getId().equals(propertyId)){
  1502.                     BinaryProperty bProp = (BinaryProperty) property;
  1503.                     BinaryParameter bp = new BinaryParameter();
  1504.                     bp.setName(bProp.getId());
  1505.                     bp.setFilename(bProp.getFileName());
  1506.                     bp.setId(bProp.getFileId());
  1507.                     bp.setValue(bProp.getValue());
  1508.                    
  1509.                     this.deleteBinaryParameter(bp);
  1510.                     break;
  1511.                 }
  1512.             }
  1513.     }
  1514.    
  1515.     /****
  1516.      *
  1517.      * cancella il file temporaneo del parametro binari del protocollo con id e alias passato come parametro, da usare dopo il salvataggio dell'oggetto nella schermata di modifica.
  1518.      *
  1519.      * @param protocolProperties
  1520.      * @param propertyId
  1521.      * @param aliasId
  1522.      * @throws DriverControlStationException
  1523.      */
  1524.     public void deleteBinaryProtocolPropertyTmpFiles(ProtocolProperties protocolProperties, String propertyId, String aliasId) throws DriverControlStationException{
  1525.        
  1526.         this.checkErrorInit();
  1527.                
  1528.         if(protocolProperties!= null)
  1529.             for (int i = 0; i < protocolProperties.sizeProperties(); i++) {
  1530.                 AbstractProperty<?> property = protocolProperties.getProperty(i);
  1531.                 if(property instanceof BinaryProperty && property.getId().equals(propertyId)){
  1532.                     BinaryProperty bProp = (BinaryProperty) property;
  1533.                     BinaryParameter bp = new BinaryParameter();
  1534.                     bp.setName(aliasId);
  1535.                     bp.setFilename(bProp.getFileName());
  1536.                     bp.setId(bProp.getFileId());
  1537.                     bp.setValue(bProp.getValue());
  1538.                    
  1539.                     this.deleteBinaryParameter(bp);
  1540.                     break;
  1541.                 }
  1542.             }
  1543.     }
  1544.    
  1545.     /****
  1546.      *
  1547.      * Cancella tutti i file temporanei dei protocol properties ricevuti, da usare durante la fase di edit e postback.
  1548.      *
  1549.      *
  1550.      * @param parameters
  1551.      * @throws DriverControlStationException
  1552.      */
  1553.     public void deleteProtocolPropertiesBinaryParameters(BinaryParameter ... parameters) throws DriverControlStationException{
  1554.        
  1555.         this.checkErrorInit();
  1556.                
  1557.         File file = null;
  1558.         if(this.idBinaryParameterRicevuti != null && this.idBinaryParameterRicevuti.size() >0){
  1559.             for (String bp : this.idBinaryParameterRicevuti) {
  1560.                 boolean delete = true;
  1561.                 if(parameters != null && parameters.length >0){
  1562.                     for (BinaryParameter binaryParameter : parameters) {
  1563.                         if(binaryParameter.getId() != null && binaryParameter.getId().equals(bp)){
  1564.                             delete = false;
  1565.                             break;
  1566.                         }
  1567.                     }
  1568.                 }
  1569.                
  1570.                 if(delete){
  1571.                     String val = this.getParameter(bp);
  1572.                     file = new File(getTmpDir() + File.separator + CostantiControlStation.TEMP_FILE_PREFIX +  val + CostantiControlStation.TEMP_FILE_SUFFIX);
  1573.                    
  1574.                     if(file.exists()) {
  1575.                         if(!file.delete()) {
  1576.                             // ignore
  1577.                         }
  1578.                     }
  1579.                 }
  1580.             }
  1581.         }
  1582.     }
  1583.    
  1584.     /***
  1585.      *
  1586.      * Cancella i file temporanei per i parametri passati.
  1587.      *
  1588.      * @param parameters
  1589.      * @throws DriverControlStationException
  1590.      */
  1591.     public void deleteBinaryParameters(BinaryParameter ... parameters) throws DriverControlStationException{
  1592.        
  1593.         this.checkErrorInit();
  1594.                
  1595.         if(parameters != null && parameters.length >0){
  1596.             for (BinaryParameter binaryParameter : parameters) {
  1597.                 this.deleteBinaryParameter(binaryParameter);
  1598.             }
  1599.         }
  1600.     }
  1601.    
  1602.     private void deleteBinaryParameter(BinaryParameter bp) throws DriverControlStationException{
  1603.        
  1604.         this.checkErrorInit();
  1605.                
  1606.         File file = null;
  1607.         if(StringUtils.isNotBlank(bp.getId())){
  1608.             file = new File(getTmpDir() + File.separator + CostantiControlStation.TEMP_FILE_PREFIX +  bp.getId() + CostantiControlStation.TEMP_FILE_SUFFIX);
  1609.            
  1610.             if(file.exists()) {
  1611.                 if(!file.delete()) {
  1612.                     // ignore
  1613.                 }
  1614.             }
  1615.         }
  1616.        
  1617.         bp.setValue(null);
  1618.         bp.setFilename(null);
  1619.         bp.setId(null);
  1620.     }


  1621.     public ProtocolProperties estraiProtocolPropertiesDaRequest(ConsoleConfiguration consoleConfiguration,ConsoleOperationType consoleOperationType,
  1622.             String propertyId, BinaryParameter contenutoDocumentoParameter) throws DriverControlStationException, UtilsException {
  1623.        
  1624.         this.checkErrorInit();
  1625.        
  1626.         String editMode = this.getParameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME);
  1627.         String postBackElementName = this.getParameter(Costanti.POSTBACK_ELEMENT_NAME);
  1628.         boolean primoAccessoAdd = (ConsoleOperationType.ADD.equals(consoleOperationType) &&
  1629.                 (editMode==null ||
  1630.                 CostantiControlStation.PARAMETRO_PROTOCOLLO.equals(postBackElementName) ||  // per default in accordo parte comune
  1631.                 AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ACCORDO.equals(postBackElementName))  // per default in accordo parte aspecifica
  1632.                 );
  1633.        
  1634.         ProtocolProperties properties = new ProtocolProperties();

  1635.         List<BaseConsoleItem> consoleItems = consoleConfiguration.getConsoleItem();

  1636.         for (BaseConsoleItem item : consoleItems) {
  1637.             // per ora prelevo solo i parametri che possono avere un valore non considero titoli e note
  1638.             if(item instanceof AbstractConsoleItem<?>){
  1639.                 ConsoleItemValueType consoleItemValueType = ProtocolPropertiesUtils.getConsoleItemValueType(item);
  1640.                 if(consoleItemValueType != null){
  1641.                     switch (consoleItemValueType) {
  1642.                     case BINARY:
  1643.                         BinaryParameter bp = contenutoDocumentoParameter;
  1644.                         if(propertyId == null || !propertyId.equals(item.getId())){
  1645.                             bp = this.getBinaryParameter(item.getId());
  1646.                         } else {
  1647.                             bp.setName(item.getId());
  1648.                         }
  1649.                         byte [] binValue = item.isLockedType() ? this.core.getDriverBYOKUtilities().unwrap(bp.getValue()) : bp.getValue();
  1650.                         BinaryProperty binaryProperty = ProtocolPropertiesFactory.newProperty(bp.getName(), binValue, bp.getFilename(), bp.getId());
  1651.                         properties.addProperty(binaryProperty);
  1652.                         break;
  1653.                     case NUMBER:
  1654.                         String lvS = item.isLockedType() ? this.getLockedParameter(item.getId()) : this.getParameter(item.getId());
  1655.                         Long longValue = null;
  1656.                         try{
  1657.                             // soluzione necessaria perche' il tipo di dato number puo' essere utilizzato anche negli input di tipo text che possono non controllare il tipo di dato inserito
  1658.                             longValue = StringUtils.isNotEmpty(lvS) ? Long.parseLong(lvS) : null;
  1659.                         }catch(NumberFormatException e) {
  1660.                             longValue = null;
  1661.                         }
  1662.                         NumberProperty numberProperty = ProtocolPropertiesFactory.newProperty(item.getId(), longValue);
  1663.                         if(primoAccessoAdd) {
  1664.                             numberProperty.setValue(((NumberConsoleItem) item).getDefaultValue());
  1665.                         }
  1666.                         properties.addProperty(numberProperty);
  1667.                         break;
  1668.                     case BOOLEAN:
  1669.                         String bvS = item.isLockedType() ? this.getLockedParameter(item.getId()) : this.getParameter(item.getId());
  1670.                         Boolean booleanValue = ServletUtils.isCheckBoxEnabled(bvS);
  1671.                         Boolean falseValue = null;
  1672.                         if(item instanceof BooleanConsoleItem) {
  1673.                             BooleanConsoleItem b = (BooleanConsoleItem) item;
  1674.                             if(!b.isConvertFalseAsNull()) {
  1675.                                 falseValue = false;
  1676.                             }
  1677.                         }
  1678.                         BooleanProperty booleanProperty = ProtocolPropertiesFactory.newProperty(item.getId(), booleanValue ? booleanValue : falseValue);
  1679.                         if(primoAccessoAdd) {
  1680.                             booleanProperty.setValue(((BooleanConsoleItem) item).getDefaultValue());
  1681.                         }
  1682.                         properties.addProperty(booleanProperty);
  1683.                         break;
  1684.                     case STRING:
  1685.                     default:
  1686.                         StringProperty stringProperty = null;
  1687.                         if(ConsoleItemType.MULTI_SELECT.equals(item.getType())) {
  1688.                             String [] parameterValues = this.getParameterValues(item.getId());
  1689.                             String value = parameterValues!=null && parameterValues.length>0 ? ProtocolPropertiesUtils.getValueMultiSelect(parameterValues) : null;
  1690.                             stringProperty = ProtocolPropertiesFactory.newProperty(item.getId(), value);
  1691.                         }
  1692.                         else {
  1693.                             String parameterValue = item.isLockedType() ? this.getLockedParameter(item.getId()) : this.getParameter(item.getId());
  1694.                             stringProperty = ProtocolPropertiesFactory.newProperty(item.getId(), parameterValue);
  1695.                         }
  1696.                         if(primoAccessoAdd) {
  1697.                             stringProperty.setValue(((StringConsoleItem) item).getDefaultValue());
  1698.                         }
  1699.                         properties.addProperty(stringProperty);
  1700.                         break;
  1701.                     }
  1702.                 }
  1703.             }
  1704.         }

  1705.         return properties;
  1706.     }
  1707.     public ProtocolProperties estraiProtocolPropertiesDaRequest(ConsoleConfiguration consoleConfiguration,ConsoleOperationType consoleOperationType) throws DriverControlStationException, UtilsException {
  1708.        
  1709.         this.checkErrorInit();
  1710.                
  1711.         return estraiProtocolPropertiesDaRequest(consoleConfiguration, consoleOperationType, null , null);
  1712.     }

  1713.     // Prepara il menu'
  1714.     public void makeMenu() throws DriverControlStationException {
  1715.         try {
  1716.             String userLogin = ServletUtils.getUserLoginFromSession(this.session);

  1717.             ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);

  1718.             PermessiUtente pu = null;
  1719.             User u = this.utentiCore.getUser(userLogin);
  1720.             pu = u.getPermessi();

  1721.             Boolean singlePdD = ServletUtils.getObjectFromSession(this.request, this.session, Boolean.class, CostantiControlStation.SESSION_PARAMETRO_SINGLE_PDD);
  1722.             if(singlePdD==null) {
  1723.                 singlePdD = this.core!=null ? this.core.isSinglePdD() : true;
  1724.             }

  1725.             boolean isModalitaAvanzata = this.isModalitaAvanzata();
  1726.             boolean isModalitaCompleta = this.isModalitaCompleta();
  1727.            
  1728.             List<IExtendedMenu> extendedMenu = this.core.getExtendedMenu();

  1729.             List<MenuEntry> menu = new ArrayList<>();

  1730.             boolean showAccordiCooperazione = pu.isAccordiCooperazione() && this.core.isAccordiCooperazioneEnabled();
  1731.            
  1732.             if(pu.isServizi() || showAccordiCooperazione){
  1733.                 Boolean serviziVisualizzaModalitaElenco = ConsoleProperties.getInstance().isEnableServiziVisualizzaModalitaElenco();
  1734.                 // Oggetti del registro compatti
  1735.                 MenuEntry me = new MenuEntry();
  1736.                 String[][] entries = null;
  1737.                 me.setTitle(Costanti.PAGE_DATA_TITLE_LABEL_REGISTRO);

  1738.                 //Calcolo del numero di entries
  1739.                 int totEntries = 0;
  1740.                 // PdD, Soggetti, SA, ASPC e ASPS con permessi S
  1741.                 if(pu.isServizi()){
  1742.                     // Link PdD
  1743.                     if(this.core.isRegistroServiziLocale()){
  1744.                         if(this.core.isGestionePddAbilitata(this)) {
  1745.                             totEntries ++;
  1746.                         }
  1747.                     }

  1748.                     // Soggetti ed SA
  1749.                     totEntries += 2;

  1750.                     // ASPC e ASPS
  1751.                     if(this.core.isRegistroServiziLocale()){
  1752.                         // ASPC
  1753.                         totEntries ++;
  1754.                        
  1755.                         if(isModalitaCompleta) {
  1756.                             totEntries +=1;
  1757.                         } else {
  1758.                             // ASPS vecchia visualizzazione
  1759.                             if(serviziVisualizzaModalitaElenco) {
  1760.                                 totEntries +=2;
  1761.                             }
  1762.                             // ASPS nuova visualizzazione
  1763.                             totEntries +=2;
  1764.                         }
  1765.                     }
  1766.                 }

  1767.                 // Cooperazione e Accordi Composti con permessi P
  1768.                 if(showAccordiCooperazione){
  1769.                     if(this.core.isRegistroServiziLocale()){
  1770.                         totEntries +=2;
  1771.                     }
  1772.                 }

  1773.                 // Ruoli, Token Policy e Scope
  1774.                 if(pu.isServizi()){
  1775.                     if(this.core.isRegistroServiziLocale()){
  1776.                         // ruoli
  1777.                         totEntries +=1;
  1778.                         // scope
  1779.                         totEntries +=1;
  1780.                     }
  1781.                 }
  1782.                
  1783.                 // PA e PD con permessi S e interfaccia avanzata
  1784.                 if(pu.isServizi() && this.isModalitaCompleta()){
  1785.                     totEntries +=2;
  1786.                 }

  1787.                 // Extended Menu
  1788.                 if(extendedMenu!=null){
  1789.                     for (IExtendedMenu extMenu : extendedMenu) {
  1790.                         List<ExtendedMenuItem> list =
  1791.                                 extMenu.getExtendedItemsMenuRegistro(isModalitaAvanzata,
  1792.                                         this.core.isRegistroServiziLocale(), singlePdD, pu);
  1793.                         if(list!=null && list.size()>0){
  1794.                             totEntries +=list.size();
  1795.                         }
  1796.                     }
  1797.                 }

  1798.                 // Creo le entries e le valorizzo
  1799.                 entries = new String[totEntries][2];

  1800.                 int index = 0;
  1801.                 boolean pddVisualizzate = false;
  1802.                 // PdD, Soggetti, SA, ASPC e ASPS con permessi S
  1803.                 if(pu.isServizi()){
  1804.                    
  1805.                     //Link PdD
  1806.                     if(this.core.isRegistroServiziLocale()){
  1807.                         if(this.core.isGestionePddAbilitata(this)) {
  1808.                             pddVisualizzate = true;
  1809.                             entries[index][0] = PddCostanti.LABEL_PDD_MENU_VISUALE_AGGREGATA;
  1810.                             if (singlePdD == false) {
  1811.                                 entries[index][1] = PddCostanti.SERVLET_NAME_PDD_LIST;
  1812.                             }else {
  1813.                                 entries[index][1] = PddCostanti.SERVLET_NAME_PDD_SINGLEPDD_LIST;
  1814.                             }
  1815.                             index++;
  1816.                         }
  1817.                     }

  1818.                     if(pddVisualizzate) {
  1819.                    
  1820.                         // Soggetti
  1821.                         entries[index][0] = SoggettiCostanti.LABEL_SOGGETTI_MENU_VISUALE_AGGREGATA;
  1822.                         entries[index][1] = SoggettiCostanti.SERVLET_NAME_SOGGETTI_LIST;
  1823.                         index++;
  1824.    
  1825.                         //SA
  1826.                         entries[index][0] = ServiziApplicativiCostanti.LABEL_SA_MENU_VISUALE_AGGREGATA;
  1827.                         entries[index][1] = ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_LIST;
  1828.                         index++;
  1829.                        
  1830.                     }

  1831.                     // ASPC e ASPS
  1832.                     if(this.core.isRegistroServiziLocale()){
  1833.                         //ASPC
  1834.                         if(isModalitaCompleta) {
  1835.                             entries[index][0] = AccordiServizioParteComuneCostanti.LABEL_APC_MENU_VISUALE_AGGREGATA;
  1836.                             entries[index][1] = AccordiServizioParteComuneCostanti.SERVLET_NAME_APC_LIST+"?"+
  1837.                                     AccordiServizioParteComuneCostanti.PARAMETRO_APC_TIPO_ACCORDO+"="+
  1838.                                     AccordiServizioParteComuneCostanti.PARAMETRO_VALORE_APC_TIPO_ACCORDO_PARTE_COMUNE;
  1839.                             index++;
  1840.                         } else {
  1841.                             entries[index][0] = AccordiServizioParteComuneCostanti.LABEL_APC_MENU_VISUALE_AGGREGATA;
  1842.                             entries[index][1] = ApiCostanti.SERVLET_NAME_APC_API_LIST +"?"+
  1843.                                     AccordiServizioParteComuneCostanti.PARAMETRO_APC_TIPO_ACCORDO+"="+
  1844.                                     AccordiServizioParteComuneCostanti.PARAMETRO_VALORE_APC_TIPO_ACCORDO_PARTE_COMUNE;
  1845.                             index++;
  1846.                         }

  1847.                         //ASPS
  1848.                         if(isModalitaCompleta) {
  1849.                             entries[index][0] = AccordiServizioParteSpecificaCostanti.LABEL_APS_MENU_VISUALE_AGGREGATA;
  1850.                             entries[index][1] = AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST+"?"+
  1851.                                     AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE+"="+
  1852.                                     AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_COMPLETA;
  1853.                             index++;
  1854.                         }
  1855.                         else {
  1856.                             // ASPS vecchia visualizzazione
  1857.                             if(serviziVisualizzaModalitaElenco) {
  1858.                                 entries[index][0] = AccordiServizioParteSpecificaCostanti.LABEL_APS_MENU_VISUALE_AGGREGATA;
  1859.                                 entries[index][1] = AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST+"?"+
  1860.                                         AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE+"="+
  1861.                                         AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE;
  1862.                                 index++;
  1863.                                
  1864.                                 entries[index][0] = AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUIZIONI_MENU_VISUALE_AGGREGATA;
  1865.                                 entries[index][1] = AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST+"?"+
  1866.                                         AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE+"="+
  1867.                                         AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE;
  1868.                                 index++;
  1869.                             }
  1870.                            
  1871.                             // ASPS nuova visualizzazione
  1872.                             entries[index][0] = ErogazioniCostanti.LABEL_ASPS_EROGAZIONI;
  1873.                             entries[index][1] = ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST+"?"+
  1874.                                     AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE+"="+
  1875.                                     AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE;
  1876.                             index++;
  1877.                            
  1878.                             entries[index][0] = ErogazioniCostanti.LABEL_ASPS_FRUIZIONI;
  1879.                             entries[index][1] = ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST+"?"+
  1880.                                     AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE+"="+
  1881.                                     AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE;
  1882.                             index++;
  1883.                         }
  1884.                     }
  1885.                 }

  1886.                 // Cooperazione e Accordi Composti con permessi P
  1887.                 if(showAccordiCooperazione){
  1888.                     if(this.core.isRegistroServiziLocale()){
  1889.                         //COOPERAZIONE
  1890.                         entries[index][0] = AccordiCooperazioneCostanti.LABEL_AC_MENU_VISUALE_AGGREGATA;
  1891.                         entries[index][1] = AccordiCooperazioneCostanti.SERVLET_NAME_ACCORDI_COOPERAZIONE_LIST;
  1892.                         index++;

  1893.                         // COMPOSTO
  1894.                         entries[index][0] = AccordiServizioParteComuneCostanti.LABEL_ASC_MENU_VISUALE_AGGREGATA;
  1895.                         entries[index][1] = AccordiServizioParteComuneCostanti.SERVLET_NAME_APC_LIST+"?"+
  1896.                                 AccordiServizioParteComuneCostanti.PARAMETRO_APC_TIPO_ACCORDO+"="+
  1897.                                 AccordiServizioParteComuneCostanti.PARAMETRO_VALORE_APC_TIPO_ACCORDO_SERVIZIO_COMPOSTO;
  1898.                         index++;
  1899.                     }
  1900.                 }
  1901.                
  1902.                 if(!pddVisualizzate) {
  1903.                    
  1904.                     // Soggetti
  1905.                     entries[index][0] = SoggettiCostanti.LABEL_SOGGETTI_MENU_VISUALE_AGGREGATA;
  1906.                     entries[index][1] = SoggettiCostanti.SERVLET_NAME_SOGGETTI_LIST;
  1907.                     index++;

  1908.                     // SA
  1909.                     if(this.isModalitaCompleta()) {
  1910.                         entries[index][0] = ServiziApplicativiCostanti.LABEL_SA_MENU_VISUALE_AGGREGATA;
  1911.                     }
  1912.                     else {
  1913.                         entries[index][0] = ServiziApplicativiCostanti.LABEL_APPLICATIVI_MENU_VISUALE_AGGREGATA;
  1914.                     }
  1915.                     entries[index][1] = ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_LIST;
  1916.                     index++;
  1917.                    
  1918.                 }
  1919.                
  1920.                 // Ruoli, PolicyToken e Scopes
  1921.                 if(pu.isServizi()){
  1922.                     if(this.core.isRegistroServiziLocale()){
  1923.                         entries[index][0] = RuoliCostanti.LABEL_RUOLI;
  1924.                         entries[index][1] = RuoliCostanti.SERVLET_NAME_RUOLI_LIST;
  1925.                         index++;
  1926.                                                
  1927.                         entries[index][0] = ScopeCostanti.LABEL_SCOPES;
  1928.                         entries[index][1] = ScopeCostanti.SERVLET_NAME_SCOPE_LIST;
  1929.                         index++;
  1930.                     }
  1931.                 }

  1932.                 // PA e PD con permessi S e interfaccia avanzata
  1933.                 if(pu.isServizi() && this.isModalitaCompleta()){
  1934.                     //PD
  1935.                     entries[index][0] = PorteDelegateCostanti.LABEL_PD_MENU_VISUALE_AGGREGATA;
  1936.                     entries[index][1] = PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_LIST;
  1937.                     index++;

  1938.                     //PA
  1939.                     entries[index][0] = PorteApplicativeCostanti.LABEL_PA_MENU_VISUALE_AGGREGATA;
  1940.                     entries[index][1] = PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_LIST;
  1941.                     index++;
  1942.                 }

  1943.                 // Extended Menu
  1944.                 if(extendedMenu!=null){
  1945.                     for (IExtendedMenu extMenu : extendedMenu) {
  1946.                         List<ExtendedMenuItem> list =
  1947.                                 extMenu.getExtendedItemsMenuRegistro(isModalitaAvanzata,
  1948.                                         this.core.isRegistroServiziLocale(), singlePdD, pu);
  1949.                         if(list!=null){
  1950.                             for (ExtendedMenuItem extendedMenuItem : list) {
  1951.                                 entries[index][0] = extendedMenuItem.getLabel();
  1952.                                 entries[index][1] = extendedMenuItem.getUrl();
  1953.                                 index++;
  1954.                             }
  1955.                         }
  1956.                     }
  1957.                 }

  1958.                 me.setEntries(entries);
  1959.                 menu.add(me);
  1960.             }




  1961.             if (singlePdD) {

  1962.                 List<ExtendedMenuItem> listStrumenti = null;
  1963.                 if(extendedMenu!=null){
  1964.                     for (IExtendedMenu extMenu : extendedMenu) {
  1965.                         listStrumenti =
  1966.                                 extMenu.getExtendedItemsMenuStrumenti(isModalitaAvanzata,
  1967.                                         this.core.isRegistroServiziLocale(), singlePdD, pu);
  1968.                     }
  1969.                 }
  1970.                
  1971.                 List<String> aliases = this.confCore.getJmxPdDAliases();
  1972.                
  1973.                 boolean showCodaMessaggi = pu.isCodeMessaggi() && this.core.showCodaMessage();
  1974.                
  1975.                 if ( showCodaMessaggi || pu.isAuditing() ||
  1976.                         (pu.isSistema() && aliases!=null && aliases.size()>0) ||
  1977.                         (listStrumenti!=null && listStrumenti.size()>0) ) {
  1978.                     // Se l'utente non ha i permessi "diagnostica", devo
  1979.                     // gestire la reportistica
  1980.                     MenuEntry me = new MenuEntry();
  1981.                     me.setTitle(CostantiControlStation.LABEL_STRUMENTI);

  1982.                     int totEntries = 0;
  1983.                     if(pu.isSistema() && aliases!=null && aliases.size()>0){
  1984.                         totEntries++; // runtime
  1985.                     }
  1986.                     if(this.isModalitaAvanzata() && showCodaMessaggi) {
  1987.                         totEntries++;
  1988.                     }
  1989.                     if(pu.isAuditing()) {
  1990.                         totEntries++;
  1991.                     }

  1992.                     // Extended Menu
  1993.                     if(extendedMenu!=null){
  1994.                         for (IExtendedMenu extMenu : extendedMenu) {
  1995.                             List<ExtendedMenuItem> list =
  1996.                                     extMenu.getExtendedItemsMenuStrumenti(isModalitaAvanzata,
  1997.                                             this.core.isRegistroServiziLocale(), singlePdD, pu);
  1998.                             if(list!=null && list.size()>0){
  1999.                                 totEntries +=list.size();
  2000.                             }
  2001.                         }
  2002.                     }

  2003.                     String[][] entries = new String[totEntries][2];

  2004.                     int i = 0;

  2005.                     if(pu.isSistema() && aliases!=null && aliases.size()>0){
  2006.                         entries[i][0] = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RUNTIME;
  2007.                         entries[i][1] = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_SISTEMA_ADD;
  2008.                         i++;
  2009.                     }
  2010.                    
  2011.                     if (pu.isAuditing()) {
  2012.                         entries[i][0] = AuditCostanti.LABEL_AUDIT;
  2013.                         entries[i][1] = AuditCostanti.SERVLET_NAME_AUDITING;
  2014.                         i++;
  2015.                     }
  2016.                     if (this.isModalitaAvanzata() && showCodaMessaggi) {
  2017.                         entries[i][0] = MonitorCostanti.LABEL_MONITOR;
  2018.                         entries[i][1] = MonitorCostanti.SERVLET_NAME_MONITOR;
  2019.                         i++;
  2020.                     }
  2021.                    
  2022.                     // Extended Menu
  2023.                     if(extendedMenu!=null){
  2024.                         for (IExtendedMenu extMenu : extendedMenu) {
  2025.                             List<ExtendedMenuItem> list =
  2026.                                     extMenu.getExtendedItemsMenuStrumenti(isModalitaAvanzata,
  2027.                                             this.core.isRegistroServiziLocale(), singlePdD, pu);
  2028.                             if(list!=null){
  2029.                                 for (ExtendedMenuItem extendedMenuItem : list) {
  2030.                                     entries[i][0] = extendedMenuItem.getLabel();
  2031.                                     entries[i][1] = extendedMenuItem.getUrl();
  2032.                                     i++;
  2033.                                 }
  2034.                             }
  2035.                         }
  2036.                     }

  2037.                     me.setEntries(entries);
  2038.                     menu.add(me);
  2039.                 }
  2040.                
  2041.                

  2042.                 // Label Configurazione
  2043.                 if(pu.isSistema()){

  2044.                     MenuEntry me = new MenuEntry();
  2045.                     me.setTitle(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE);
  2046.                     // Se l'utente ha anche i permessi "utenti", la
  2047.                     // configurazione utente la gestisco dopo
  2048.                     String[][] entries = null;
  2049.                     String[][] entriesUtenti = null;
  2050.                     int dimensioneEntries = 0;


  2051.                     dimensioneEntries = 7; // configurazione, controllo del traffico, tracciamento, registrazioneMessaggi, policy, aa e audit
  2052.                    
  2053.                     if(this.core.isVisualizzaConfigurazioneAllarmiEnabled()) { // configurazione allarmi (solo se sono stati caricati dei plugin di tipo allarme)
  2054.                         dimensioneEntries++; // configurazione allarmi
  2055.                     }
  2056.                    
  2057.                     dimensioneEntries++; // gruppi

  2058.                     if(!isModalitaStandard()) {
  2059.                         dimensioneEntries++; // caches
  2060.                         dimensioneEntries++; // remote stores
  2061.                     }
  2062.                    
  2063.                     if(this.core.isShowPulsantiImportExport() && pu.isServizi()){
  2064.                         dimensioneEntries++; // importa
  2065.                         if(exporterUtils.existsAtLeastOneExportMode(ArchiveType.CONFIGURAZIONE, this.request, this.session)){
  2066.                             dimensioneEntries++; // esporta
  2067.                             if(isModalitaAvanzata){
  2068.                                 dimensioneEntries++; // elimina
  2069.                             }
  2070.                         }
  2071.                     }
  2072.                     if (!pu.isUtenti()){
  2073.                         //dimensioneEntries++; // change password
  2074.                     }else {
  2075.                         entriesUtenti = getVoceMenuUtenti();
  2076.                         dimensioneEntries += entriesUtenti.length;
  2077.                     }

  2078.                     // Extended Menu
  2079.                     if(extendedMenu!=null){
  2080.                         for (IExtendedMenu extMenu : extendedMenu) {
  2081.                             List<ExtendedMenuItem> list =
  2082.                                     extMenu.getExtendedItemsMenuConfigurazione(isModalitaAvanzata,
  2083.                                             this.core.isRegistroServiziLocale(), singlePdD, pu);
  2084.                             if(list!=null && list.size()>0){
  2085.                                 dimensioneEntries +=list.size();
  2086.                             }
  2087.                         }
  2088.                     }

  2089.                     entries = new String[dimensioneEntries][2];

  2090.                     int index = 0;
  2091.                     entries[index][0] = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_GENERALE_MENU;
  2092.                     entries[index][1] = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE;
  2093.                     index++;
  2094.                     if(!isModalitaStandard()) {
  2095.                         entries[index][0] = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CACHES;
  2096.                         entries[index][1] = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_GENERALE+"?"+
  2097.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CACHES+"="+Costanti.CHECK_BOX_ENABLED;
  2098.                         index++;
  2099.                     }
  2100.                     // remote stores
  2101.                     if(!isModalitaStandard()) {
  2102.                         entries[index][0] = RemoteStoresCostanti.LABEL_CACHE_PDND;
  2103.                         entries[index][1] = RemoteStoresCostanti.SERVLET_NAME_REMOTE_STORES_KEYS_LIST;
  2104.                         index++;
  2105.                     }
  2106.                    
  2107.                    
  2108.                     entries[index][0] = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CONTROLLO_TRAFFICO;
  2109.                     entries[index][1] = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO;
  2110.                     index++;
  2111.                     entries[index][0] = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO_MENU;
  2112.                     entries[index][1] = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI+"?"+
  2113.                             ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE+"="+ConfigurazioneCostanti.VALORE_PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE_TRACCIAMENTO;
  2114.                     index++;
  2115.                     entries[index][0] = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_MESSAGGI_MENU;
  2116.                     entries[index][1] = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_TRACCIAMENTO_TRANSAZIONI+"?"+
  2117.                             ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE+"="+ConfigurazioneCostanti.VALORE_PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE_REGISTRAZIONE_MESSAGGI;
  2118.                     index++;
  2119.                     if(this.core.isVisualizzaConfigurazioneAllarmiEnabled()) { // configurazione allarmi (solo se sono stati caricati dei plugin di tipo allarme)
  2120.                         entries[index][0] = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI;
  2121.                         entries[index][1] = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_LIST;
  2122.                         index++;    
  2123.                     }
  2124.                     entries[index][0] = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN;
  2125.                     entries[index][1] = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_LIST+"?"+
  2126.                             ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE+"="+ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE_VALORE_TOKEN;
  2127.                     index++;
  2128.                     entries[index][0] = ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ATTRIBUTE_AUTHORITY;
  2129.                     entries[index][1] = ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_POLICY_GESTIONE_TOKEN_LIST+"?"+
  2130.                             ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE+"="+ConfigurazioneCostanti.PARAMETRO_TOKEN_POLICY_TIPOLOGIA_INFORMAZIONE_VALORE_ATTRIBUTE_AUTHORITY;
  2131.                     index++;
  2132.                    
  2133.                     entries[index][0] = GruppiCostanti.LABEL_GRUPPI;
  2134.                     entries[index][1] = GruppiCostanti.SERVLET_NAME_GRUPPI_LIST;
  2135.                     index++;
  2136.                     // link utenti sotto quello di configurazione  generale
  2137.                     if (pu.isUtenti()) {
  2138.                         for (int j = 0; j < entriesUtenti.length; j++) {
  2139.                             entries[index][0] = entriesUtenti[j][0];
  2140.                             entries[index][1] = entriesUtenti[j][1];
  2141.                             index++;        
  2142.                         }
  2143.                     }
  2144.                     if(this.core.isShowPulsantiImportExport() && pu.isServizi()){
  2145.                         entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_IMPORT;
  2146.                         entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_IMPORT+"?"+
  2147.                                 ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA+"="+ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA_IMPORT;
  2148.                         index++;
  2149.                         if(exporterUtils.existsAtLeastOneExportMode(ArchiveType.CONFIGURAZIONE, this.request, this.session)){
  2150.                             entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_EXPORT;
  2151.                             entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_EXPORT+"?"+ArchiviCostanti.PARAMETRO_ARCHIVI_EXPORT_TIPO+"="+ArchiveType.CONFIGURAZIONE.name();
  2152.                             index++;

  2153.                             if(isModalitaAvanzata){
  2154.                                 entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_ELIMINA;
  2155.                                 entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_IMPORT+"?"+
  2156.                                         ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA+"="+ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA_ELIMINA;
  2157.                                 index++;
  2158.                             }
  2159.                         }
  2160.                     }
  2161.                     entries[index][0] = AuditCostanti.LABEL_AUDIT;
  2162.                     entries[index][1] = AuditCostanti.SERVLET_NAME_AUDIT;
  2163.                     index++;
  2164.                    
  2165.                     //link cambio password
  2166.                     if (!pu.isUtenti()) {
  2167. //                      entries[index][0] = UtentiCostanti.LABEL_UTENTE;
  2168. //                      entries[index][1] = UtentiCostanti.SERVLET_NAME_UTENTE_CHANGE;
  2169. //                      index++;
  2170.                     }

  2171.                     // Extended Menu
  2172.                     if(extendedMenu!=null){
  2173.                         for (IExtendedMenu extMenu : extendedMenu) {
  2174.                             List<ExtendedMenuItem> list =
  2175.                                     extMenu.getExtendedItemsMenuConfigurazione(isModalitaAvanzata,
  2176.                                             this.core.isRegistroServiziLocale(), singlePdD, pu);
  2177.                             if(list!=null){
  2178.                                 for (ExtendedMenuItem extendedMenuItem : list) {
  2179.                                     entries[index][0] = extendedMenuItem.getLabel();
  2180.                                     entries[index][1] = extendedMenuItem.getUrl();
  2181.                                     index++;
  2182.                                 }
  2183.                             }
  2184.                         }
  2185.                     }

  2186.                     me.setEntries(entries);
  2187.                     menu.add(me);

  2188.                 }else {

  2189.                     // se non esiste la configurazione, devo cmq gestire il caso se non ho i diritti utente e se posso comunque importare servizi
  2190.                     int dimensioneEntries = 0;
  2191.                     String[][] entriesUtenti = null;
  2192.                     if(this.core.isShowPulsantiImportExport() && pu.isServizi()){
  2193.                         dimensioneEntries++; // importa
  2194.                         if(exporterUtils.existsAtLeastOneExportMode(ArchiveType.CONFIGURAZIONE, this.request, this.session)){
  2195.                             dimensioneEntries++; // esporta
  2196.                             if(isModalitaAvanzata){
  2197.                                 dimensioneEntries++; // elimina
  2198.                             }
  2199.                         }
  2200.                     }
  2201.                     if(!pu.isUtenti()){
  2202.                         //dimensioneEntries++;  // change password
  2203.                     }else {
  2204.                         entriesUtenti = getVoceMenuUtenti();
  2205.                         dimensioneEntries += entriesUtenti.length;
  2206.                     }

  2207.                     // Extended Menu
  2208.                     if(extendedMenu!=null){
  2209.                         for (IExtendedMenu extMenu : extendedMenu) {
  2210.                             List<ExtendedMenuItem> list =
  2211.                                     extMenu.getExtendedItemsMenuConfigurazione(isModalitaAvanzata,
  2212.                                             this.core.isRegistroServiziLocale(), singlePdD, pu);
  2213.                             if(list!=null && list.size()>0){
  2214.                                 dimensioneEntries +=list.size();
  2215.                             }
  2216.                         }
  2217.                     }

  2218.                     if(dimensioneEntries>0){
  2219.                         // Comunque devo permettere di cambiare la password ad ogni utente, se l'utente stesso non puo' gestire gli utenti
  2220.                         MenuEntry me = new MenuEntry();
  2221.                         me.setTitle(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE);
  2222.                         String[][] entries = new String[dimensioneEntries][2];
  2223.                         int index = 0;
  2224.                         // link utenti sotto quello di configurazione  generale
  2225.                         if (pu.isUtenti()) {
  2226.                             for (int j = 0; j < entriesUtenti.length; j++) {
  2227.                                 entries[index][0] = entriesUtenti[j][0];
  2228.                                 entries[index][1] = entriesUtenti[j][1];
  2229.                                 index++;        
  2230.                             }
  2231.                         }
  2232.                         if(this.core.isShowPulsantiImportExport() && pu.isServizi()){
  2233.                             entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_IMPORT;
  2234.                             entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_IMPORT+"?"+
  2235.                                     ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA+"="+ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA_IMPORT;
  2236.                             index++;
  2237.                             if(exporterUtils.existsAtLeastOneExportMode(ArchiveType.CONFIGURAZIONE, this.request, this.session)){
  2238.                                 entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_EXPORT;
  2239.                                 entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_EXPORT+"?"+ArchiviCostanti.PARAMETRO_ARCHIVI_EXPORT_TIPO+"="+ArchiveType.CONFIGURAZIONE.name();
  2240.                                 index++;

  2241.                                 if(isModalitaAvanzata){
  2242.                                     entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_ELIMINA;
  2243.                                     entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_IMPORT+"?"+
  2244.                                             ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA+"="+ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA_ELIMINA;
  2245.                                     index++;        
  2246.                                 }
  2247.                             }
  2248.                         }
  2249.                         if (!pu.isUtenti()) {
  2250. //                          entries[index][0] = UtentiCostanti.LABEL_UTENTE;
  2251. //                          entries[index][1] = UtentiCostanti.SERVLET_NAME_UTENTE_CHANGE;
  2252. //                          index++;
  2253.                         }

  2254.                         // Extended Menu
  2255.                         if(extendedMenu!=null){
  2256.                             for (IExtendedMenu extMenu : extendedMenu) {
  2257.                                 List<ExtendedMenuItem> list =
  2258.                                         extMenu.getExtendedItemsMenuConfigurazione(isModalitaAvanzata,
  2259.                                                 this.core.isRegistroServiziLocale(), singlePdD, pu);
  2260.                                 if(list!=null){
  2261.                                     for (ExtendedMenuItem extendedMenuItem : list) {
  2262.                                         entries[index][0] = extendedMenuItem.getLabel();
  2263.                                         entries[index][1] = extendedMenuItem.getUrl();
  2264.                                         index++;
  2265.                                     }
  2266.                                 }
  2267.                             }
  2268.                         }

  2269.                         me.setEntries(entries);
  2270.                         menu.add(me);
  2271.                     }
  2272.                 }

  2273.                
  2274.             } else {

  2275.                 // SinglePdD=false
  2276.                 if(pu.isSistema()){

  2277.                     MenuEntry me = new MenuEntry();
  2278.                     me.setTitle(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE);

  2279.                     // Se l'utente ha anche i permessi "utenti", la
  2280.                     // configurazione utente la gestisco dopo
  2281.                     String[][] entries = null;
  2282.                     String[][] entriesUtenti = null;
  2283.                     int dimensioneEntries = 1; //  audit
  2284.                     if(this.core.isShowPulsantiImportExport() && pu.isServizi()){
  2285.                         dimensioneEntries++; // importa
  2286.                         if(exporterUtils.existsAtLeastOneExportMode(ArchiveType.CONFIGURAZIONE, this.request, this.session)){
  2287.                             dimensioneEntries++; // esporta
  2288.                             if(isModalitaAvanzata){
  2289.                                 dimensioneEntries++; // elimina
  2290.                             }
  2291.                         }
  2292.                     }
  2293.                     if (!pu.isUtenti()){
  2294.                         dimensioneEntries++; // change password
  2295.                     }else {
  2296.                         entriesUtenti = getVoceMenuUtenti();
  2297.                         dimensioneEntries += entriesUtenti.length;
  2298.                     }

  2299.                     // Extended Menu
  2300.                     if(extendedMenu!=null){
  2301.                         for (IExtendedMenu extMenu : extendedMenu) {
  2302.                             List<ExtendedMenuItem> list =
  2303.                                     extMenu.getExtendedItemsMenuConfigurazione(isModalitaAvanzata,
  2304.                                             this.core.isRegistroServiziLocale(), singlePdD, pu);
  2305.                             if(list!=null && list.size()>0){
  2306.                                 dimensioneEntries +=list.size();
  2307.                             }
  2308.                         }
  2309.                     }

  2310.                     entries = new String[dimensioneEntries][2];

  2311.                     int index = 0;
  2312.                     // link utenti sotto quello di configurazione  generale
  2313.                     if (pu.isUtenti()) {
  2314.                         if(entriesUtenti!=null) {
  2315.                             for (int j = 0; j < entriesUtenti.length; j++) {
  2316.                                 entries[index][0] = entriesUtenti[j][0];
  2317.                                 entries[index][1] = entriesUtenti[j][1];
  2318.                                 index++;        
  2319.                             }
  2320.                         }
  2321.                     }
  2322.                     if(this.core.isShowPulsantiImportExport() && pu.isServizi()){
  2323.                         entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_IMPORT;
  2324.                         entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_IMPORT+"?"+
  2325.                                 ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA+"="+ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA_IMPORT;
  2326.                         index++;
  2327.                         if(exporterUtils.existsAtLeastOneExportMode(ArchiveType.CONFIGURAZIONE, this.request, this.session)){
  2328.                             entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_EXPORT;
  2329.                             entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_EXPORT+"?"+ArchiviCostanti.PARAMETRO_ARCHIVI_EXPORT_TIPO+"="+ArchiveType.CONFIGURAZIONE.name();
  2330.                             index++;

  2331.                             if(isModalitaAvanzata){
  2332.                                 entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_ELIMINA;
  2333.                                 entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_IMPORT+"?"+
  2334.                                         ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA+"="+ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA_ELIMINA;
  2335.                                 index++;
  2336.                             }
  2337.                         }
  2338.                     }
  2339.                     entries[index][0] = AuditCostanti.LABEL_AUDIT;
  2340.                     entries[index][1] = AuditCostanti.SERVLET_NAME_AUDIT;
  2341.                     index++;
  2342.                    
  2343.                     if (!pu.isUtenti()) {
  2344.                         entries[index][0] = UtentiCostanti.LABEL_UTENTE;
  2345.                         entries[index][1] = UtentiCostanti.SERVLET_NAME_UTENTE_CHANGE;
  2346.                         index++;
  2347.                     }

  2348.                     // Extended Menu
  2349.                     if(extendedMenu!=null){
  2350.                         for (IExtendedMenu extMenu : extendedMenu) {
  2351.                             List<ExtendedMenuItem> list =
  2352.                                     extMenu.getExtendedItemsMenuConfigurazione(isModalitaAvanzata,
  2353.                                             this.core.isRegistroServiziLocale(), singlePdD, pu);
  2354.                             if(list!=null){
  2355.                                 for (ExtendedMenuItem extendedMenuItem : list) {
  2356.                                     entries[index][0] = extendedMenuItem.getLabel();
  2357.                                     entries[index][1] = extendedMenuItem.getUrl();
  2358.                                     index++;
  2359.                                 }
  2360.                             }
  2361.                         }
  2362.                     }

  2363.                     me.setEntries(entries);
  2364.                     menu.add(me);

  2365.                 }else {

  2366.                     // se non esiste la configurazione, devo cmq gestire il caso se non ho i diritti utente e se posso comunque importare servizi
  2367.                     int dimensioneEntries = 0;
  2368.                     String[][] entriesUtenti = null;
  2369.                     if(this.core.isShowPulsantiImportExport() && pu.isServizi()){
  2370.                         dimensioneEntries++; // importa
  2371.                         if(exporterUtils.existsAtLeastOneExportMode(ArchiveType.CONFIGURAZIONE, this.request, this.session)){
  2372.                             dimensioneEntries++; // esporta
  2373.                             if(isModalitaAvanzata){
  2374.                                 dimensioneEntries++; // elimina
  2375.                             }
  2376.                         }
  2377.                     }
  2378.                     if(!pu.isUtenti()){
  2379.                         dimensioneEntries++;  // change password
  2380.                     }else {
  2381.                         entriesUtenti = getVoceMenuUtenti();
  2382.                         dimensioneEntries += entriesUtenti.length;
  2383.                     }

  2384.                     // Extended Menu
  2385.                     if(extendedMenu!=null){
  2386.                         for (IExtendedMenu extMenu : extendedMenu) {
  2387.                             List<ExtendedMenuItem> list =
  2388.                                     extMenu.getExtendedItemsMenuConfigurazione(isModalitaAvanzata,
  2389.                                             this.core.isRegistroServiziLocale(), singlePdD, pu);
  2390.                             if(list!=null && list.size()>0){
  2391.                                 dimensioneEntries +=list.size();
  2392.                             }
  2393.                         }
  2394.                     }

  2395.                     if(dimensioneEntries>0){
  2396.                         // Comunque devo permettere di cambiare la password ad ogni utente, se l'utente stesso non puo' gestire gli utenti
  2397.                         MenuEntry me = new MenuEntry();
  2398.                         me.setTitle(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE);
  2399.                         String[][] entries = new String[dimensioneEntries][2];
  2400.                         int index = 0;
  2401.                         // link utenti sotto quello di configurazione  generale
  2402.                         if (pu.isUtenti()) {
  2403.                             if(entriesUtenti!=null) {
  2404.                                 for (int j = 0; j < entriesUtenti.length; j++) {
  2405.                                     entries[index][0] = entriesUtenti[j][0];
  2406.                                     entries[index][1] = entriesUtenti[j][1];
  2407.                                     index++;        
  2408.                                 }
  2409.                             }
  2410.                         }
  2411.                         if(this.core.isShowPulsantiImportExport() && pu.isServizi()){
  2412.                             entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_IMPORT;
  2413.                             entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_IMPORT+"?"+
  2414.                                     ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA+"="+ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA_IMPORT;
  2415.                             index++;
  2416.                             if(exporterUtils.existsAtLeastOneExportMode(ArchiveType.CONFIGURAZIONE, this.request, this.session)){
  2417.                                 entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_EXPORT;
  2418.                                 entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_EXPORT+"?"+ArchiviCostanti.PARAMETRO_ARCHIVI_EXPORT_TIPO+"="+ArchiveType.CONFIGURAZIONE.name();
  2419.                                 index++;

  2420.                                 if(isModalitaAvanzata){
  2421.                                     entries[index][0] = ArchiviCostanti.LABEL_ARCHIVI_ELIMINA;
  2422.                                     entries[index][1] = ArchiviCostanti.SERVLET_NAME_ARCHIVI_IMPORT+"?"+
  2423.                                             ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA+"="+ArchiviCostanti.PARAMETRO_ARCHIVI_IMPORTER_MODALITA_ELIMINA;
  2424.                                     index++;        
  2425.                                 }
  2426.                             }
  2427.                         }
  2428.                         if (!pu.isUtenti()) {
  2429.                             entries[index][0] = UtentiCostanti.LABEL_UTENTE;
  2430.                             entries[index][1] = UtentiCostanti.SERVLET_NAME_UTENTE_CHANGE;
  2431.                             index++;
  2432.                         }

  2433.                         // Extended Menu
  2434.                         if(extendedMenu!=null){
  2435.                             for (IExtendedMenu extMenu : extendedMenu) {
  2436.                                 List<ExtendedMenuItem> list =
  2437.                                         extMenu.getExtendedItemsMenuConfigurazione(isModalitaAvanzata,
  2438.                                                 this.core.isRegistroServiziLocale(), singlePdD, pu);
  2439.                                 if(list!=null){
  2440.                                     for (ExtendedMenuItem extendedMenuItem : list) {
  2441.                                         entries[index][0] = extendedMenuItem.getLabel();
  2442.                                         entries[index][1] = extendedMenuItem.getUrl();
  2443.                                         index++;
  2444.                                     }
  2445.                                 }
  2446.                             }
  2447.                         }

  2448.                         me.setEntries(entries);
  2449.                         menu.add(me);
  2450.                     }

  2451.                 }

  2452.                 boolean showCodaMessaggi = pu.isCodeMessaggi() && this.core.showCodaMessage();
  2453.                
  2454.                 if (pu.isAuditing() || pu.isSistema() || showCodaMessaggi) {
  2455.                     MenuEntry me = new MenuEntry();
  2456.                     me.setTitle(CostantiControlStation.LABEL_STRUMENTI);

  2457.                     String[][] entries = null;
  2458.                     int size = 0;
  2459.                     if (pu.isAuditing()) {
  2460.                         size++;
  2461.                     }
  2462.                     if (pu.isSistema()) {
  2463.                         size++;
  2464.                     }
  2465.                     if (pu.isAuditing()) {
  2466.                         size++;
  2467.                     }

  2468.                     // Extended Menu
  2469.                     if(extendedMenu!=null){
  2470.                         for (IExtendedMenu extMenu : extendedMenu) {
  2471.                             List<ExtendedMenuItem> list =
  2472.                                     extMenu.getExtendedItemsMenuStrumenti(isModalitaAvanzata,
  2473.                                             this.core.isRegistroServiziLocale(), singlePdD, pu);
  2474.                             if(list!=null && list.size()>0){
  2475.                                 size +=list.size();
  2476.                             }
  2477.                         }
  2478.                     }

  2479.                     entries = new String[size][2];

  2480.                     int i = 0;

  2481.                     if (pu.isAuditing()) {
  2482.                         entries[i][0] = AuditCostanti.LABEL_AUDIT;
  2483.                         entries[i][1] = AuditCostanti.SERVLET_NAME_AUDITING;
  2484.                         i++;
  2485.                     }
  2486.                    
  2487.                     if (pu.isSistema()) {
  2488.                         entries[i][0] = OperazioniCostanti.LABEL_OPERAZIONI;
  2489.                         entries[i][1] = OperazioniCostanti.SERVLET_NAME_OPERAZIONI;
  2490.                         i++;
  2491.                     }
  2492.                     if (this.isModalitaAvanzata() && showCodaMessaggi) {
  2493.                         entries[i][0] = MonitorCostanti.LABEL_MONITOR;
  2494.                         entries[i][1] = MonitorCostanti.SERVLET_NAME_MONITOR;
  2495.                         i++;
  2496.                     }

  2497.                     // Extended Menu
  2498.                     if(extendedMenu!=null){
  2499.                         for (IExtendedMenu extMenu : extendedMenu) {
  2500.                             List<ExtendedMenuItem> list =
  2501.                                     extMenu.getExtendedItemsMenuStrumenti(isModalitaAvanzata,
  2502.                                             this.core.isRegistroServiziLocale(), singlePdD, pu);
  2503.                             if(list!=null){
  2504.                                 for (ExtendedMenuItem extendedMenuItem : list) {
  2505.                                     entries[i][0] = extendedMenuItem.getLabel();
  2506.                                     entries[i][1] = extendedMenuItem.getUrl();
  2507.                                     i++;
  2508.                                 }
  2509.                             }
  2510.                         }
  2511.                     }

  2512.                     me.setEntries(entries);
  2513.                     menu.add(me);
  2514.                 }
  2515.             }

  2516.             for (MenuEntry menuEntry : menu) {
  2517.                 String [][] entries = menuEntry.getEntries();
  2518.                 if(entries!=null && entries.length>0) {
  2519.                     for (int i = 0; i < entries.length; i++) {
  2520.                         String [] voce = entries[i];
  2521.                         if(voce[1]!=null && !"".equals(voce[1])) {
  2522.                             String newUrl = voce[1];
  2523.                             if(newUrl.contains("?")) {
  2524.                                 newUrl = newUrl + "&";
  2525.                             }
  2526.                             else {
  2527.                                 newUrl = newUrl + "?";
  2528.                             }
  2529.                             newUrl = newUrl + CostantiControlStation.PARAMETRO_RESET_SEARCH;
  2530.                             newUrl = newUrl + "=";
  2531.                             newUrl = newUrl + Costanti.CHECK_BOX_ENABLED;
  2532.                            
  2533.                            
  2534.                            
  2535.                             // aggiungo l'identificativo del tab
  2536.                             if(this.getTabId() != null) {
  2537.                                 newUrl = newUrl + "&";
  2538.                                 newUrl = newUrl + Costanti.PARAMETER_PREV_TAB_KEY;
  2539.                                 newUrl = newUrl + "=";
  2540.                                 newUrl = newUrl + this.getTabId();
  2541.                             }
  2542.                            
  2543.                             voce[1] = newUrl;
  2544.                         }
  2545.                     }
  2546.                 }
  2547.             }
  2548.            
  2549.            
  2550.             this.pd.setMenu(menu);
  2551.         } catch (Exception e) {
  2552.             this.logError("Exception: " + e.getMessage(), e);
  2553.             throw new DriverControlStationException(e);
  2554.         }
  2555.     }

  2556.     private String[][] getVoceMenuUtenti() {
  2557.         String[][] entries = new String[1][2];
  2558.         entries[0][0] = UtentiCostanti.LABEL_UTENTI;
  2559.         entries[0][1] = UtentiCostanti.SERVLET_NAME_UTENTI_LIST;
  2560.         return entries;
  2561.     }





  2562.     // *** Utilities generiche ***

  2563.     public void initializeFilter(ConsoleSearch ricerca) throws DriverControlStationException {
  2564.         initializeFilter(ricerca, Liste.SOGGETTI);
  2565.         initializeFilter(ricerca, Liste.SERVIZIO_APPLICATIVO);
  2566.         initializeFilter(ricerca, Liste.ACCORDI);
  2567.         initializeFilter(ricerca, Liste.ACCORDI_COOPERAZIONE);
  2568.         initializeFilter(ricerca, Liste.SERVIZI);
  2569.         initializeFilter(ricerca, Liste.PORTE_DELEGATE);
  2570.         initializeFilter(ricerca, Liste.PORTE_APPLICATIVE);
  2571.     }
  2572.     public void initializeFilter(ConsoleSearch ricerca, int idLista) throws DriverControlStationException {
  2573.         // Non devo inizializzare la lista degli utenti
  2574.         if(Liste.UTENTI_SERVIZI != idLista && Liste.UTENTI_SOGGETTI != idLista) {
  2575.             this.setFilterSelectedProtocol(ricerca, idLista);
  2576.         }
  2577.         this.setFilterRuoloServizioApplicativo(ricerca, idLista);
  2578.     }
  2579.    
  2580.     public ConsoleSearch checkSearchParameters(int idLista, ConsoleSearch ricerca)
  2581.             throws DriverControlStationException {
  2582.         try {
  2583.             int limit = ricerca.getPageSize(idLista);
  2584.             int offset = ricerca.getIndexIniziale(idLista);

  2585.             String search = ricerca.getSearchString(idLista);

  2586.             if (this.getParameter(Costanti.SEARCH_INDEX) != null) {
  2587.                 offset = Integer.parseInt(this.getParameter(Costanti.SEARCH_INDEX));
  2588.             }else {
  2589.                 offset = Costanti.INDEX_DEFAULT;
  2590.             }
  2591.             ricerca.setIndexIniziale(idLista, offset);
  2592.            
  2593.             if (this.getParameter(Costanti.SEARCH_PAGE_SIZE) != null) {
  2594.                 limit = Integer.parseInt(this.getParameter(Costanti.SEARCH_PAGE_SIZE));
  2595.             }else {
  2596.                 limit = Costanti.PAGE_SIZE_DEFAULT;
  2597.             }
  2598.             ricerca.setPageSize(idLista, limit);
  2599.            
  2600.             if (this.getParameter(Costanti.SEARCH) != null) {
  2601.                 search = this.getParameter(Costanti.SEARCH);
  2602.                 search = search.trim();
  2603.                 if (search.equals("")) {
  2604.                     ricerca.setSearchString(idLista, org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED);
  2605.                 } else {
  2606.                     ricerca.setSearchString(idLista, search);
  2607.                 }
  2608.             }
  2609.             else {
  2610.                 if(this.core.isConservaRisultatiRicerca()==false) {
  2611.                     ricerca.setSearchString(idLista, org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED);
  2612.                 }
  2613.             }
  2614.            
  2615.             int index=0;
  2616.             String nameFilter = PageData.GET_PARAMETRO_FILTER_NAME(index);
  2617.             if(this.core.isConservaRisultatiRicerca()==false) {
  2618.                 ricerca.clearFilters(idLista);
  2619.                 this.initializeFilter(ricerca,idLista);
  2620.             }
  2621.             while (this.getParameter(nameFilter) != null) {
  2622.                 String paramFilterName = this.getParameter(nameFilter);
  2623.                 paramFilterName = paramFilterName.trim();
  2624.                
  2625.                 String paramFilterValue = this.getParameter( PageData.GET_PARAMETRO_FILTER_VALUE(index));
  2626.                 if(paramFilterValue==null) {
  2627.                     paramFilterValue = "";
  2628.                 }
  2629.                 paramFilterValue = paramFilterValue.trim();
  2630.                 if (paramFilterValue.equals("")) {
  2631.                     paramFilterValue = org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_FILTER_UNDEFINED;
  2632.                 }
  2633.                
  2634.                 ricerca.addFilter(idLista, paramFilterName, paramFilterValue);
  2635.                
  2636.                 index++;
  2637.                 nameFilter = PageData.GET_PARAMETRO_FILTER_NAME(index);
  2638.             }

  2639.             return ricerca;
  2640.         } catch (Exception e) {
  2641.             this.logError("Exception: " + e.getMessage(), e);
  2642.             throw new DriverControlStationException(e);
  2643.         }
  2644.     }

  2645.     /**
  2646.      * Indica se si vogliono inviare le operazioni allo smistatore
  2647.      *
  2648.      * @return boolean
  2649.      */
  2650.     public boolean smista() throws DriverControlStationException {
  2651.         try {
  2652.             if(this.core.isUsedByApi()) {
  2653.                 return false;
  2654.             }
  2655.            
  2656.             boolean usaSmistatore = true;
  2657.             Boolean singlePdD = this.core.isSinglePdD();
  2658.             if (singlePdD)
  2659.                 usaSmistatore = false;
  2660.             return usaSmistatore;
  2661.         } catch (Exception e) {
  2662.             this.logError("Exception: " + e.getMessage(), e);
  2663.             throw new DriverControlStationException(e);
  2664.         }
  2665.     }

  2666.     public List<DataElement> addNomeValoreToDati( TipoOperazione tipoOp,List<DataElement> dati, String nome, String valore, boolean enableUpdate) {
  2667.         DataElement de = new DataElement();
  2668.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  2669.         de.setValue(nome);
  2670.         if (tipoOp.equals(TipoOperazione.ADD) || enableUpdate) {
  2671.             de.setType(DataElementType.TEXT_EDIT);
  2672.             de.setRequired(true);
  2673.         } else {
  2674.             de.setType(DataElementType.TEXT);
  2675.         }
  2676.         de.setName(CostantiControlStation.PARAMETRO_NOME);
  2677.         de.setSize(this.getSize());
  2678.         dati.add(de);

  2679.         de = new DataElement();
  2680.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_VALORE);
  2681.         de.setValue(valore);
  2682.         de.setType(DataElementType.TEXT_EDIT);
  2683.         de.setName(CostantiControlStation.PARAMETRO_VALORE);
  2684.         de.setSize(this.getSize());
  2685.         de.setRequired(true);
  2686.         dati.add(de);

  2687.         return dati;
  2688.     }
  2689.    
  2690.     public List<DataElement> addNomeValoreProprietaCifrataToDati( TipoOperazione tipoOp,List<DataElement> dati, String nome, String valore, boolean enableUpdate) throws UtilsException {
  2691.         DataElement de = new DataElement();
  2692.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  2693.         de.setValue(nome);
  2694.         if (tipoOp.equals(TipoOperazione.ADD) || enableUpdate) {
  2695.             de.setType(DataElementType.TEXT_EDIT);
  2696.             de.setRequired(true);
  2697.         } else {
  2698.             de.setType(DataElementType.TEXT);
  2699.         }
  2700.         de.setName(CostantiControlStation.PARAMETRO_NOME);
  2701.         de.setSize(this.getSize());
  2702.         dati.add(de);
  2703.        
  2704.         de = new DataElement();
  2705.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_VALORE);
  2706.         de.setName(CostantiControlStation.PARAMETRO_VALORE);
  2707.         de.setSize(this.getSize());
  2708.         this.core.getLockUtilities().lockProperty(de, valore);
  2709.         de.setRequired(true);
  2710.         dati.add(de);

  2711.         return dati;
  2712.     }
  2713.    
  2714.     public String wrapValoreProprieta(String valore) throws DriverControlStationException, UtilsException {
  2715.         return wrapValoreProprieta(CostantiControlStation.PARAMETRO_VALORE, valore);
  2716.     }
  2717.     public String wrapValoreProprieta(String nomeParametro, String valore) throws DriverControlStationException, UtilsException {
  2718.         if(valore!=null && StringUtils.isNotEmpty(valore) &&
  2719.             BYOKManager.isEnabledBYOK() &&
  2720.             nomeParametro.equals(this.getPostBackElementName())) {
  2721.             // è stata richiesta la cifratura
  2722.             return this.core.getDriverBYOKUtilities().wrap(valore);
  2723.         }
  2724.         return valore;
  2725.     }
  2726.        
  2727.     public List<DataElement> addHiddenFieldsToDati(TipoOperazione tipoOp, String id, String idsogg, String idPorta,
  2728.             List<DataElement> dati) {
  2729.         return addHiddenFieldsToDati(tipoOp, id, idsogg, idPorta, null, dati);
  2730.     }
  2731.    
  2732.     public List<DataElement> addHiddenFieldsToDati(TipoOperazione tipoOp, String id, String idsogg, String idPorta, String idAsps,
  2733.             List<DataElement> dati) {
  2734.         return addHiddenFieldsToDati(tipoOp, id, idsogg, idPorta, idAsps, null, null, null, dati);
  2735.     }

  2736.     public List<DataElement> addHiddenFieldsToDati(TipoOperazione tipoOp, String id, String idsogg, String idPorta, String idAsps,
  2737.             String idFruizione, String tipoSoggettoFruitore, String nomeSoggettoFruitore,
  2738.             List<DataElement> dati) {

  2739.         DataElement de = new DataElement();
  2740.         if(id!= null){
  2741.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID);
  2742.             de.setValue(id);
  2743.             de.setType(DataElementType.HIDDEN);
  2744.             de.setName(CostantiControlStation.PARAMETRO_ID);
  2745.             dati.add(de);
  2746.         }
  2747.         if(idsogg != null){
  2748.             de = new DataElement();
  2749.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_SOGGETTO);
  2750.             de.setValue(idsogg);
  2751.             de.setType(DataElementType.HIDDEN);
  2752.             de.setName(CostantiControlStation.PARAMETRO_ID_SOGGETTO);
  2753.             dati.add(de);
  2754.         }
  2755.         if(idPorta != null){
  2756.             de = new DataElement();
  2757.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_PORTA);
  2758.             de.setValue(idPorta);
  2759.             de.setType(DataElementType.HIDDEN);
  2760.             de.setName(CostantiControlStation.PARAMETRO_ID_PORTA);
  2761.             dati.add(de);
  2762.         }
  2763.        
  2764.         if(idAsps != null){
  2765.             de = new DataElement();
  2766.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_ASPS);
  2767.             de.setValue(idAsps);
  2768.             de.setType(DataElementType.HIDDEN);
  2769.             de.setName(CostantiControlStation.PARAMETRO_ID_ASPS);
  2770.             dati.add(de);
  2771.         }
  2772.        
  2773.         if(idFruizione != null){
  2774.             de = new DataElement();
  2775.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_FRUIZIONE);
  2776.             de.setValue(idFruizione);
  2777.             de.setType(DataElementType.HIDDEN);
  2778.             de.setName(CostantiControlStation.PARAMETRO_ID_FRUIZIONE);
  2779.             dati.add(de);
  2780.         }
  2781.        
  2782.         if(tipoSoggettoFruitore != null){
  2783.             de = new DataElement();
  2784.             de.setValue(tipoSoggettoFruitore);
  2785.             de.setType(DataElementType.HIDDEN);
  2786.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE);
  2787.             dati.add(de);
  2788.         }
  2789.        
  2790.         if(nomeSoggettoFruitore != null){
  2791.             de = new DataElement();
  2792.             de.setValue(nomeSoggettoFruitore);
  2793.             de.setType(DataElementType.HIDDEN);
  2794.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE);
  2795.             dati.add(de);
  2796.         }

  2797.         return dati;
  2798.     }

  2799.     // *** Utilities per i nomi ***
  2800.    
  2801.     // In effetti iniziare con un '.' o un '-' e' brutto, per adesso si elimina questa possibilita
  2802. //  public boolean checkName(String name, String object) throws DriverControlStationException{
  2803. //      // Il nome deve contenere solo lettere e numeri e '_' '-' '.'
  2804. //      if (!RegularExpressionEngine.isMatch(name,"^[0-9A-Za-z_\\-\\.]+$")) {
  2805. //          this.pd.setMessage("Il campo '"+object+"' deve essere formato solo da caratteri, cifre, '_' , '-' e '.'");
  2806. //          return false;
  2807. //      }
  2808. //      return true;
  2809. //  }  

  2810.     public boolean checkNCName(String name, String object) throws DriverControlStationException{
  2811.         // Il nome deve contenere solo lettere e numeri e '_' '-' '.'
  2812.         try {
  2813.             if (!RegularExpressionEngine.isMatch(name,"^[_A-Za-z][\\-\\._A-Za-z0-9]*$")) {
  2814.                 this.pd.setMessage("Il campo '"+object+"' può iniziare solo con un carattere [A-Za-z] o il simbolo '_' e dev'essere formato solo da caratteri, cifre, '_' , '-' e '.'");
  2815.                 return false;
  2816.             }
  2817.         }catch(Exception e) {
  2818.             throw new DriverControlStationException(e.getMessage(),e);
  2819.         }
  2820.         return true;
  2821.     }
  2822.    
  2823.     public boolean checkNCNameAndSerial(String name, String object) throws DriverControlStationException{
  2824.         // Il nome deve contenere solo lettere e numeri e '_' '-' '.'
  2825.         try {
  2826.             if (!RegularExpressionEngine.isMatch(name,"^[_A-Za-z][\\-\\._A-Za-z0-9]*@[0-9]*$")) {
  2827.                 this.pd.setMessage("Il campo '"+object+"' può iniziare solo con un carattere [A-Za-z] o il simbolo '_' e dev'essere formato solo da caratteri, cifre, '_' , '-' e '.', infine deve terminare con @ e numeri interi");
  2828.                 return false;
  2829.             }
  2830.         }catch(Exception e) {
  2831.             throw new DriverControlStationException(e.getMessage(),e);
  2832.         }
  2833.         return true;
  2834.     }
  2835.    
  2836.     public boolean checkSimpleNamePath(String name, String object) throws DriverControlStationException{
  2837.         // Il nome può iniziare solo con un carattere o cifra [0-9A-Za-z] e dev'essere formato solo da caratteri, cifre e '-'
  2838.         try {
  2839.             if (!RegularExpressionEngine.isMatch(name,"^[0-9A-Za-z][\\-A-Za-z0-9]*$")) {
  2840.                 this.pd.setMessage("Il campo '"+object+"' può iniziare solo con un carattere o cifra [0-9A-Za-z] e dev'essere formato solo da caratteri, cifre e '-'");
  2841.                 return false;
  2842.             }
  2843.         }catch(Exception e) {
  2844.             throw new DriverControlStationException(e.getMessage(),e);
  2845.         }
  2846.         return true;
  2847.     }
  2848.    
  2849.     public boolean checkSimpleName(String name, String object) throws DriverControlStationException{
  2850.         try {
  2851.             if (!RegularExpressionEngine.isMatch(name,"^[0-9A-Za-z]+$")) {
  2852.                 this.pd.setMessage("Il campo '"+object+"' deve essere formato solo da caratteri e cifre");
  2853.                 return false;
  2854.             }  
  2855.         }catch(Exception e) {
  2856.             throw new DriverControlStationException(e.getMessage(),e);
  2857.         }
  2858.         return true;
  2859.     }
  2860.    
  2861.     public boolean checkIntegrationEntityName(String name, String object) throws DriverControlStationException{
  2862.         // Il nome deve contenere solo lettere e numeri e '_' '-' '.' '/'
  2863.         try {
  2864.             if (!RegularExpressionEngine.isMatch(name,"^[_A-Za-z][\\-\\._/A-Za-z0-9]*$")) {
  2865.                 this.pd.setMessage("Il campo '"+object+"' può iniziare solo con un carattere [A-Za-z] o il simbolo '_' e dev'essere formato solo da caratteri, cifre, '_' , '-', '.' e '/'");
  2866.                 return false;
  2867.             }
  2868.         }catch(Exception e) {
  2869.             throw new DriverControlStationException(e.getMessage(),e);
  2870.         }
  2871.         return true;
  2872.     }
  2873.    
  2874.    
  2875.     public boolean checkNumber(String value, String object, boolean permitZeroAsValue) throws DriverControlStationException{
  2876.         if(permitZeroAsValue){
  2877.             try {
  2878.                 if (!RegularExpressionEngine.isMatch(value,"^[0-9]+$")) {
  2879.                     this.pd.setMessage("Il campo '"+object+"' deve essere formato solo da cifre");
  2880.                     return false;
  2881.                 }  
  2882.             }catch(Exception e) {
  2883.                 throw new DriverControlStationException(e.getMessage(),e);
  2884.             }
  2885.         }
  2886.         else{
  2887.             try {
  2888.                 if (!RegularExpressionEngine.isMatch(value,"^[1-9]+[0-9]*$")) {
  2889.                     if(value.charAt(0) == '0' && value.length()>1){
  2890.                         this.pd.setMessage("Il campo '"+object+"' deve contenere un numero intero maggiore di zero e non deve iniziare con la cifra '0'");
  2891.                     }else{
  2892.                         this.pd.setMessage("Il campo '"+object+"' deve contenere un numero intero maggiore di zero");
  2893.                     }
  2894.                     return false;
  2895.                 }
  2896.             }catch(Exception e) {
  2897.                 throw new DriverControlStationException(e.getMessage(),e);
  2898.             }
  2899.         }
  2900.         return true;
  2901.     }
  2902.    
  2903.     public boolean checkLength4000(String value, String object) throws DriverControlStationException{
  2904.         return this.checkLength(value, object, -1, 4000);
  2905.     }
  2906.     public boolean checkLength255(String value, String object) throws DriverControlStationException{
  2907.         return this.checkLength(value, object, -1, 255);
  2908.     }
  2909.     public boolean checkLengthSubject_SSL_Principal(String value, String object) throws DriverControlStationException{
  2910.         return this.checkLength(value, object, -1, 2800);
  2911.     }
  2912.     public boolean checkLength(String value, String object, int minLength, int maxLength) throws DriverControlStationException{
  2913.         if(minLength>0) {
  2914.             if(value==null || value.length()<minLength) {
  2915.                 this.pd.setMessage("L'informazione fornita nel campo '"+object+"' deve possedere una lunghezza maggiore di "+(minLength-1));
  2916.                 return false;
  2917.             }
  2918.         }
  2919.         if(maxLength>0) {
  2920.             if(value!=null && value.length()>maxLength) {
  2921.                 this.pd.setMessage("L'informazione fornita nel campo '"+object+"' deve possedere una lunghezza minore di "+maxLength);
  2922.                 return false;
  2923.             }
  2924.         }
  2925.         return true;
  2926.     }
  2927.    
  2928.     public boolean checkSpazi(String value, String object) throws DriverControlStationException{
  2929.         if(value.contains(" ")) {
  2930.             this.pd.setMessage("L'informazione fornita nel campo '"+object+"' non deve contenere spazi");
  2931.             return false;
  2932.         }
  2933.         return true;
  2934.     }

  2935.     public boolean checkEmail(String email, String object) throws DriverControlStationException{
  2936.         // Email deve rispettare il pattern
  2937.         try {
  2938.             if (!RegularExpressionEngine.isMatch(email,CostantiControlStation.EMAIL_PATTERN)) {
  2939.                 this.pd.setMessage("Il campo '"+object+"' non contiene un indirizzo e-mail valido");
  2940.                 return false;
  2941.             }
  2942.         }catch(Exception e) {
  2943.             throw new DriverControlStationException(e.getMessage(),e);
  2944.         }
  2945.         return true;
  2946.     }
  2947.    
  2948.     public boolean checkRegexp(String pattern, String object) throws DriverControlStationException{
  2949.         try {
  2950.             RegularExpressionEngine.validate(pattern);
  2951.         }catch(Exception e) {
  2952.             this.pd.setMessage("Il campo '"+object+"' non contiene un'espressione regolare valida: "+e.getMessage());
  2953.             return false;
  2954.         }
  2955.         return true;
  2956.     }
  2957.    
  2958.     public boolean checkXPath(String pattern, String object) throws DriverControlStationException{
  2959.         try {
  2960.             AbstractXPathExpressionEngine engine = new XPathExpressionEngine();
  2961.             engine.validate(pattern);
  2962.         }catch(Exception e) {
  2963.             this.pd.setMessage("Il campo '"+object+"' non contiene un'espressione xpath valida: "+e.getMessage());
  2964.             return false;
  2965.         }
  2966.         return true;
  2967.     }
  2968.     public boolean checkJsonPath(String pattern, String object) throws DriverControlStationException{
  2969.         try {
  2970.             JsonXmlPathExpressionEngine.validate(pattern, this.log); // per poter validare anche la funzionalità 'Espressioni XPath su messaggi JSON'
  2971.         }catch(Exception e) {
  2972.             this.pd.setMessage("Il campo '"+object+"' non contiene un'espressione json-path valida: "+e.getMessage());
  2973.             return false;
  2974.         }
  2975.         return true;
  2976.     }
  2977.     public boolean checkXPathOrJsonPath(String pattern, String object) throws DriverControlStationException{
  2978.         StringBuilder sb = new StringBuilder();
  2979.         try {
  2980.             AbstractXPathExpressionEngine engine = new XPathExpressionEngine();
  2981.             engine.validate(pattern);
  2982.             return true;
  2983.         }catch(Exception e) {
  2984.             if(sb.length()>0) {
  2985.                 sb.append("<BR/>");
  2986.                 sb.append("<BR/>");
  2987.             }
  2988.             sb.append("XPath: "+e.getMessage());
  2989.         }
  2990.         try {
  2991.             JsonXmlPathExpressionEngine.validate(pattern, this.log); // per poter validare anche la funzionalità 'Espressioni XPath su messaggi JSON'
  2992.             return true;
  2993.         }catch(Exception e) {
  2994.             if(sb.length()>0) {
  2995.                 sb.append("<BR/>");
  2996.                 sb.append("<BR/>");
  2997.             }
  2998.             sb.append("JsonPath: "+e.getMessage());
  2999.         }
  3000.         if(sb.length()>0) {
  3001.             this.pd.setMessage("Il campo '"+object+"' contiene un'espressione non validabile né come XPath né come JsonPath:"+"<BR/><BR/>"+sb.toString());
  3002.             return false;
  3003.         }
  3004.         return true;
  3005.     }
  3006.    
  3007.    
  3008.     // *** Utilities condivise tra Porte Delegate e Porte Applicative ***
  3009.    
  3010.     public List<DataElement> addPorteServizioApplicativoToDati(TipoOperazione tipoOp, List<DataElement> dati,
  3011.             String servizioApplicativo, String[] servizioApplicativoList, int sizeAttuale,
  3012.             boolean addMsgServiziApplicativoNonDisponibili, boolean addTitle,
  3013.             boolean isToken) {
  3014.        
  3015.         if(isToken) {
  3016.             DataElement de = new DataElement();
  3017.             de.setType(DataElementType.HIDDEN);
  3018.             de.setName(CostantiControlStation.PARAMETRO_TOKEN_AUTHORIZATION);
  3019.             de.setValue("true");
  3020.             dati.add(de);
  3021.         }
  3022.        
  3023.         if(servizioApplicativoList!=null && servizioApplicativoList.length>0){
  3024.        
  3025.             String labelApplicativo = CostantiControlStation.LABEL_PARAMETRO_SERVIZIO_APPLICATIVO;
  3026.             if(!this.isModalitaCompleta()) {
  3027.                 labelApplicativo = CostantiControlStation.LABEL_PARAMETRO_APPLICATIVO;
  3028.             }
  3029.            
  3030.             if(addTitle) {
  3031.                 DataElement de = new DataElement();
  3032.                 de.setType(DataElementType.TITLE);
  3033.                 de.setLabel(labelApplicativo);
  3034.                 dati.add(de);
  3035.             }
  3036.            
  3037.             DataElement de = new DataElement();
  3038.             de.setLabel( CostantiControlStation.LABEL_PARAMETRO_NOME );
  3039.             de.setType(DataElementType.SELECT);
  3040.             de.setName(CostantiControlStation.PARAMETRO_SERVIZIO_APPLICATIVO);
  3041.             de.setValues(servizioApplicativoList);
  3042.             de.setSelected(servizioApplicativo);
  3043.             dati.add(de);
  3044.            
  3045.         }else{
  3046.             if(addMsgServiziApplicativoNonDisponibili){
  3047.                 if(sizeAttuale>0){
  3048.                     this.pd.setMessage("Non esistono ulteriori servizi applicativi associabili alla porta",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  3049.                 }
  3050.                 else{
  3051.                     this.pd.setMessage("Non esistono servizi applicativi associabili alla porta",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  3052.                 }
  3053.                 this.pd.disableEditMode();
  3054.             }
  3055.         }

  3056.         return dati;
  3057.     }
  3058.    
  3059.     public List<DataElement> addPorteSoggettoToDati(TipoOperazione tipoOp, List<DataElement> dati,
  3060.             String[] soggettiLabelList, String[] soggettiList, String soggetto, int sizeAttuale,
  3061.                 boolean addMsgSoggettiNonDisponibili, boolean addTitle) {
  3062.            
  3063.             if(soggettiList!=null && soggettiList.length>0){
  3064.            
  3065.                 if(addTitle) {
  3066.                     DataElement de = new DataElement();
  3067.                     de.setType(DataElementType.TITLE);
  3068.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_SOGGETTO);
  3069.                     dati.add(de);
  3070.                 }
  3071.                
  3072.                 DataElement de = new DataElement();
  3073.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  3074.                 de.setType(DataElementType.SELECT);
  3075.                 de.setName(CostantiControlStation.PARAMETRO_SOGGETTO);
  3076.                 de.setLabels(soggettiLabelList);
  3077.                 de.setValues(soggettiList);
  3078.                 de.setSelected(soggetto);
  3079.                 dati.add(de);
  3080.                
  3081.             }else{
  3082.                 if(addMsgSoggettiNonDisponibili){
  3083.                     if(sizeAttuale>0){
  3084.                         this.pd.setMessage("Non esistono ulteriori soggetti associabili",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  3085.                     }
  3086.                     else{
  3087.                         this.pd.setMessage("Non esistono soggetti associabili",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  3088.                     }
  3089.                     this.pd.disableEditMode();
  3090.                 }
  3091.             }

  3092.             return dati;
  3093.         }

  3094.     public List<DataElement> addPorteServizioApplicativoAutorizzatiToDati(TipoOperazione tipoOp, List<DataElement> dati,
  3095.             String[] soggettiLabelList, String[] soggettiList, String soggetto, int sizeAttuale,
  3096.             Map<String,List<IDServizioApplicativoDB>> listServiziApplicativi, String sa,
  3097.             boolean addMsgApplicativiNonDisponibili, boolean showTitle, boolean isAutorizzazioneModi,
  3098.             boolean isSupportatoAutenticazioneApplicativiEsterni,
  3099.             boolean isToken) {
  3100.            
  3101.         if(isAutorizzazioneModi) {
  3102.             DataElement de = new DataElement();
  3103.             de.setType(DataElementType.HIDDEN);
  3104.             de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_MODIPA);
  3105.             de.setValue("true");
  3106.             dati.add(de);
  3107.         }
  3108.        
  3109.         if(isToken) {
  3110.             DataElement de = new DataElement();
  3111.             de.setType(DataElementType.HIDDEN);
  3112.             de.setName(CostantiControlStation.PARAMETRO_TOKEN_AUTHORIZATION);
  3113.             de.setValue("true");
  3114.             dati.add(de);
  3115.         }
  3116.        
  3117.         if(soggettiList!=null && soggettiList.length>0 && listServiziApplicativi!=null && listServiziApplicativi.size()>0){
  3118.        
  3119.             if(showTitle) {
  3120.                 DataElement de = new DataElement();
  3121.                 de.setType(DataElementType.TITLE);
  3122.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_APPLICATIVO);
  3123.                 dati.add(de);
  3124.             }
  3125.            
  3126.             DataElement de = new DataElement();
  3127.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_SOGGETTO);
  3128.             de.setName(CostantiControlStation.PARAMETRO_SOGGETTO);
  3129.             de.setValue(soggetto);
  3130.             if(this.core.isMultitenant() || isSupportatoAutenticazioneApplicativiEsterni) {
  3131.                 de.setType(DataElementType.SELECT);
  3132.                 de.setLabels(soggettiLabelList);
  3133.                 de.setValues(soggettiList);
  3134.                 de.setSelected(soggetto);
  3135.                 de.setPostBack(true);
  3136.             }
  3137.             else {
  3138.                 de.setType(DataElementType.HIDDEN);
  3139.             }
  3140.             dati.add(de);
  3141.            
  3142.             List<IDServizioApplicativoDB> listSA = null;
  3143.             if(soggetto!=null && !"".equals(soggetto)) {
  3144.                 listSA = listServiziApplicativi.get(soggetto);
  3145.             }
  3146.            
  3147.             if(listSA!=null && !listSA.isEmpty()) {
  3148.                
  3149.                 String [] saValues = new String[listSA.size()];
  3150.                 String [] saLabels = new String[listSA.size()];
  3151.                 int index =0;
  3152.                 for (IDServizioApplicativoDB saObject : listSA) {
  3153.                     saValues[index] = saObject.getId().longValue()+"";
  3154.                     saLabels[index] = saObject.getNome();
  3155.                     index++;
  3156.                 }
  3157.                
  3158.                 de = new DataElement();
  3159.                 if(showTitle) {
  3160.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  3161.                 }
  3162.                 else {
  3163.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_APPLICATIVO);
  3164.                 }
  3165.                 de.setType(DataElementType.SELECT);
  3166.                 de.setName(CostantiControlStation.PARAMETRO_SERVIZIO_APPLICATIVO_AUTORIZZATO);
  3167.                 de.setLabels(saLabels);
  3168.                 de.setValues(saValues);
  3169.                 de.setSelected(sa);
  3170.                 dati.add(de);
  3171.                
  3172.             }
  3173.             else {
  3174.                 this.pd.setMessage("Non esistono applicativi associabili per il soggetto selezionato",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  3175.                 this.pd.disableEditMode();
  3176.             }
  3177.            
  3178.         }else{
  3179.             if(addMsgApplicativiNonDisponibili){
  3180.                 if(sizeAttuale>0){
  3181.                     this.pd.setMessage("Non esistono ulteriori applicativi associabili",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  3182.                 }
  3183.                 else{
  3184.                     this.pd.setMessage("Non esistono applicativi associabili",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  3185.                 }
  3186.                 this.pd.disableEditMode();
  3187.             }
  3188.         }

  3189.         return dati;
  3190.     }

  3191.    
  3192.     // Controlla i dati del Message-Security
  3193.     public boolean WSCheckData(TipoOperazione tipoOp) throws DriverControlStationException {
  3194.         try{
  3195.             String messageSecurity = this.getParameter(CostantiControlStation.PARAMETRO_MESSAGE_SECURITY);

  3196.             // Controllo che i campi "select" abbiano uno dei valori ammessi
  3197.             if (!messageSecurity.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_SECURITY_ABILITATO) &&
  3198.                     !messageSecurity.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_SECURITY_DISABILITATO)) {
  3199.                 this.pd.setMessage("Stato dev'essere abilitato o disabilitato");
  3200.                 return false;
  3201.             }
  3202.            
  3203.             if (messageSecurity.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_SECURITY_ABILITATO)){
  3204.                 String req = this.getParameter(CostantiControlStation.PARAMETRO_REQUEST_FLOW_PROPERTIES_CONFIG_NAME);
  3205.                 String res = this.getParameter(CostantiControlStation.PARAMETRO_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME);
  3206.                 if(
  3207.                         (req==null || "".equals(req) || CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(req))
  3208.                         &&
  3209.                         (res==null || "".equals(res) || CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(res))
  3210.                         ) {
  3211.                     this.pd.setMessage("Almeno uno schema di sicurezza per la richiesta o per la risposta dev'essere abilitato");
  3212.                     return false;
  3213.                 }
  3214.             }
  3215.            
  3216.             return true;
  3217.         } catch (Exception e) {
  3218.             this.logError("Exception: " + e.getMessage(), e);
  3219.             throw new DriverControlStationException(e);
  3220.         }
  3221.     }

  3222.     public List<DataElement> addMessageSecurityToDati(List<DataElement> dati,boolean delegata,long idPorta,
  3223.                 String messageSecurity, String url1, String url2, Boolean contaListe, int numWSreq, int numWSres, boolean showApplicaMTOMReq, String applicaMTOMReq,
  3224.                 boolean showApplicaMTOMRes, String applicaMTOMRes,String idPropConfigReq, String idPropConfigRes,
  3225.                 String[] propConfigReqLabelList, String[] propConfigReqList, String[] propConfigResLabelList, String[] propConfigResList,String oldIdPropConfigReq, String oldIdPropConfigRes) {


  3226.         DataElement de = new DataElement();
  3227.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_MESSAGE_SECURITY);
  3228.         de.setType(DataElementType.TITLE);
  3229.         dati.add(de);
  3230.        
  3231.        
  3232.         de = new DataElement();
  3233.         String[] tipoWS = {
  3234.                 CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_SECURITY_ABILITATO,
  3235.                 CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_SECURITY_DISABILITATO
  3236.         };

  3237.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_STATO);
  3238.         de.setType(DataElementType.SELECT);
  3239.         de.setName(CostantiControlStation.PARAMETRO_MESSAGE_SECURITY);
  3240.         de.setValues(tipoWS);
  3241.         de.setSelected(messageSecurity);
  3242.         de.setPostBack(true);
  3243.         dati.add(de);

  3244.         if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_SECURITY_ABILITATO.equals(messageSecurity)){
  3245.             //          de = new DataElement();
  3246.             //          de.setLabel(CostantiControlStation.LABEL_PARAMETRO_MESSAGE_SECURITY);
  3247.             //          de.setType(DataElementType.TITLE);
  3248.             //          dati.add(de);

  3249.             // Sezione Richiesta
  3250.             de = new DataElement();
  3251.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RICHIESTA);
  3252.             de.setType(DataElementType.TITLE);
  3253.             dati.add(de);

  3254.             // Applica MTOM Richiesta
  3255.             de = new DataElement();
  3256.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_APPLICA_MTOM);
  3257.             if(showApplicaMTOMReq){
  3258.                 de.setType(DataElementType.CHECKBOX);
  3259.                 if( ServletUtils.isCheckBoxEnabled(applicaMTOMReq) || CostantiRegistroServizi.ABILITATO.equals(applicaMTOMReq) ){
  3260.                     de.setSelected(true);
  3261.                 }
  3262.             } else {
  3263.                 de.setType(DataElementType.HIDDEN);
  3264.                 de.setValue(applicaMTOMReq);
  3265.             }
  3266.             de.setName(CostantiControlStation.PARAMETRO_APPLICA_MTOM_RICHIESTA);
  3267.             dati.add(de);
  3268.            
  3269.             de = new DataElement();
  3270.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_REQUEST_FLOW_PROPERTIES_CONFIG_NAME);
  3271.             de.setName(CostantiControlStation.PARAMETRO_REQUEST_FLOW_PROPERTIES_CONFIG_NAME);
  3272.             if(propConfigReqList.length > 1){
  3273.                 de.setType(DataElementType.SELECT);
  3274.                 de.setLabels(propConfigReqLabelList);
  3275.                 de.setValues(propConfigReqList);
  3276.                 de.setSelected(idPropConfigReq);
  3277.                 de.setPostBack(true);
  3278.             }else{
  3279.                 de.setType(DataElementType.HIDDEN);
  3280.                 de.setValue(idPropConfigReq);
  3281.             }
  3282.             dati.add(de);

  3283.             if(idPropConfigReq.equals(oldIdPropConfigReq) && !idPropConfigReq.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO)) { // finche' non applico la modifica questi due valori saranno diversi
  3284.                 de = new DataElement();
  3285.                 de.setType(DataElementType.LINK);
  3286.                 de.setUrl(url1);
  3287.                 if(idPropConfigReq.equals(CostantiControlStation.VALUE_PARAMETRO_PROPERTIES_MODE_DEFAULT)) {
  3288.                     if (contaListe)
  3289.                         de.setValue(CostantiControlStation.LABEL_PARAMETRO_PARAMETRI+"(" + numWSreq + ")");
  3290.                     else
  3291.                         de.setValue(CostantiControlStation.LABEL_PARAMETRO_PARAMETRI);
  3292.                 } else {
  3293.                     if(numWSreq<=0) {
  3294.                         boolean editModeInProgress = true;
  3295.                         try {
  3296.                             editModeInProgress = this.isEditModeInProgress();
  3297.                         }catch(Exception e) {
  3298.                             // ignore
  3299.                         }
  3300.                         if(!editModeInProgress) {
  3301.                             de.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_PROPERTIES_PROCEDI);
  3302.                         }
  3303.                         else {
  3304.                            
  3305.                             DataElement note = new DataElement();
  3306.                             note.setBold(true);
  3307.                             note.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_INCOMPLETA_LABEL);
  3308.                             note.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_INCOMPLETA);
  3309.                             note.setType(DataElementType.NOTE);
  3310.                             dati.add(note);
  3311.                            
  3312.                             de.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_PROPERTIES_COMPLETA);
  3313.                         }
  3314.                     }
  3315.                     else {
  3316.                         // Se cambia l'xml potrebbe succedere
  3317.                         boolean valida = false;
  3318.                         try {
  3319.                             PropertiesSourceConfiguration propertiesSourceConfiguration = this.core.getMessageSecurityPropertiesSourceConfiguration();
  3320.                             ConfigManager configManager = ConfigManager.getinstance(ControlStationCore.getLog());
  3321.                             Config configurazione = configManager.getConfigurazione(propertiesSourceConfiguration, idPropConfigReq);
  3322.                             Map<String, Properties> mappaDB = null;
  3323.                             if(delegata) {
  3324.                                 mappaDB = this.porteDelegateCore.readMessageSecurityRequestPropertiesConfiguration(idPorta);
  3325.                             }
  3326.                             else {
  3327.                                 mappaDB = this.porteApplicativeCore.readMessageSecurityRequestPropertiesConfiguration(idPorta);
  3328.                             }
  3329.                             ConfigBean configurazioneBean = this.porteApplicativeCore.leggiConfigurazione(configurazione, mappaDB);
  3330.                             valida = this.checkPropertiesConfigurationData(TipoOperazione.OTHER, configurazioneBean, null, null, configurazione);
  3331.                         }catch(Exception e) {
  3332.                             this.logError(e.getMessage(),e);
  3333.                         }
  3334.                         if(valida) {
  3335.                             de.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_PROPERTIES);
  3336.                         }
  3337.                         else {
  3338.                             de.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_PROPERTIES_COMPLETA);
  3339.                         }
  3340.                     }
  3341.                 }
  3342.                 dati.add(de);
  3343.             }

  3344.             // Sezione Risposta
  3345.             de = new DataElement();
  3346.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RISPOSTA);
  3347.             de.setType(DataElementType.TITLE);
  3348.             dati.add(de);

  3349.             // Applica MTOM Risposta
  3350.             de = new DataElement();
  3351.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_APPLICA_MTOM);
  3352.             if(showApplicaMTOMRes){
  3353.                 de.setType(DataElementType.CHECKBOX);
  3354.                 if( ServletUtils.isCheckBoxEnabled(applicaMTOMRes) || CostantiRegistroServizi.ABILITATO.equals(applicaMTOMRes) ){
  3355.                     de.setSelected(true);
  3356.                 }
  3357.             } else {
  3358.                 de.setType(DataElementType.HIDDEN);
  3359.                 de.setValue(applicaMTOMRes);
  3360.             }
  3361.             de.setName(CostantiControlStation.PARAMETRO_APPLICA_MTOM_RISPOSTA);
  3362.             dati.add(de);
  3363.            
  3364.             de = new DataElement();
  3365.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME);
  3366.             de.setName(CostantiControlStation.PARAMETRO_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME);
  3367.             if(propConfigResList.length > 1){
  3368.                 de.setType(DataElementType.SELECT);
  3369.                 de.setLabels(propConfigResLabelList);
  3370.                 de.setValues(propConfigResList);
  3371.                 de.setSelected(idPropConfigRes);
  3372.                 de.setPostBack(true);
  3373.             }else{
  3374.                 de.setType(DataElementType.HIDDEN);
  3375.                 de.setValue(idPropConfigReq);
  3376.             }
  3377.             dati.add(de);

  3378.             if(idPropConfigRes.equals(oldIdPropConfigRes) && !idPropConfigRes.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO)) { // finche' non applico la modifica questi due valori saranno diversi
  3379.                 de = new DataElement();
  3380.                 de.setType(DataElementType.LINK);
  3381.                 de.setUrl(url2);
  3382.                 if(idPropConfigRes.equals(CostantiControlStation.VALUE_PARAMETRO_PROPERTIES_MODE_DEFAULT)) {
  3383.                     if (contaListe)
  3384.                         de.setValue(CostantiControlStation.LABEL_PARAMETRO_PARAMETRI+"(" + numWSres + ")");
  3385.                     else
  3386.                         de.setValue(CostantiControlStation.LABEL_PARAMETRO_PARAMETRI);
  3387.                 } else {
  3388.                     if(numWSres<=0) {
  3389.                         boolean editModeInProgress = true;
  3390.                         try {
  3391.                             editModeInProgress = this.isEditModeInProgress();
  3392.                         }catch(Exception e) {
  3393.                             // ignore
  3394.                         }
  3395.                         if(!editModeInProgress) {
  3396.                             de.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_PROPERTIES_PROCEDI);
  3397.                         }
  3398.                         else {
  3399.                            
  3400.                             DataElement note = new DataElement();
  3401.                             note.setBold(true);
  3402.                             note.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_INCOMPLETA_LABEL);
  3403.                             note.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_INCOMPLETA);
  3404.                             note.setType(DataElementType.NOTE);
  3405.                             dati.add(note);
  3406.                            
  3407.                             de.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_PROPERTIES_COMPLETA);
  3408.                         }
  3409.                     }
  3410.                     else {
  3411.                         // Se cambia l'xml potrebbe succedere
  3412.                         boolean valida = false;
  3413.                         try {
  3414.                             PropertiesSourceConfiguration propertiesSourceConfiguration = this.core.getMessageSecurityPropertiesSourceConfiguration();
  3415.                             ConfigManager configManager = ConfigManager.getinstance(ControlStationCore.getLog());
  3416.                             Config configurazione = configManager.getConfigurazione(propertiesSourceConfiguration, idPropConfigRes);
  3417.                             Map<String, Properties> mappaDB = null;
  3418.                             if(delegata) {
  3419.                                 mappaDB = this.porteDelegateCore.readMessageSecurityResponsePropertiesConfiguration(idPorta);
  3420.                             }
  3421.                             else {
  3422.                                 mappaDB = this.porteApplicativeCore.readMessageSecurityResponsePropertiesConfiguration(idPorta);
  3423.                             }
  3424.                             ConfigBean configurazioneBean = this.porteApplicativeCore.leggiConfigurazione(configurazione, mappaDB);
  3425.                             valida = this.checkPropertiesConfigurationData(TipoOperazione.OTHER, configurazioneBean, null, null, configurazione);
  3426.                         }catch(Exception e) {
  3427.                             this.logError(e.getMessage(),e);
  3428.                         }
  3429.                         if(valida) {
  3430.                             de.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_PROPERTIES);
  3431.                         }
  3432.                         else {
  3433.                             de.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_PROPERTIES_COMPLETA);
  3434.                         }
  3435.                     }
  3436.                 }
  3437.                 dati.add(de);
  3438.             }
  3439.         }

  3440.         dati = addParameterApplicaModifica(dati);
  3441.        
  3442.         return dati;
  3443.     }

  3444.     public List<DataElement> addMTOMToDati(List<DataElement> dati, String[] modeMtomListReq,String[] modeMtomListRes,
  3445.             String mtomRichiesta,String mtomRisposta, String url1, String url2, Boolean contaListe, int numMTOMreq, int numMTOMres) {

  3446.         DataElement de = new DataElement();

  3447.         // Sezione Richiesta
  3448.         de = new DataElement();
  3449.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RICHIESTA);
  3450.         de.setType(DataElementType.TITLE);
  3451.         dati.add(de);

  3452.         // Stato
  3453.         de = new DataElement();
  3454.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_STATO);
  3455.         de.setType(DataElementType.SELECT);
  3456.         de.setName(CostantiControlStation.PARAMETRO_MTOM_RICHIESTA);
  3457.         de.setValues(modeMtomListReq);
  3458.         de.setSelected(mtomRichiesta);
  3459.         de.setSize(this.getSize());
  3460.         dati.add(de);

  3461.         // Link
  3462.         if(url1 != null){
  3463.             de = new DataElement();
  3464.             de.setType(DataElementType.LINK);
  3465.             de.setUrl(url1);
  3466.             if (contaListe)
  3467.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_PARAMETRI +"(" + numMTOMreq + ")");
  3468.             else
  3469.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_PARAMETRI);
  3470.             dati.add(de);
  3471.         }


  3472.         // Sezione Richiesta
  3473.         de = new DataElement();
  3474.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RISPOSTA);
  3475.         de.setType(DataElementType.TITLE);
  3476.         dati.add(de);

  3477.         // Stato
  3478.         de = new DataElement();
  3479.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_STATO);
  3480.         de.setType(DataElementType.SELECT);
  3481.         de.setName(CostantiControlStation.PARAMETRO_MTOM_RISPOSTA);
  3482.         de.setValues(modeMtomListRes);
  3483.         de.setSelected(mtomRisposta);
  3484.         de.setSize(this.getSize());
  3485.         dati.add(de);

  3486.         // Link
  3487.         if(url2 != null){
  3488.             de = new DataElement();
  3489.             de.setType(DataElementType.LINK);
  3490.             de.setUrl(url2);
  3491.             if (contaListe)
  3492.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_PARAMETRI +"(" + numMTOMres + ")");
  3493.             else
  3494.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_PARAMETRI);
  3495.             dati.add(de);
  3496.         }
  3497.        
  3498.         dati = addParameterApplicaModifica(dati);

  3499.         return dati;
  3500.     }
  3501.    
  3502.     private static boolean riusoIdCorrelazioneApplicativaPA = false; // riuso non abilitato nella porta applicativa
  3503.     public static boolean isRiusoIdCorrelazioneApplicativaPA() {
  3504.         return riusoIdCorrelazioneApplicativaPA;
  3505.     }
  3506.     public static void setRiusoIdCorrelazioneApplicativaPA(boolean riusoIdCorrelazioneApplicativaPA) {
  3507.         ConsoleHelper.riusoIdCorrelazioneApplicativaPA = riusoIdCorrelazioneApplicativaPA;
  3508.     }

  3509.     // Dati schermata correlazione applicativa
  3510.     public List<DataElement> addCorrelazioneApplicativaToDati(List<DataElement> dati,boolean portaDelegata,
  3511.             boolean riusoID,String scadcorr, String urlRichiesta, String urlRisposta, Boolean contaListe, int numCorrelazioneReq, int numCorrelazioneRes) {

  3512.         DataElement de = new DataElement();
  3513.         de = new DataElement();
  3514.         de.setType(DataElementType.TITLE);
  3515.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CORRELAZIONE_APPLICATIVA);
  3516.         dati.add(de);
  3517.        
  3518.         de = new DataElement();
  3519.         de.setType(DataElementType.SUBTITLE);
  3520.         //de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CORRELAZIONE_APPLICATIVA);
  3521.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RICHIESTA);
  3522.         dati.add(de);
  3523.        
  3524.         if(portaDelegata){      
  3525.             if (riusoID && numCorrelazioneReq > 0 && this.isModalitaAvanzata()) {
  3526.                 de = new DataElement();
  3527.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_SCADENZA_CORRELAZIONE_APPLICATIVA_LABEL);
  3528.                 de.setNote(CostantiControlStation.LABEL_PARAMETRO_SCADENZA_CORRELAZIONE_APPLICATIVA_NOTE);
  3529.                 de.setValue(scadcorr);
  3530.                 de.setType(DataElementType.TEXT_EDIT);
  3531.                 de.setName(CostantiControlStation.PARAMETRO_SCADENZA_CORRELAZIONE_APPLICATIVA);
  3532.                 dati.add(de);
  3533.             }
  3534.         } else {
  3535.             if (riusoIdCorrelazioneApplicativaPA && numCorrelazioneReq > 0 && this.isModalitaAvanzata()) {
  3536.                 de = new DataElement();
  3537.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_SCADENZA_CORRELAZIONE_APPLICATIVA_LABEL);
  3538.                 de.setNote(CostantiControlStation.LABEL_PARAMETRO_SCADENZA_CORRELAZIONE_APPLICATIVA_NOTE);
  3539.                 de.setValue(scadcorr);
  3540.                 de.setType(DataElementType.TEXT_EDIT);
  3541.                 de.setName(CostantiControlStation.PARAMETRO_SCADENZA_CORRELAZIONE_APPLICATIVA);
  3542.                 dati.add(de);
  3543.             }
  3544.         }
  3545.        
  3546.         de = new DataElement();
  3547.         de.setType(DataElementType.LINK);
  3548.         de.setUrl(urlRichiesta);

  3549.         if (contaListe) {
  3550.             ServletUtils.setDataElementCustomLabel(de,CostantiControlStation.LABEL_PARAMETRO_CORRELAZIONE_APPLICATIVA_RICHIESTA,Long.valueOf(numCorrelazioneReq));
  3551.         } else
  3552.             ServletUtils.setDataElementCustomLabel(de,CostantiControlStation.LABEL_PARAMETRO_CORRELAZIONE_APPLICATIVA_RICHIESTA);

  3553.         dati.add(de);

  3554.        
  3555.         de = new DataElement();
  3556.         de.setType(DataElementType.SUBTITLE);
  3557.         //de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CORRELAZIONE_APPLICATIVA);
  3558.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RISPOSTA);
  3559.         dati.add(de);
  3560.        
  3561.         de = new DataElement();
  3562.         de.setType(DataElementType.LINK);
  3563.         de.setUrl(urlRisposta);

  3564.         if (contaListe) {
  3565.             ServletUtils.setDataElementCustomLabel(de,CostantiControlStation.LABEL_PARAMETRO_CORRELAZIONE_APPLICATIVA_RISPOSTA,Long.valueOf(numCorrelazioneRes));
  3566.         } else
  3567.             ServletUtils.setDataElementCustomLabel(de,CostantiControlStation.LABEL_PARAMETRO_CORRELAZIONE_APPLICATIVA_RISPOSTA);

  3568.         dati.add(de);
  3569.        
  3570.         dati = addParameterApplicaModifica(dati);

  3571.         return dati;
  3572.     }

  3573.     public List<DataElement> addParameterApplicaModifica(List<DataElement> dati) {
  3574.         DataElement de;
  3575.         de = new DataElement();
  3576.         de.setType(DataElementType.HIDDEN);
  3577.         de.setName(CostantiControlStation.PARAMETRO_APPLICA_MODIFICA);
  3578.         de.setValue(Costanti.CHECK_BOX_ENABLED);
  3579.         dati.add(de);
  3580.         return dati;
  3581.     }
  3582.    
  3583.     // Controlla i dati della correlazione applicativa
  3584.     public boolean correlazioneApplicativaCheckData(TipoOperazione tipoOp,boolean portaDelegata,String scadcorr) throws DriverControlStationException {
  3585.         try{
  3586.             // scadenza correlazione intero > 0 opzionale
  3587.             if(scadcorr != null && !scadcorr.equals("")){
  3588.                 int scadCorrInt = -1;
  3589.                 try{
  3590.                     scadCorrInt = Integer.parseInt(scadcorr);
  3591.                 }catch(Exception e){
  3592.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SCADENZA_CORRELAZIONE_APPLICATIVA_NON_VALIDA_INSERIRE_UN_NUMERO_INTERO_MAGGIORE_DI_ZERO);
  3593.                     return false;
  3594.                 }
  3595.                
  3596.                 if(scadCorrInt <= 0){
  3597.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SCADENZA_CORRELAZIONE_APPLICATIVA_NON_VALIDA_INSERIRE_UN_NUMERO_INTERO_MAGGIORE_DI_ZERO);
  3598.                     return false;
  3599.                 }
  3600.             }
  3601.            
  3602.             return true;
  3603.         } catch (Exception e) {
  3604.             this.logError("Exception: " + e.getMessage(), e);
  3605.             throw new DriverControlStationException(e);
  3606.         }
  3607.     }

  3608.     // Controlla i dati della correlazione applicativa richiesta della porta delegata
  3609.     public boolean correlazioneApplicativaRichiestaCheckData(TipoOperazione tipoOp,boolean portaDelegata,
  3610.             ServiceBinding serviceBinding) throws DriverControlStationException {
  3611.         try {
  3612.             String id = this.getParameter(CostantiControlStation.PARAMETRO_ID);
  3613.             int idInt = Integer.parseInt(id);
  3614.             // String idsogg = this.getParameter("idsogg");
  3615.             String elemxml = this.getParameter(CostantiControlStation.PARAMETRO_ELEMENTO_XML);
  3616.             String mode = this.getParameter(CostantiControlStation.PARAMETRO_MODE_CORRELAZIONE_APPLICATIVA);
  3617.             String pattern = this.getParameter(CostantiControlStation.PARAMETRO_PATTERN);
  3618.             String idcorr = this.getParameter(CostantiControlStation.PARAMETRO_ID_CORRELAZIONE);
  3619.             int idcorrInt = 0;
  3620.             if (idcorr != null) {
  3621.                 idcorrInt = Integer.parseInt(idcorr);
  3622.             }

  3623.             if(elemxml!=null && !"".equals(elemxml)) {
  3624.                 if(this.checkLength255(elemxml, CostantiControlStation.LABEL_PARAMETRO_PORTE_ELEMENTO_XML)==false) {
  3625.                     return false;
  3626.                 }
  3627.             }
  3628.            
  3629.             // Campi obbligatori
  3630.             // if ( elemxml.equals("")||
  3631.             if (
  3632.                     (
  3633.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_URL_BASED) ||
  3634.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_HEADER_BASED) ||
  3635.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_CONTENT_BASED) ||
  3636.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_TEMPLATE) ||
  3637.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE) ||
  3638.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE)
  3639.                     )
  3640.                     &&
  3641.                     pattern.equals("")
  3642.                 ) {
  3643.                 String label = "";
  3644.                 if(mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_HEADER_BASED)) {
  3645.                     label = CostantiControlStation.LABEL_PARAMETRO_NOME;
  3646.                 }
  3647.                 else if(mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_TEMPLATE) ||
  3648.                         mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE) ||
  3649.                         mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE)) {
  3650.                     label = CostantiControlStation.LABEL_PARAMETRO_TEMPLATE;
  3651.                 }
  3652.                 else {
  3653.                     label = CostantiControlStation.LABEL_PATTERN;
  3654.                 }
  3655.                
  3656.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, label));
  3657.                 return false;
  3658.             }

  3659.             // Controllo che i campi "select" abbiano uno dei valori ammessi
  3660.             if (!mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_URL_BASED)
  3661.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_HEADER_BASED)
  3662.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_CONTENT_BASED)
  3663.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_INPUT_BASED)
  3664.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_TEMPLATE)
  3665.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE)
  3666.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE)
  3667.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_DISABILITATO)) {
  3668.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_MODALITA_IDENTIFICAZIONE_CON_TIPI_POSSIBILI);
  3669.                 return false;
  3670.             }

  3671.             if (mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_URL_BASED)) {
  3672.                 if(this.checkRegexp(pattern,ModalitaIdentificazione.URL_BASED.getLabelParametro())==false){
  3673.                     return false;
  3674.                 }
  3675.             }
  3676.            
  3677.             if (mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_TEMPLATE)) {
  3678.                 try{
  3679.                     DynamicUtils.validate(ModalitaIdentificazione.GOVWAY_TEMPLATE.getLabelParametro(), pattern, false);
  3680.                 }catch(Exception e){
  3681.                     this.pd.setMessage("Il valore indicato nel parametro '"+ModalitaIdentificazione.GOVWAY_TEMPLATE.getLabelParametro()+"' non risulta corretto: "+e.getMessage());
  3682.                     return false;
  3683.                 }
  3684.             }
  3685.            
  3686.             if (mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_CONTENT_BASED)) {
  3687.                 if(ServiceBinding.SOAP.equals(serviceBinding)) {
  3688.                     if(this.checkXPath(pattern,ModalitaIdentificazione.CONTENT_BASED.getLabelParametro())==false){
  3689.                         return false;
  3690.                     }
  3691.                 }
  3692.                 else {
  3693.                     if(this.checkXPathOrJsonPath(pattern,ModalitaIdentificazione.CONTENT_BASED.getLabelParametro())==false){
  3694.                         return false;
  3695.                     }
  3696.                 }
  3697.             }
  3698.            
  3699.             // Controllo che non esistano altre correlazioni applicative con gli
  3700.             // stessi dati
  3701.             boolean giaRegistrato = false;
  3702.             StringBuilder existsMessage = new StringBuilder();
  3703.             if(portaDelegata) {
  3704.                 giaRegistrato = ConsoleUtilities.alreadyExistsCorrelazioneApplicativaRichiesta(this.porteDelegateCore, idInt, elemxml, idcorrInt, existsMessage);
  3705.             }
  3706.             else {
  3707.                 giaRegistrato = ConsoleUtilities.alreadyExistsCorrelazioneApplicativaRichiesta(this.porteApplicativeCore, idInt, elemxml, idcorrInt, existsMessage);
  3708.             }
  3709.            
  3710.             if (giaRegistrato) {
  3711.                 this.pd.setMessage(existsMessage.toString());
  3712.                 return false;
  3713.             }          

  3714.             return true;
  3715.         } catch (Exception e) {
  3716.             this.logError("Exception: " + e.getMessage(), e);
  3717.             throw new DriverControlStationException(e);
  3718.         }
  3719.     }
  3720.    



  3721.     // Controlla i dati della correlazione applicativa della porta delegata
  3722.     public boolean correlazioneApplicativaRispostaCheckData(TipoOperazione tipoOp,boolean portaDelegata,
  3723.             ServiceBinding serviceBinding) throws DriverControlStationException {
  3724.         try {
  3725.             String id = this.getParameter(CostantiControlStation.PARAMETRO_ID);
  3726.             int idInt = Integer.parseInt(id);
  3727.             // String idsogg = this.getParameter("idsogg");
  3728.             String elemxml = this.getParameter(CostantiControlStation.PARAMETRO_ELEMENTO_XML);
  3729.             String mode = this.getParameter(CostantiControlStation.PARAMETRO_MODE_CORRELAZIONE_APPLICATIVA);
  3730.             String pattern = this.getParameter(CostantiControlStation.PARAMETRO_PATTERN);
  3731.             String idcorr = this.getParameter(CostantiControlStation.PARAMETRO_ID_CORRELAZIONE);
  3732.             int idcorrInt = 0;
  3733.             if (idcorr != null) {
  3734.                 idcorrInt = Integer.parseInt(idcorr);
  3735.             }

  3736.             if(elemxml!=null && !"".equals(elemxml)) {
  3737.                 if(this.checkLength255(elemxml, CostantiControlStation.LABEL_PARAMETRO_PORTE_ELEMENTO_XML)==false) {
  3738.                     return false;
  3739.                 }
  3740.             }
  3741.            
  3742.             // Campi obbligatori
  3743.             // if ( elemxml.equals("")||
  3744.             if (
  3745.                     (
  3746.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_URL_BASED) ||
  3747.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_HEADER_BASED) ||
  3748.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_CONTENT_BASED) ||
  3749.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_TEMPLATE) ||
  3750.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE) ||
  3751.                             mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE)
  3752.                     )
  3753.                     &&
  3754.                     pattern.equals("")
  3755.                 ) {
  3756.                 String label = "";
  3757.                 if(mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_HEADER_BASED)) {
  3758.                     label = CostantiControlStation.LABEL_PARAMETRO_NOME;
  3759.                 }
  3760.                 else if(mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_TEMPLATE) ||
  3761.                         mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE) ||
  3762.                         mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE)) {
  3763.                     label = CostantiControlStation.LABEL_PARAMETRO_TEMPLATE;
  3764.                 }
  3765.                 else {
  3766.                     label = CostantiControlStation.LABEL_PATTERN;
  3767.                 }
  3768.                
  3769.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, label));
  3770.                 return false;
  3771.             }

  3772.             // Controllo che i campi "select" abbiano uno dei valori ammessi
  3773.             if (!mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_URL_BASED)
  3774.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_HEADER_BASED)
  3775.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_CONTENT_BASED)
  3776.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_INPUT_BASED)  
  3777.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_TEMPLATE)
  3778.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE)
  3779.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE)
  3780.                     && !mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_DISABILITATO)) {
  3781.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_MODALITA_IDENTIFICAZIONE_CON_TIPI_POSSIBILI);
  3782.                 return false;
  3783.             }

  3784.             if (mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_URL_BASED)) {
  3785.                 if(this.checkRegexp(pattern,ModalitaIdentificazione.URL_BASED.getLabelParametro())==false){
  3786.                     return false;
  3787.                 }
  3788.             }
  3789.             if (mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_TEMPLATE)) {
  3790.                 try{
  3791.                     DynamicUtils.validate(ModalitaIdentificazione.GOVWAY_TEMPLATE.getLabelParametro(), pattern, false);
  3792.                 }catch(Exception e){
  3793.                     this.pd.setMessage("Il valore indicato nel parametro '"+ModalitaIdentificazione.GOVWAY_TEMPLATE.getLabelParametro()+"' non risulta corretto: "+e.getMessage());
  3794.                     return false;
  3795.                 }
  3796.             }
  3797.             if (mode.equals(CostantiControlStation.VALUE_PARAMETRO_MODE_CORRELAZIONE_CONTENT_BASED)) {
  3798.                 if(ServiceBinding.SOAP.equals(serviceBinding)) {
  3799.                     if(this.checkXPath(pattern,ModalitaIdentificazione.CONTENT_BASED.getLabelParametro())==false){
  3800.                         return false;
  3801.                     }
  3802.                 }
  3803.                 else {
  3804.                     if(this.checkXPathOrJsonPath(pattern,ModalitaIdentificazione.CONTENT_BASED.getLabelParametro())==false){
  3805.                         return false;
  3806.                     }
  3807.                 }
  3808.             }
  3809.            
  3810.             // Controllo che non esistano altre correlazioni applicative con gli
  3811.             // stessi dati
  3812.             boolean giaRegistrato = false;
  3813.             StringBuilder existsMessage = new StringBuilder();
  3814.             if(portaDelegata) {
  3815.                 giaRegistrato = ConsoleUtilities.alreadyExistsCorrelazioneApplicativaRisposta(this.porteDelegateCore, idInt, elemxml, idcorrInt, existsMessage);
  3816.             }
  3817.             else {
  3818.                 giaRegistrato = ConsoleUtilities.alreadyExistsCorrelazioneApplicativaRisposta(this.porteApplicativeCore, idInt, elemxml, idcorrInt, existsMessage);
  3819.             }
  3820.            
  3821.             if (giaRegistrato) {
  3822.                 this.pd.setMessage(existsMessage.toString());
  3823.                 return false;
  3824.             }  
  3825.            
  3826.             return true;
  3827.         } catch (Exception e) {
  3828.             this.logError("Exception: " + e.getMessage(), e);
  3829.             throw new DriverControlStationException(e);
  3830.         }
  3831.     }





  3832.     // Controlla i dati del Message-Security
  3833.     public boolean MTOMCheckData(TipoOperazione tipoOp) throws DriverControlStationException {
  3834.         try{
  3835.             String mtomRichiesta = this.getParameter(CostantiControlStation.PARAMETRO_MTOM_RICHIESTA);
  3836.             String mtomRisposta = this.getParameter(CostantiControlStation.PARAMETRO_MTOM_RISPOSTA);

  3837.             // Controllo che i campi "select" abbiano uno dei valori ammessi
  3838.             if (!mtomRichiesta.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MTOM_DISABLE) &&
  3839.                     !mtomRichiesta.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MTOM_PACKAGING) &&
  3840.                     !mtomRichiesta.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MTOM_VERIFY) &&
  3841.                     !mtomRichiesta.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MTOM_UNPACKAGING)) {
  3842.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_STATO_DELLA_RICHIESTA_DEVE_ESSERE_DISABLED_PACKAGING_UNPACKAGING_O_VERIFY);
  3843.                 return false;
  3844.             }

  3845.             if (!mtomRisposta.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MTOM_DISABLE) &&
  3846.                     !mtomRisposta.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MTOM_PACKAGING) &&
  3847.                     !mtomRisposta.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MTOM_VERIFY) &&
  3848.                     !mtomRisposta.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MTOM_UNPACKAGING)) {
  3849.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_STATO_DELLA_RISPOSTA_DEVE_ESSERE_DISABLED_PACKAGING_UNPACKAGING_O_VERIFY);
  3850.                 return false;
  3851.             }

  3852.             return true;
  3853.         } catch (Exception e) {
  3854.             this.logError("Exception: " + e.getMessage(), e);
  3855.             throw new DriverControlStationException(e);
  3856.         }
  3857.     }

  3858.     // Controlla i dati dei parametri MTOM
  3859.     public boolean MTOMParameterCheckData(TipoOperazione tipoOp, boolean isRisposta, boolean isPortaDelegata) throws DriverControlStationException {
  3860.         try {
  3861.             String id = this.getParameter(CostantiControlStation.PARAMETRO_ID);
  3862.             int idInt = Integer.parseInt(id);
  3863.             String nome = this.getParameter(CostantiControlStation.PARAMETRO_NOME);
  3864.             String contentType =this.getParameter(CostantiControlStation.PARAMETRO_CONTENT_TYPE);
  3865.             //  String obbligatorio = this.getParameter(CostantiControlStation.PARAMETRO_OBBLIGATORIO);
  3866.             String pattern = this.getParameter(CostantiControlStation.PARAMETRO_PATTERN);


  3867.             // Campi obbligatori
  3868.             if (nome.equals("") || pattern.equals("")) {
  3869.                 String tmpElenco = "";
  3870.                 if (nome.equals("")) {
  3871.                     tmpElenco = CostantiControlStation.LABEL_PARAMETRO_NOME;
  3872.                 }
  3873.                 if (pattern.equals("")) {
  3874.                     if (tmpElenco.equals("")) {
  3875.                         tmpElenco = CostantiControlStation.LABEL_PATTERN;
  3876.                     } else {
  3877.                         tmpElenco = tmpElenco + ", " + CostantiControlStation.LABEL_PATTERN;
  3878.                     }
  3879.                 }
  3880.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, tmpElenco));
  3881.                 return false;
  3882.             }

  3883.             // Controllo che non ci siano spazi nei campi di testo
  3884.             //if ((nome.indexOf(" ") != -1) || (valore.indexOf(" ") != -1)) {
  3885.             if ((nome.indexOf(" ") != -1) ) {
  3886.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEL_CAMPO_NOME);
  3887.                 return false;
  3888.             }
  3889.             if(pattern.indexOf(" ") != -1){
  3890.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRROE_NON_INSERIRE_SPAZI_NEL_CAMPO_PATTERN);
  3891.                 return false;
  3892.             }



  3893.             if(contentType!=null && contentType.indexOf(" ") != -1){
  3894.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEL_CAMPO_CONTENT_TYPE);
  3895.                 return false;
  3896.             }

  3897.             // length
  3898.             if(this.checkLength255(nome, CostantiControlStation.LABEL_PARAMETRO_NOME)==false) {
  3899.                 return false;
  3900.             }
  3901.             if(contentType!=null && !"".equals(contentType)){
  3902.                 if(this.checkLength255(contentType, CostantiControlStation.LABEL_PARAMETRO_CONTENT_TYPE)==false) {
  3903.                     return false;
  3904.                 }
  3905.             }
  3906.            
  3907.             // Se tipoOp = add, controllo che il message-security non sia gia' stato
  3908.             // registrato per la porta delegata
  3909.             if (tipoOp.equals(TipoOperazione.ADD)) {
  3910.                 MtomProcessor mtomProcessor = null;
  3911.                 boolean giaRegistrato = false;
  3912.                 String nomeporta =  null;

  3913.                 if(isPortaDelegata){
  3914.                     PortaDelegata pde = this.porteDelegateCore.getPortaDelegata(idInt);
  3915.                     nomeporta = pde.getNome();
  3916.                     mtomProcessor = pde.getMtomProcessor();
  3917.                 } else {
  3918.                     PortaApplicativa pa = this.porteApplicativeCore.getPortaApplicativa(idInt);
  3919.                     nomeporta = pa.getNome();
  3920.                     mtomProcessor = pa.getMtomProcessor();
  3921.                 }

  3922.                 if(mtomProcessor!=null){
  3923.                     if(!isRisposta){
  3924.                         if(mtomProcessor.getRequestFlow()!=null){
  3925.                             for (int i = 0; i < mtomProcessor.getRequestFlow().sizeParameterList(); i++) {
  3926.                                 MtomProcessorFlowParameter tmpMTOM =mtomProcessor.getRequestFlow().getParameter(i);
  3927.                                 if (nome.equals(tmpMTOM.getNome())) {
  3928.                                     giaRegistrato = true;
  3929.                                     break;
  3930.                                 }
  3931.                             }
  3932.                         }
  3933.                     } else {
  3934.                         if(mtomProcessor.getResponseFlow()!=null){
  3935.                             for (int i = 0; i < mtomProcessor.getResponseFlow().sizeParameterList(); i++) {
  3936.                                 MtomProcessorFlowParameter tmpMTOM =mtomProcessor.getResponseFlow().getParameter(i);
  3937.                                 if (nome.equals(tmpMTOM.getNome())) {
  3938.                                     giaRegistrato = true;
  3939.                                     break;
  3940.                                 }
  3941.                             }
  3942.                         }
  3943.                     }
  3944.                 }

  3945.                 if (giaRegistrato) {
  3946.                     if(isPortaDelegata)
  3947.                         this.pd.setMessage(MessageFormat.format(
  3948.                                 CostantiControlStation.MESSAGGIO_ERRORE_PROPRIETA_DI_MTOM_GIA_ASSOCIATA_ALLA_PORTA_DELEGATA_XX, nome, nomeporta));
  3949.                     else
  3950.                         this.pd.setMessage(MessageFormat.format(
  3951.                                 CostantiControlStation.MESSAGGIO_ERRORE_PROPRIETA_DI_MTOM_GIA_ASSOCIATA_ALLA_PORTA_APPLICATIVA_XX, nome, nomeporta));
  3952.                     return false;
  3953.                 }
  3954.             }

  3955.             return true;

  3956.         } catch (Exception e) {
  3957.             this.logError("Exception: " + e.getMessage(), e);
  3958.             throw new DriverControlStationException(e);
  3959.         }
  3960.     }

  3961.     public List<DataElement> addMTOMParameterToDati(TipoOperazione tipoOp,List<DataElement> dati,boolean enableUpdate, String nome, String pattern,
  3962.             String contentType, String obbligatorio, MTOMProcessorType type) {

  3963.         // Nome
  3964.         DataElement de = new DataElement();
  3965.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  3966.         de.setValue(nome);
  3967.         if (tipoOp.equals(TipoOperazione.ADD) || enableUpdate) {
  3968.             de.setType(DataElementType.TEXT_EDIT);
  3969.             de.setRequired(true);
  3970.         } else {
  3971.             de.setType(DataElementType.TEXT);
  3972.         }
  3973.         de.setName(CostantiControlStation.PARAMETRO_NOME);
  3974.         de.setSize(this.getSize());
  3975.         de.setRequired(true);
  3976.         DataElementInfo dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_NOME);
  3977.         switch (type) {
  3978.         case PACKAGING:
  3979.         case VERIFY:
  3980.             dInfoPattern.setBody(CostantiControlStation.LABEL_CONFIGURAZIONE_MTOM_INFO_NOME_SOAP_PACKAGE);
  3981.             break;
  3982.         default:
  3983.             dInfoPattern = null;
  3984.             break;
  3985.         }
  3986.         de.setInfo(dInfoPattern);
  3987.         dati.add(de);

  3988.         // Pattern
  3989.         de = new DataElement();
  3990.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PATTERN);
  3991.         de.setValue(pattern);
  3992.         de.setType(DataElementType.TEXT_AREA);
  3993.         de.setName(CostantiControlStation.PARAMETRO_PATTERN);
  3994.         de.setSize(this.getSize());
  3995.         de.setRequired(true);
  3996.         dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_PATTERN);
  3997.         switch (type) {
  3998.         case PACKAGING:
  3999.             dInfoPattern.setBody(CostantiControlStation.LABEL_CONFIGURAZIONE_MTOM_INFO_PATTERN_SOAP_PACKAGE);
  4000.             break;
  4001.         case VERIFY:
  4002.             dInfoPattern.setBody(CostantiControlStation.LABEL_CONFIGURAZIONE_MTOM_INFO_PATTERN_SOAP_VERIFY);
  4003.             break;
  4004.         default:
  4005.             dInfoPattern = null;
  4006.             break;
  4007.         }
  4008.         de.setInfo(dInfoPattern);
  4009.         dati.add(de);

  4010.         // Content-type
  4011.         de = new DataElement();
  4012.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONTENT_TYPE);
  4013.         de.setValue(contentType);
  4014.         de.setType(DataElementType.TEXT_EDIT);
  4015.         de.setName(CostantiControlStation.PARAMETRO_CONTENT_TYPE);
  4016.         de.setSize(this.getSize());
  4017.         dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONTENT_TYPE);
  4018.         switch (type) {
  4019.         case PACKAGING:
  4020.             dInfoPattern.setBody(CostantiControlStation.LABEL_CONFIGURAZIONE_MTOM_INFO_CONTENT_TYPE_SOAP_PACKAGE);
  4021.             break;
  4022.         case VERIFY:
  4023.             dInfoPattern.setBody(CostantiControlStation.LABEL_CONFIGURAZIONE_MTOM_INFO_CONTENT_TYPE_SOAP_VERIFY);
  4024.             break;
  4025.         default:
  4026.             dInfoPattern = null;
  4027.             break;
  4028.         }
  4029.         de.setInfo(dInfoPattern);
  4030.         dati.add(de);

  4031.         // Obbligatorio
  4032.         de = new DataElement();
  4033.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_OBBLIGATORIO);
  4034.         de.setType(DataElementType.CHECKBOX);
  4035.         if( ServletUtils.isCheckBoxEnabled(obbligatorio) || CostantiRegistroServizi.ABILITATO.equals(obbligatorio) ){
  4036.             de.setSelected(true);
  4037.         }
  4038.         de.setName(CostantiControlStation.PARAMETRO_OBBLIGATORIO);
  4039.         dati.add(de);

  4040.         return dati;
  4041.     }

  4042.     public List<DataElement> addProtocolPropertiesToDatiRegistry(List<DataElement> dati, ConsoleConfiguration consoleConfiguration,ConsoleOperationType consoleOperationType,
  4043.             ProtocolProperties protocolProperties) throws DriverControlStationException{
  4044.         return addProtocolPropertiesToDatiRegistry(dati, consoleConfiguration, consoleOperationType, protocolProperties, null, null);
  4045.     }
  4046.     public List<DataElement> addProtocolPropertiesToDatiRegistry(List<DataElement> dati, ConsoleConfiguration consoleConfiguration,ConsoleOperationType consoleOperationType,
  4047.             ProtocolProperties protocolProperties, List<ProtocolProperty> listaProtocolPropertiesDaDB ,Properties binaryPropertyChangeInfoProprietario) throws DriverControlStationException{
  4048.        
  4049.         String titleId = null;
  4050.         String endTitleId = null;
  4051.        
  4052.         String subtitleId = null;
  4053.         String endSubtitleId = null;
  4054.        
  4055.         for (BaseConsoleItem item : consoleConfiguration.getConsoleItem()) {
  4056.             AbstractProperty<?> property = ProtocolPropertiesUtils.getAbstractPropertyById(protocolProperties, item.getId());
  4057.             // imposto nel default value il valore attuale.
  4058.             // Mi tengo cmq il default value attuale per le opzioni di selected
  4059.             Object defaultItemValue = null;
  4060.             if(item instanceof AbstractConsoleItem<?> ) {
  4061.                 AbstractConsoleItem<?> itemConsole = (AbstractConsoleItem<?>) item;
  4062.                 defaultItemValue = itemConsole.getDefaultValue();
  4063.             }
  4064.             try {
  4065.                 ProtocolPropertiesUtils.setDefaultValue(item, property);
  4066.    
  4067.                 ProtocolProperty protocolProperty = ProtocolPropertiesUtils.getProtocolPropertyRegistry(item.getId(), listaProtocolPropertiesDaDB);
  4068.                 dati = ProtocolPropertiesUtilities.itemToDataElement(dati,this,item, defaultItemValue,
  4069.                         consoleOperationType, binaryPropertyChangeInfoProprietario, protocolProperty, this.getSize());
  4070.             }catch(Exception e) {
  4071.                 throw new DriverControlStationException(e.getMessage(),e);
  4072.             }
  4073.            
  4074.             if(ConsoleItemType.TITLE.equals(item.getType()) && item instanceof TitleConsoleItem) {
  4075.                 TitleConsoleItem titleItem = (TitleConsoleItem) item;
  4076.                 if(titleItem.isCloseable()) {
  4077.                     titleId = titleItem.getId();
  4078.                     endTitleId = titleItem.getLastItemId();
  4079.                 }
  4080.             }
  4081.             else if(ConsoleItemType.SUBTITLE.equals(item.getType()) && item instanceof SubtitleConsoleItem) {
  4082.                 SubtitleConsoleItem subItem = (SubtitleConsoleItem) item;
  4083.                 if(subItem.isCloseable()) {
  4084.                     subtitleId = subItem.getId();
  4085.                     endSubtitleId = subItem.getLastItemId();
  4086.                 }
  4087.             }
  4088.             else {
  4089.                 if(endTitleId!=null && endTitleId.equals(item.getId())) {
  4090.                     this.impostaAperturaTitle(dati, titleId);
  4091.                 }
  4092.                 else if(endSubtitleId!=null && endSubtitleId.equals(item.getId())) {
  4093.                     this.impostaAperturaSubTitle(dati, subtitleId);
  4094.                 }
  4095.             }
  4096.         }

  4097.         // Imposto il flag per indicare che ho caricato la configurazione
  4098.         DataElement de = new DataElement();
  4099.         de.setName(ProtocolPropertiesCostanti.PARAMETRO_PP_SET);
  4100.         de.setType(DataElementType.HIDDEN);
  4101.         de.setValue("ok");
  4102.         dati.add(de);

  4103.         return dati;
  4104.     }
  4105.    
  4106.     public List<DataElement> addProtocolPropertiesToDatiConfig(List<DataElement> dati, ConsoleConfiguration consoleConfiguration,ConsoleOperationType consoleOperationType,
  4107.             ProtocolProperties protocolProperties) throws DriverControlStationException{
  4108.         return addProtocolPropertiesToDatiRegistry(dati, consoleConfiguration, consoleOperationType, protocolProperties, null, null);
  4109.     }
  4110.     public List<DataElement> addProtocolPropertiesToDatiConfig(List<DataElement> dati, ConsoleConfiguration consoleConfiguration,ConsoleOperationType consoleOperationType,
  4111.             ProtocolProperties protocolProperties, List<org.openspcoop2.core.config.ProtocolProperty> listaProtocolPropertiesDaDB ,Properties binaryPropertyChangeInfoProprietario) throws DriverControlStationException{
  4112.    
  4113.         String titleId = null;
  4114.         String endTitleId = null;
  4115.        
  4116.         String subtitleId = null;
  4117.         String endSubtitleId = null;
  4118.        
  4119.         for (BaseConsoleItem item : consoleConfiguration.getConsoleItem()) {
  4120.             AbstractProperty<?> property = ProtocolPropertiesUtils.getAbstractPropertyById(protocolProperties, item.getId());
  4121.             // imposto nel default value il valore attuale.
  4122.             // Mi tengo cmq il default value attuale per le opzioni di selected
  4123.             Object defaultItemValue = null;
  4124.             if(item instanceof AbstractConsoleItem<?> ) {
  4125.                 AbstractConsoleItem<?> itemConsole = (AbstractConsoleItem<?>) item;
  4126.                 defaultItemValue = itemConsole.getDefaultValue();
  4127.             }
  4128.             try {
  4129.                 ProtocolPropertiesUtils.setDefaultValue(item, property);
  4130.                
  4131.                 org.openspcoop2.core.config.ProtocolProperty protocolProperty = ProtocolPropertiesUtils.getProtocolPropertyConfig(item.getId(), listaProtocolPropertiesDaDB);
  4132.                 dati = ProtocolPropertiesUtilities.itemToDataElement(dati,this,item, defaultItemValue,
  4133.                         consoleOperationType, binaryPropertyChangeInfoProprietario, protocolProperty, this.getSize());
  4134.             }catch(Exception e) {
  4135.                 throw new DriverControlStationException(e.getMessage(),e);
  4136.             }
  4137.            
  4138.             if(ConsoleItemType.TITLE.equals(item.getType()) && item instanceof TitleConsoleItem) {
  4139.                 TitleConsoleItem titleItem = (TitleConsoleItem) item;
  4140.                 if(titleItem.isCloseable()) {
  4141.                     titleId = titleItem.getId();
  4142.                     endTitleId = titleItem.getLastItemId();
  4143.                 }
  4144.             }
  4145.             else if(ConsoleItemType.SUBTITLE.equals(item.getType()) && item instanceof SubtitleConsoleItem) {
  4146.                 SubtitleConsoleItem subItem = (SubtitleConsoleItem) item;
  4147.                 if(subItem.isCloseable()) {
  4148.                     subtitleId = subItem.getId();
  4149.                     endSubtitleId = subItem.getLastItemId();
  4150.                 }
  4151.             }
  4152.             else {
  4153.                 if(endTitleId!=null && endTitleId.equals(item.getId())) {
  4154.                     this.impostaAperturaTitle(dati, titleId);
  4155.                 }
  4156.                 else if(endSubtitleId!=null && endSubtitleId.equals(item.getId())) {
  4157.                     this.impostaAperturaSubTitle(dati, subtitleId);
  4158.                 }
  4159.             }
  4160.         }

  4161.         // Imposto il flag per indicare che ho caricato la configurazione
  4162.         DataElement de = new DataElement();
  4163.         de.setName(ProtocolPropertiesCostanti.PARAMETRO_PP_SET);
  4164.         de.setType(DataElementType.HIDDEN);
  4165.         de.setValue("ok");
  4166.         dati.add(de);

  4167.         return dati;
  4168.     }
  4169.    
  4170.    
  4171.     public List<DataElement> addProtocolPropertiesToDatiAsHidden(List<DataElement> dati, ConsoleConfiguration consoleConfiguration,ConsoleOperationType consoleOperationType,
  4172.             ProtocolProperties protocolProperties) throws DriverControlStationException{
  4173.         return addProtocolPropertiesToDatiAsHidden(dati, consoleConfiguration, consoleOperationType, protocolProperties, null, null);
  4174.     }

  4175.     public List<DataElement> addProtocolPropertiesToDatiAsHidden(List<DataElement> dati, ConsoleConfiguration consoleConfiguration,ConsoleOperationType consoleOperationType,
  4176.             ProtocolProperties protocolProperties, List<ProtocolProperty> listaProtocolPropertiesDaDB ,Properties binaryPropertyChangeInfoProprietario) throws DriverControlStationException{
  4177.         for (BaseConsoleItem item : consoleConfiguration.getConsoleItem()) {
  4178.             AbstractProperty<?> property = ProtocolPropertiesUtils.getAbstractPropertyById(protocolProperties, item.getId());
  4179.             // imposto nel default value il valore attuale.
  4180.             // Mi tengo cmq il default value attuale per le opzioni di selected
  4181.             Object defaultItemValue = null;
  4182.             if(item instanceof AbstractConsoleItem<?> ) {
  4183.                 AbstractConsoleItem<?> itemConsole = (AbstractConsoleItem<?>) item;
  4184.                 defaultItemValue = itemConsole.getDefaultValue();
  4185.             }
  4186.             try {
  4187.                 ProtocolPropertiesUtils.setDefaultValue(item, property);
  4188.    
  4189.                 ProtocolProperty protocolProperty = ProtocolPropertiesUtils.getProtocolPropertyRegistry(item.getId(), listaProtocolPropertiesDaDB);
  4190.                 dati = ProtocolPropertiesUtilities.itemToDataElementAsHidden(dati, this, item, defaultItemValue,
  4191.                         consoleOperationType, binaryPropertyChangeInfoProprietario, protocolProperty, this.getSize());
  4192.             }catch(Exception e) {
  4193.                 throw new DriverControlStationException(e.getMessage(),e);
  4194.             }
  4195.         }

  4196.         // Imposto il flag per indicare che ho caricato la configurazione
  4197.         DataElement de = new DataElement();
  4198.         de.setName(ProtocolPropertiesCostanti.PARAMETRO_PP_SET);
  4199.         de.setType(DataElementType.HIDDEN);
  4200.         de.setValue("ok");
  4201.         dati.add(de);

  4202.         return dati;
  4203.     }

  4204.     public void validaProtocolProperties(ConsoleConfiguration consoleConfiguration, ConsoleOperationType consoleOperationType, ProtocolProperties properties) throws ProtocolException{
  4205.         try {
  4206.             List<BaseConsoleItem> consoleItems = consoleConfiguration.getConsoleItem();
  4207.             for (int i = 0; i < properties.sizeProperties(); i++) {
  4208.                 AbstractProperty<?> property = properties.getProperty(i);
  4209.                 AbstractConsoleItem<?> consoleItem = ProtocolPropertiesUtils.getAbstractConsoleItem(consoleItems, property);

  4210.                 if(consoleItem != null &&
  4211.                     !consoleItem.isHidden()) {
  4212.                     if(consoleItem instanceof StringConsoleItem){
  4213.                         StringProperty sp = (StringProperty) property;
  4214.                         if (consoleItem.isRequired() && StringUtils.isEmpty(sp.getValue())) {
  4215.                             if(consoleItem.getLabel()==null || "".equals(consoleItem.getLabel())) {
  4216.                                 throw new ProtocolException(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI);
  4217.                             }
  4218.                             else {
  4219.                                 throw new ProtocolException(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, consoleItem.getLabel()));
  4220.                             }
  4221.                         }

  4222.                         if(StringUtils.isNotEmpty(consoleItem.getRegexpr()) &&
  4223.                             !RegularExpressionEngine.isMatch(sp.getValue(),consoleItem.getRegexpr())){
  4224.                             throw new ProtocolException(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_IL_CAMPO_XX_DEVE_RISPETTARE_IL_PATTERN_YY, consoleItem.getLabel(), consoleItem.getRegexpr()));
  4225.                         }
  4226.                        
  4227.                         if(StringUtils.isNotEmpty(sp.getValue())) {
  4228.                             try {
  4229.                                 if(!this.checkLength4000(sp.getValue(), consoleItem.getLabel())) {
  4230.                                     throw new ProtocolException(this.pd.getMessage());
  4231.                                 }
  4232.                             }catch(Exception e) {
  4233.                                 throw new ProtocolException(e.getMessage(),e);
  4234.                             }
  4235.                         }
  4236.                     }
  4237.                     else if(consoleItem instanceof NumberConsoleItem){
  4238.                         NumberProperty np = (NumberProperty) property;
  4239.                         if (consoleItem.isRequired() && np.getValue() == null) {
  4240.                             if(consoleItem.getLabel()==null || "".equals(consoleItem.getLabel())) {
  4241.                                 throw new ProtocolException(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI);
  4242.                             }
  4243.                             else {
  4244.                                 throw new ProtocolException(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, consoleItem.getLabel()));
  4245.                             }
  4246.                         }
  4247.                         if(np.getValue()!=null &&
  4248.                             ConsoleItemType.NUMBER.equals(consoleItem.getType()) && (consoleItem instanceof NumberConsoleItem)) {
  4249.                             long v = np.getValue();
  4250.                             NumberConsoleItem nci = (NumberConsoleItem) consoleItem;
  4251.                             if(v<nci.getMin()) {
  4252.                                 throw new ProtocolException(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_VALORE_MINORE_DEL_MINIMO, consoleItem.getLabel(), nci.getMin()));
  4253.                             }
  4254.                             if(v>nci.getMax()) {
  4255.                                 throw new ProtocolException(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_VALORE_MINORE_DEL_MASSIMO, consoleItem.getLabel(), nci.getMax()));
  4256.                             }
  4257.                         }
  4258.                     }
  4259.                     else if(consoleItem instanceof BinaryConsoleItem){
  4260.                         BinaryProperty bp = (BinaryProperty) property;
  4261.                         if (consoleOperationType.equals(ConsoleOperationType.ADD) && consoleItem.isRequired() && (bp.getValue() == null || bp.getValue().length == 0)) {
  4262.                             if(consoleItem.getLabel()==null || "".equals(consoleItem.getLabel())) {
  4263.                                 throw new ProtocolException(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI);
  4264.                             }
  4265.                             else {
  4266.                                 throw new ProtocolException(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, consoleItem.getLabel()));
  4267.                             }
  4268.                         }
  4269.                     }
  4270.                     else if(consoleItem instanceof BooleanConsoleItem){
  4271.                         BooleanProperty bp = (BooleanProperty) property;
  4272.                         // le checkbox obbligatorie non dovrebbero esserci...
  4273.                         if (consoleItem.isRequired() && bp.getValue() == null) {
  4274.                             if(consoleItem.getLabel()==null || "".equals(consoleItem.getLabel())) {
  4275.                                 throw new ProtocolException(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI);
  4276.                             }
  4277.                             else {
  4278.                                 throw new ProtocolException(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, consoleItem.getLabel()));
  4279.                             }
  4280.                         }
  4281.                     }
  4282.                 }
  4283.             }

  4284.         } catch (RegExpException | RegExpNotValidException | RegExpNotFoundException e) {
  4285.             throw new ProtocolException(e);
  4286.         } catch (ProtocolException e) {
  4287.             throw e;
  4288.         }

  4289.     }

  4290.     public void validaProtocolPropertyBinaria(String nome, ConsoleConfiguration consoleConfiguration, ConsoleOperationType consoleOperationType, ProtocolProperties properties) throws ProtocolException{
  4291.         try {
  4292.             List<BaseConsoleItem> consoleItems = consoleConfiguration.getConsoleItem();
  4293.             for (int i = 0; i < properties.sizeProperties(); i++) {
  4294.                 AbstractProperty<?> property = properties.getProperty(i);
  4295.                 AbstractConsoleItem<?> consoleItem = ProtocolPropertiesUtils.getAbstractConsoleItem(consoleItems, property);

  4296.                 if(consoleItem != null) {
  4297.                     if(consoleItem instanceof BinaryConsoleItem && consoleItem.getId().equals(nome)){
  4298.                         BinaryProperty bp = (BinaryProperty) property;
  4299.                         if (consoleItem.isRequired() && (bp.getValue() == null || bp.getValue().length == 0)) {
  4300.                             throw new ProtocolException(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, consoleItem.getLabel()));
  4301.                         }

  4302.                     }
  4303.                 }
  4304.             }

  4305.         } catch (ProtocolException e) {
  4306.             throw e;
  4307.         }

  4308.     }

  4309.    
  4310.     public List<DataElement> addRuoliToDati(TipoOperazione tipoOp,List<DataElement> dati,boolean enableUpdate, FiltroRicercaRuoli filtroRuoli, String nome,
  4311.             List<String> ruoliGiaConfigurati, boolean addSelezioneVuota, boolean addMsgServiziApplicativoNonDisponibili,
  4312.             boolean addTitoloSezione,
  4313.             String accessDaChangeTmp,
  4314.             boolean isToken) throws DriverRegistroServiziException {
  4315.         return this.addRuoliToDati(tipoOp, dati, enableUpdate, filtroRuoli, nome, ruoliGiaConfigurati,
  4316.                 addSelezioneVuota, addMsgServiziApplicativoNonDisponibili, CostantiControlStation.LABEL_PARAMETRO_RUOLO,
  4317.                 addTitoloSezione, accessDaChangeTmp,
  4318.                 isToken);
  4319.     }
  4320.     public List<DataElement> addRuoliToDati(TipoOperazione tipoOp,List<DataElement> dati,boolean enableUpdate, FiltroRicercaRuoli filtroRuoli, String nome,
  4321.             List<String> ruoliGiaConfigurati, boolean addSelezioneVuota, boolean addMsgServiziApplicativoNonDisponibili, String labelParametro,
  4322.             boolean addTitoloSezione,
  4323.             String accessDaChangeTmp,
  4324.             boolean isToken) throws DriverRegistroServiziException {

  4325.         List<String> allRuoli = this.confCore.getAllRuoli(filtroRuoli);
  4326.         List<String> ruoliDaFarScegliere = new ArrayList<>();
  4327.         if(ruoliGiaConfigurati!=null && ruoliGiaConfigurati.size()>0){
  4328.             for (String ruolo : allRuoli) {
  4329.                 if(ruoliGiaConfigurati.contains(ruolo)==false){
  4330.                     ruoliDaFarScegliere.add(ruolo);
  4331.                 }
  4332.             }
  4333.         }
  4334.         else{
  4335.             ruoliDaFarScegliere.addAll(allRuoli);
  4336.         }
  4337.        
  4338.         DataElement de = new DataElement();
  4339.         de.setName(CostantiControlStation.PARAMETRO_ACCESSO_DA_CHANGE);
  4340.         de.setType(DataElementType.HIDDEN);
  4341.         de.setValue(accessDaChangeTmp);
  4342.         dati.add(de);
  4343.        
  4344.         if(isToken) {
  4345.             de = new DataElement();
  4346.             de.setType(DataElementType.HIDDEN);
  4347.             de.setName(CostantiControlStation.PARAMETRO_TOKEN_AUTHORIZATION);
  4348.             de.setValue("true");
  4349.             dati.add(de);
  4350.         }
  4351.        
  4352.         // Nome
  4353.         if(ruoliDaFarScegliere.size()>0){
  4354.            
  4355.             if(addTitoloSezione){
  4356.                 de = new DataElement();
  4357.                 de.setLabel(RuoliCostanti.LABEL_RUOLO);
  4358.                 de.setType(DataElementType.TITLE);
  4359.                 dati.add(de);
  4360.             }
  4361.            
  4362.             List<String> ruoli = new ArrayList<>();
  4363.             if(addSelezioneVuota){
  4364.                 ruoli.add("-");
  4365.             }
  4366.             ruoli.addAll(ruoliDaFarScegliere);
  4367.            
  4368.             de = new DataElement();
  4369.             de.setLabel(labelParametro);
  4370.             de.setValue(nome);
  4371.             if (tipoOp.equals(TipoOperazione.ADD) || enableUpdate) {
  4372.                 de.setType(DataElementType.SELECT);
  4373.                 de.setValues(ruoli);
  4374.                 de.setSelected(nome);
  4375.             } else {
  4376.                 de.setType(DataElementType.TEXT);
  4377.             }
  4378.             de.setName(CostantiControlStation.PARAMETRO_RUOLO);
  4379.             de.setSize(this.getSize());
  4380.             dati.add(de);
  4381.         }
  4382.         else{
  4383.             if(addMsgServiziApplicativoNonDisponibili){
  4384.                 if(allRuoli.size()>0){
  4385.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_ESISTONO_ULTERIORI_RUOLI_ASSOCIABILI);
  4386.                 }
  4387.                 else{
  4388.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_ESISTONO_RUOLI_ASSOCIABILI);
  4389.                 }
  4390.                 this.pd.disableEditMode();
  4391.             }
  4392.         }

  4393.         return dati;
  4394.     }
  4395.     public List<DataElement> addScopeToDati(TipoOperazione tipoOp,List<DataElement> dati,boolean enableUpdate, FiltroRicercaScope filtroScope, String nome,
  4396.             List<String> ruoliGiaConfigurati, boolean addSelezioneVuota, boolean addMsgServiziApplicativoNonDisponibili,
  4397.             boolean addTitoloSezione) throws DriverRegistroServiziException {
  4398.         return this.addScopeToDati(tipoOp, dati, enableUpdate, filtroScope, nome, ruoliGiaConfigurati,
  4399.                 addSelezioneVuota, addMsgServiziApplicativoNonDisponibili, CostantiControlStation.LABEL_PARAMETRO_SCOPE,
  4400.                 addTitoloSezione);
  4401.     }
  4402.     public List<DataElement> addScopeToDati(TipoOperazione tipoOp,List<DataElement> dati,boolean enableUpdate, FiltroRicercaScope filtroScope, String nome,
  4403.             List<String> scopeGiaConfigurati, boolean addSelezioneVuota, boolean addMsgServiziApplicativoNonDisponibili, String labelParametro,
  4404.             boolean addTitoloSezione) throws DriverRegistroServiziException {

  4405.         List<String> allRuoli = this.confCore.getAllScope(filtroScope);
  4406.         List<String> scopeDaFarScegliere = new ArrayList<>();
  4407.         if(scopeGiaConfigurati!=null && scopeGiaConfigurati.size()>0){
  4408.             for (String ruolo : allRuoli) {
  4409.                 if(scopeGiaConfigurati.contains(ruolo)==false){
  4410.                     scopeDaFarScegliere.add(ruolo);
  4411.                 }
  4412.             }
  4413.         }
  4414.         else{
  4415.             scopeDaFarScegliere.addAll(allRuoli);
  4416.         }
  4417.        
  4418.         // Nome
  4419.         if(scopeDaFarScegliere.size()>0){
  4420.            
  4421.             if(addTitoloSezione){
  4422.                 DataElement de = new DataElement();
  4423.                 de.setLabel(ScopeCostanti.LABEL_SCOPE);
  4424.                 de.setType(DataElementType.TITLE);
  4425.                 dati.add(de);
  4426.             }
  4427.            
  4428.             List<String> ruoli = new ArrayList<>();
  4429.             if(addSelezioneVuota){
  4430.                 ruoli.add("-");
  4431.             }
  4432.             ruoli.addAll(scopeDaFarScegliere);
  4433.            
  4434.             DataElement de = new DataElement();
  4435.             de.setLabel(labelParametro);
  4436.             de.setValue(nome);
  4437.             if (tipoOp.equals(TipoOperazione.ADD) || enableUpdate) {
  4438.                 de.setType(DataElementType.SELECT);
  4439.                 de.setValues(ruoli);
  4440.                 de.setSelected(nome);
  4441.             } else {
  4442.                 de.setType(DataElementType.TEXT);
  4443.             }
  4444.             de.setName(CostantiControlStation.PARAMETRO_SCOPE);
  4445.             de.setSize(this.getSize());
  4446.             dati.add(de);
  4447.         }
  4448.         else{
  4449.             if(addMsgServiziApplicativoNonDisponibili){
  4450.                 if(allRuoli.size()>0){
  4451.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_ESISTONO_ULTERIORI_SCOPE_ASSOCIABILI);
  4452.                 }
  4453.                 else{
  4454.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_ESISTONO_SCOPE_ASSOCIABILI);
  4455.                 }
  4456.                 this.pd.disableEditMode();
  4457.             }
  4458.         }

  4459.         return dati;
  4460.     }
  4461.    
  4462.     public boolean ruoloCheckData(TipoOperazione tipoOp, String nome, List<String> ruoli) throws DriverControlStationException {
  4463.         try {
  4464.            
  4465.             if(ruoli!=null && ruoli.contains(nome)){
  4466.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_IL_RUOLO_XX_E_GIA_STATO_ASSOCIATA_AL_SOGGETTO, nome));
  4467.                 return false;
  4468.             }

  4469.             return true;

  4470.         } catch (Exception e) {
  4471.             this.logError("Exception: " + e.getMessage(), e);
  4472.             throw new DriverControlStationException(e);
  4473.         }
  4474.     }
  4475.    
  4476.     public boolean scopeCheckData(TipoOperazione tipoOp, String nome, List<String> scopes) throws DriverControlStationException {
  4477.         try {
  4478.            
  4479.             if(scopes!=null && scopes.contains(nome)){
  4480.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_LO_SCOPE_XX_E_GIA_STATO_ASSOCIATA_AL_SOGGETTO, nome));
  4481.                 return false;
  4482.             }

  4483.             return true;

  4484.         } catch (Exception e) {
  4485.             this.logError("Exception: " + e.getMessage(), e);
  4486.             throw new DriverControlStationException(e);
  4487.         }
  4488.     }
  4489.    
  4490.     public void controlloAccessi(List<DataElement> dati) throws DriverControlStationException{
  4491.         DataElement de = new DataElement();
  4492.         de.setType(DataElementType.TITLE);
  4493.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI);
  4494.         dati.add(de);
  4495.     }
  4496.    
  4497.     public List<String> convertFromDataElementValue_parametroAutenticazioneList(String autenticazione, TipoAutenticazionePrincipal autenticazionePrincipal) throws DriverControlStationException{
  4498.         List<String> l = null;
  4499.        
  4500.         if(TipoAutenticazione.BASIC.equals(autenticazione)) {
  4501.            
  4502.             // posizione 0: clean
  4503.             String v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+0);
  4504.             if(v!=null && !"".equals(v)) {
  4505.                 l = new ArrayList<>();
  4506.                 l.add(v);
  4507.             }
  4508.            
  4509.         }
  4510.         else if(TipoAutenticazione.PRINCIPAL.equals(autenticazione)) {
  4511.                                
  4512.             if(autenticazionePrincipal==null) {
  4513.                 autenticazionePrincipal = TipoAutenticazionePrincipal.CONTAINER;    
  4514.             }
  4515.            
  4516.             switch (autenticazionePrincipal) {
  4517.             case CONTAINER:
  4518.             case INDIRIZZO_IP:
  4519.             case INDIRIZZO_IP_X_FORWARDED_FOR:
  4520.                 break;
  4521.             case HEADER:
  4522.             case FORM:
  4523.                
  4524.                 // posizione 0: nome
  4525.                 String v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+0);
  4526.                 if(v!=null && !"".equals(v)) {
  4527.                     l = new ArrayList<>();
  4528.                     l.add(v);
  4529.                 }
  4530.                
  4531.                 // posizione 1: clean
  4532.                 if(l==null) {
  4533.                     break;
  4534.                 }
  4535.                 v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+1);
  4536.                 if(v!=null && !"".equals(v)) {
  4537.                     l.add(v);
  4538.                 }

  4539.                 break;
  4540.             case URL:
  4541.                
  4542.                 // posizione 0: pattern
  4543.                 v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+0);
  4544.                 if(v!=null && !"".equals(v)) {
  4545.                     l = new ArrayList<>();
  4546.                     l.add(v);
  4547.                 }
  4548.                 break;
  4549.             case TOKEN:
  4550.                
  4551.                 // posizione 0: tipoToken
  4552.                 v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+0);
  4553.                 if(v!=null && !"".equals(v)) {
  4554.                     l = new ArrayList<>();
  4555.                     l.add(v);
  4556.                 }
  4557.                
  4558.                 // posizione 1: nome claim proprietario
  4559.                 if(l==null) {
  4560.                     break;
  4561.                 }
  4562.                 v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+1);
  4563.                 if(v!=null && !"".equals(v)) {
  4564.                     l.add(v);
  4565.                 }

  4566.                 break;
  4567.             }
  4568.         }
  4569.         else if(TipoAutenticazione.APIKEY.equals(autenticazione)) {
  4570.            
  4571.             // DATA ELEMENT
  4572.             // 0: appId (CHECKBOX)
  4573.             // 1: posizione (MULTI_SELECT)
  4574.             // 2: useOAS3Names (CHECKBOX)
  4575.             // 3: forwardApiKey (CHECKBOX)
  4576.             // 4: queryParameterApiKey (TEXT_EDIT)
  4577.             // 5: headerApiKey (TEXT_EDIT)
  4578.             // 6: cookieApiKey (TEXT_EDIT)
  4579.             // 7: forwardAppId (CHECKBOX)
  4580.             // 8: queryParameterAppId (TEXT_EDIT)
  4581.             // 9: headerAppId (TEXT_EDIT)
  4582.             // 10: cookieAppId (TEXT_EDIT)
  4583.            
  4584.             l = new ArrayList<>();
  4585.            
  4586.             // posizione 0: appId
  4587.             String v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+0);
  4588.             l.add(ServletUtils.isCheckBoxEnabled(v)+"");
  4589.            
  4590.             // posizione 1: queryParameter
  4591.             // posizione 2: header
  4592.             // posizione 3: cookie
  4593.             String [] vPos = this.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+1);
  4594.             boolean query = false;
  4595.             boolean header = false;
  4596.             boolean cookie = false;
  4597.             if(vPos!=null && vPos.length>0) {
  4598.                 for (int i = 0; i < vPos.length; i++) {
  4599.                     String sel = vPos[i];
  4600.                     if(ParametriAutenticazioneApiKey.QUERY_PARAMETER.equals(sel)) {
  4601.                         query = true;
  4602.                     }
  4603.                     else if(ParametriAutenticazioneApiKey.HEADER.equals(sel)) {
  4604.                         header = true;
  4605.                     }
  4606.                     else if(ParametriAutenticazioneApiKey.COOKIE.equals(sel)) {
  4607.                         cookie = true;
  4608.                     }
  4609.                 }
  4610.             }
  4611.             l.add(query+"");
  4612.             l.add(header+"");
  4613.             l.add(cookie+"");
  4614.            
  4615.             // posizione 4: useOAS3Names
  4616.             v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+2);
  4617.             l.add(ServletUtils.isCheckBoxEnabled(v)+"");
  4618.            
  4619.             // posizione 5: cleanApiKey
  4620.             String forwardApiKey = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+3);
  4621.             if (ServletUtils.isCheckBoxEnabled(forwardApiKey)) {
  4622.                 l.add(false+"");
  4623.             }
  4624.             else {
  4625.                 l.add(true+"");
  4626.             }

  4627.             // posizione 6: cleanAppId
  4628.             String forwardAppId = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+7);
  4629.             if (ServletUtils.isCheckBoxEnabled(forwardAppId)) {
  4630.                 l.add(false+"");
  4631.             }
  4632.             else {
  4633.                 l.add(true+"");
  4634.             }

  4635.             // posizione 7: queryParameterApiKey
  4636.             v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+4);
  4637.             l.add(v);
  4638.            
  4639.             // posizione 8: headerApiKey
  4640.             v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+5);
  4641.             l.add(v);
  4642.            
  4643.             // posizione 9: cookieApiKey
  4644.             v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+6);
  4645.             l.add(v);
  4646.            
  4647.             // posizione 10: queryParameterAppId
  4648.             v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+8);
  4649.             l.add(v);
  4650.            
  4651.             // posizione 11: headerAppId
  4652.             v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+9);
  4653.             l.add(v);
  4654.            
  4655.             // posizione 12: cookieAppId
  4656.             v = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+10);
  4657.             l.add(v);
  4658.         }
  4659.        
  4660.         return l;
  4661.     }
  4662.    
  4663.     public void controlloAccessiAdd(List<DataElement> dati, TipoOperazione tipoOperazione, String statoControlloAccessiAdd, boolean forceAutenticato) {
  4664.        
  4665.         if(!this.isModalitaCompleta() && TipoOperazione.ADD.equals(tipoOperazione)) {
  4666.            
  4667.             if(!forceAutenticato) {
  4668.                 DataElement de = new DataElement();
  4669.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI );
  4670.                 de.setType(DataElementType.TITLE);
  4671.                 dati.add(de);
  4672.             }
  4673.            
  4674.             DataElement de = new DataElement();
  4675.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_STATO);
  4676.             de.setName(CostantiControlStation.PARAMETRO_PORTE_CONTROLLO_ACCESSI_STATO);
  4677.             if(forceAutenticato) {
  4678.                 de.setType(DataElementType.HIDDEN);
  4679.                 de.setValue(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_STATO_AUTENTICATO);
  4680.             }
  4681.             else {
  4682.                 de.setType(DataElementType.SELECT);
  4683.                 de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_PORTE_CONTROLLO_ACCESSI_STATO);
  4684.                 de.setLabels(CostantiControlStation.SELECT_VALUES_PARAMETRO_PORTE_CONTROLLO_ACCESSI_STATO);
  4685.                 de.setSelected(statoControlloAccessiAdd);
  4686.             }
  4687.             dati.add(de);
  4688.            
  4689.         }
  4690.        
  4691.     }
  4692.            
  4693.    
  4694.     public void controlloAccessiAutenticazione(List<DataElement> dati, TipoOperazione tipoOperazione, String servletChiamante, Object oggetto, String protocolloParam,
  4695.             String autenticazione, String autenticazioneCustom, String autenticazioneOpzionale,
  4696.             TipoAutenticazionePrincipal autenticazionePrincipal,  List<String> autenticazioneParametroList,
  4697.             boolean confPers, boolean isSupportatoAutenticazioneSoggetti,boolean isPortaDelegata,
  4698.             String gestioneToken,String gestioneTokenPolicy,String autenticazioneTokenIssuer,String autenticazioneTokenClientId,String autenticazioneTokenSubject,String autenticazioneTokenUsername,String autenticazioneTokenEMail,
  4699.             boolean oldAutenticazioneCustom, String urlAutenticazioneCustomProperties, int numAutenticazioneCustomPropertiesList,
  4700.             boolean forceHttps, boolean forceDisableOptional) throws DriverControlStationException{
  4701.        
  4702.         boolean tokenAbilitato = StatoFunzionalita.ABILITATO.getValue().equalsIgnoreCase(gestioneToken) &&
  4703.                 gestioneTokenPolicy != null && !gestioneTokenPolicy.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO);
  4704.        
  4705.         boolean mostraSezione = !tipoOperazione.equals(TipoOperazione.ADD) ||
  4706.                 (isPortaDelegata ? this.core.isEnabledAutenticazione_generazioneAutomaticaPorteDelegate() : this.core.isEnabledAutenticazione_generazioneAutomaticaPorteApplicative());
  4707.        
  4708.         boolean allHidden = false;
  4709.         if(!this.isModalitaCompleta() && TipoOperazione.ADD.equals(tipoOperazione)) {
  4710.             allHidden = true;
  4711.         }
  4712.        
  4713.         String protocollo = protocolloParam;
  4714.         if((protocollo==null || "".equals(protocollo)) && oggetto!=null){
  4715.             if(isPortaDelegata){
  4716.                 PortaDelegata pd = (PortaDelegata) oggetto;
  4717.                 if(pd!=null && pd.getServizio()!=null && pd.getServizio().getTipo()!=null) {
  4718.                     try {
  4719.                         protocollo = this.apsCore.getProtocolloAssociatoTipoServizio(pd.getServizio().getTipo());
  4720.                     }catch(Exception e) {
  4721.                         throw new DriverControlStationException(e.getMessage(),e);
  4722.                     }
  4723.                 }
  4724.             }
  4725.             else {
  4726.                 PortaApplicativa pa = (PortaApplicativa) oggetto;
  4727.                 if(pa!=null && pa.getServizio()!=null && pa.getServizio().getTipo()!=null) {
  4728.                     try {
  4729.                         protocollo = this.apsCore.getProtocolloAssociatoTipoServizio(pa.getServizio().getTipo());
  4730.                     }catch(Exception e) {
  4731.                         throw new DriverControlStationException(e.getMessage(),e);
  4732.                     }
  4733.                 }
  4734.             }
  4735.         }
  4736.        
  4737.         boolean existsAutorizzazioniPuntuali = false;
  4738.         if(oggetto!=null) {
  4739.             if(isPortaDelegata){
  4740.                 PortaDelegata pdObject = (PortaDelegata) oggetto;
  4741.                 if(pdObject!=null && pdObject.sizeServizioApplicativoList()>0) {
  4742.                     existsAutorizzazioniPuntuali = true;
  4743.                 }
  4744.             }
  4745.             else {
  4746.                 PortaApplicativa pa = (PortaApplicativa) oggetto;
  4747.                 if(pa!=null &&
  4748.                     (
  4749.                             (pa.getSoggetti()!=null && pa.getSoggetti().sizeSoggettoList()>0)
  4750.                             ||
  4751.                             (pa.getServiziApplicativiAutorizzati()!=null && pa.getServiziApplicativiAutorizzati().sizeServizioApplicativoList()>0))
  4752.                     ){
  4753.                     existsAutorizzazioniPuntuali = true;
  4754.                 }
  4755.             }
  4756.         }
  4757.        
  4758.         boolean modipa = this.isProfiloModIPA(protocollo);
  4759.        
  4760.         if(forceHttps) {
  4761.             autenticazione = TipoAutenticazione.SSL.getValue();
  4762.         }
  4763.         if(forceDisableOptional) {
  4764.             // Fix: se l'autenticazioneOpzionale risulta abilitata e sono nella servlet di cambio controllo degli accessi, significa che siamo arrivati da una condizione in cui l'erogazione era stata creata con API C01 e poi successivamente l'API è stata modificata in C02
  4765.             if(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONTROLLO_ACCESSI.equals(servletChiamante) && ServletUtils.isCheckBoxEnabled(autenticazioneOpzionale)) {
  4766.                 forceDisableOptional=false;
  4767.             }
  4768.             else {
  4769.                 autenticazioneOpzionale = Costanti.CHECK_BOX_DISABLED;
  4770.             }
  4771.         }
  4772.                
  4773.         if(mostraSezione){
  4774.            
  4775.             if(tokenAbilitato) {

  4776.                 if(!allHidden) {
  4777.                     DataElement de = new DataElement();
  4778.                     de.setType(DataElementType.SUBTITLE); //SUBTITLE);
  4779.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE_TOKEN_CLAIMS);
  4780.                     dati.add(de);
  4781.                 }
  4782.                
  4783.                 DataElement de = new DataElement();
  4784.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_ISSUER);
  4785.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_ISSUER);
  4786.                 if(allHidden) {
  4787.                     de.setType(DataElementType.HIDDEN);
  4788.                     de.setValue(ServletUtils.isCheckBoxEnabled(autenticazioneTokenIssuer)+"");
  4789.                 }
  4790.                 else {
  4791.                     de.setType(DataElementType.CHECKBOX);
  4792.                     de.setSelected(ServletUtils.isCheckBoxEnabled(autenticazioneTokenIssuer));
  4793.                 }
  4794.                 dati.add(de);
  4795.                
  4796.                 de = new DataElement();
  4797.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_CLIENT_ID);
  4798.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_CLIENT_ID);
  4799.                 if(allHidden) {
  4800.                     de.setType(DataElementType.HIDDEN);
  4801.                     de.setValue(ServletUtils.isCheckBoxEnabled(autenticazioneTokenClientId)+"");
  4802.                 }
  4803.                 else {
  4804.                     de.setType(DataElementType.CHECKBOX);
  4805.                     de.setSelected(ServletUtils.isCheckBoxEnabled(autenticazioneTokenClientId));
  4806.                 }
  4807.                 dati.add(de);
  4808.                
  4809.                 de = new DataElement();
  4810.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_SUBJECT);
  4811.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_SUBJECT);
  4812.                 if(allHidden) {
  4813.                     de.setType(DataElementType.HIDDEN);
  4814.                     de.setValue(ServletUtils.isCheckBoxEnabled(autenticazioneTokenSubject)+"");
  4815.                 }
  4816.                 else {
  4817.                     de.setType(DataElementType.CHECKBOX);
  4818.                     de.setSelected(ServletUtils.isCheckBoxEnabled(autenticazioneTokenSubject));
  4819.                 }
  4820.                 dati.add(de);
  4821.                
  4822.                 de = new DataElement();
  4823.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_USERNAME);
  4824.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_USERNAME);
  4825.                 if(allHidden) {
  4826.                     de.setType(DataElementType.HIDDEN);
  4827.                     de.setValue(ServletUtils.isCheckBoxEnabled(autenticazioneTokenUsername)+"");
  4828.                 }
  4829.                 else {
  4830.                     de.setType(DataElementType.CHECKBOX);
  4831.                     de.setSelected(ServletUtils.isCheckBoxEnabled(autenticazioneTokenUsername));
  4832.                 }
  4833.                 dati.add(de);
  4834.                
  4835.                 de = new DataElement();
  4836.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_MAIL);
  4837.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_MAIL);
  4838.                 if(allHidden) {
  4839.                     de.setType(DataElementType.HIDDEN);
  4840.                     de.setValue(ServletUtils.isCheckBoxEnabled(autenticazioneTokenEMail)+"");
  4841.                 }
  4842.                 else {
  4843.                     de.setType(DataElementType.CHECKBOX);
  4844.                     de.setSelected(ServletUtils.isCheckBoxEnabled(autenticazioneTokenEMail));
  4845.                 }
  4846.                 dati.add(de);
  4847.                
  4848.             }
  4849.            
  4850.             boolean addTitle = !allHidden && isSupportatoAutenticazioneSoggetti;
  4851.             if(addTitle) {
  4852.                 DataElement de = new DataElement();
  4853.                 de.setType(DataElementType.TITLE); //SUBTITLE);
  4854.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TITLE);
  4855.                 if(modipa && !isPortaDelegata) {
  4856.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE+" "+CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE_CANALE);
  4857.                 }
  4858.                 else {
  4859.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE+" "+CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE_TRASPORTO);
  4860.                 }
  4861.                 de.setStatoAperturaSezioni(STATO_APERTURA_SEZIONI.APERTO);
  4862.                 dati.add(de);
  4863.             }
  4864.            
  4865.             if(isSupportatoAutenticazioneSoggetti){
  4866.                
  4867. //              if(!allHidden) {
  4868. //                  DataElement de = new DataElement();
  4869. //                  de.setType(DataElementType.SUBTITLE); //SUBTITLE);
  4870. //                  de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE_TRASPORTO);
  4871. //                  dati.add(de);
  4872. //              }
  4873.            
  4874.                 List<String> autenticazioneValues = TipoAutenticazione.getValues();
  4875.                 List<String> autenticazioneLabels = TipoAutenticazione.getLabels();
  4876.                 int totEl = autenticazioneValues.size();
  4877.                 if (confPers)
  4878.                     totEl++;
  4879.                 String[] tipoAutenticazione = new String[totEl];
  4880.                 String[] labelTipoAutenticazione = new String[totEl];
  4881.                 for (int i = 0; i < autenticazioneValues.size(); i++) {
  4882.                     tipoAutenticazione[i]=autenticazioneValues.get(i);
  4883.                     labelTipoAutenticazione[i]=autenticazioneLabels.get(i);
  4884.                 }
  4885.                 if (confPers ){
  4886.                     tipoAutenticazione[totEl-1] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM;
  4887.                     labelTipoAutenticazione[totEl-1] = CostantiControlStation.DEFAULT_LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM;
  4888.                 }
  4889.                 DataElement de = new DataElement();
  4890.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE);
  4891.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE);
  4892.                 if(allHidden) {
  4893.                     de.setType(DataElementType.HIDDEN);
  4894.                     de.setValue(autenticazione);
  4895.                 }
  4896.                 else {
  4897.                     if(forceHttps) {
  4898.                         de.setType(DataElementType.HIDDEN);
  4899.                         de.setValue(autenticazione);
  4900.                         dati.add(de);
  4901.                        
  4902.                         de = new DataElement();
  4903.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE);
  4904.                         de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  4905.                         de.setType(DataElementType.TEXT);
  4906.                         de.setValue(TipoAutenticazione.SSL.getLabel());
  4907.                         de.setValoreDefault(TipoAutenticazione.DISABILITATO.getLabel());
  4908.                     }
  4909.                     else if(existsAutorizzazioniPuntuali) {
  4910.                         de.setType(DataElementType.HIDDEN);
  4911.                         de.setValue(autenticazione);
  4912.                         dati.add(de);
  4913.                        
  4914.                         de = new DataElement();
  4915.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE);
  4916.                         de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  4917.                         de.setType(DataElementType.TEXT);
  4918.                         String labelAutenticazione = null;
  4919.                         for (int i = 0; i < tipoAutenticazione.length; i++) {
  4920.                             if(autenticazione!=null && autenticazione.equals(tipoAutenticazione[i])) {
  4921.                                 labelAutenticazione = labelTipoAutenticazione[i];
  4922.                                 break;
  4923.                             }
  4924.                         }
  4925.                         de.setValue(labelAutenticazione!=null ? labelAutenticazione : autenticazione);
  4926.                         de.setValoreDefault(TipoAutenticazione.DISABILITATO.getLabel());
  4927.                     }
  4928.                     else {
  4929.                         de.setType(DataElementType.SELECT);
  4930.                         de.setValues(tipoAutenticazione);
  4931.                         de.setLabels(labelTipoAutenticazione);
  4932.                         de.setPostBack(true);
  4933.                         de.setSelected(autenticazione);
  4934.                         de.setValoreDefaultSelect(TipoAutenticazione.DISABILITATO.getValue());
  4935.                     }
  4936.                 }
  4937.                 dati.add(de);
  4938.        
  4939.                 String tipoAutenticazioneCustom = isPortaDelegata ? Filtri.FILTRO_RUOLO_VALORE_FRUIZIONE : Filtri.FILTRO_RUOLO_VALORE_EROGAZIONE;
  4940.                 boolean autenticazioneCustomHidden = (allHidden || (autenticazione == null) || (!autenticazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM)));
  4941.                 this.addCustomField(TipoPlugin.AUTENTICAZIONE,
  4942.                         tipoAutenticazioneCustom,
  4943.                         null,
  4944.                         CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE,
  4945.                         CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM,
  4946.                         CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM,
  4947.                         autenticazioneCustom, autenticazioneCustomHidden, dati,
  4948.                         false);    
  4949.                 /**
  4950.                 de = new DataElement();
  4951.                 de.setLabel("");
  4952.                 if(allHidden) {
  4953.                     de.setType(DataElementType.HIDDEN);
  4954.                 }
  4955.                 else if (autenticazione == null ||
  4956.                         !autenticazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM)) {
  4957.                     de.setType(DataElementType.HIDDEN);
  4958.                 }else {
  4959.                     de.setType(DataElementType.TEXT_EDIT);
  4960.                     de.setRequired(true);
  4961.                 }
  4962.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM);
  4963.                 de.setValue(autenticazioneCustom);
  4964.                 dati.add(de);
  4965.                 */
  4966.                
  4967.                 // se ho salvato il tipo custom faccio vedere il link alle proprieta'
  4968.                 if(autenticazione != null && autenticazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM)) {
  4969.                     if(oldAutenticazioneCustom) {
  4970.                         Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  4971.                         de = new DataElement();
  4972.                         de.setType(DataElementType.LINK);
  4973.                         de.setUrl(urlAutenticazioneCustomProperties);
  4974.                         String labelCustomProperties = CostantiControlStation.LABEL_PARAMETRO_AUTENTICAZIONE_CUSTOM_PROPERTIES;
  4975.                         if (contaListe) {
  4976.                             ServletUtils.setDataElementCustomLabel(de,labelCustomProperties,Long.valueOf(numAutenticazioneCustomPropertiesList));
  4977.                         } else {
  4978.                             ServletUtils.setDataElementCustomLabel(de,labelCustomProperties);
  4979.                         }
  4980.                         dati.add(de);
  4981.                     }
  4982.                 }
  4983.                        
  4984.                 try {
  4985.                     if(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE.equals(this.getPostBackElementName())) {
  4986.                         autenticazioneParametroList = null;
  4987.                     }
  4988.                 }catch(Exception e) {
  4989.                     // ignore
  4990.                 }
  4991.                
  4992.                 boolean addOpzionale = true;
  4993.                
  4994.                 if(TipoAutenticazione.BASIC.equals(autenticazione)) {
  4995.                    
  4996.                     // posizione 0: clean
  4997.                     String autenticazioneParametro = null;
  4998.                     if(autenticazioneParametroList!=null && !autenticazioneParametroList.isEmpty()) {
  4999.                         autenticazioneParametro = autenticazioneParametroList.get(0);
  5000.                     }
  5001.                    
  5002.                     de = new DataElement();
  5003.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_BASIC_FORWARD);
  5004.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+0);
  5005.                     if(allHidden) {
  5006.                         de.setType(DataElementType.HIDDEN);
  5007.                         de.setValue(ServletUtils.isCheckBoxEnabled(autenticazioneParametro)+"");
  5008.                     }
  5009.                     else {
  5010.                         de.setType(DataElementType.CHECKBOX);
  5011.                         if(autenticazioneParametro==null || "".equals(autenticazioneParametro)) {
  5012.                             autenticazioneParametro = Costanti.CHECK_BOX_DISABLED;
  5013.                         }
  5014.                         de.setSelected(ServletUtils.isCheckBoxEnabled(autenticazioneParametro));
  5015.                     }
  5016.                     dati.add(de);
  5017.                 }
  5018.                 else if(TipoAutenticazione.PRINCIPAL.equals(autenticazione)) {
  5019.                                        
  5020.                     List<String> autenticazionePrincipalValues = TipoAutenticazionePrincipal.getValues(tokenAbilitato);
  5021.                     List<String> autenticazionePrincipalLabels = TipoAutenticazionePrincipal.getLabels(tokenAbilitato);
  5022.                     de = new DataElement();
  5023.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TIPO);
  5024.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TIPO);
  5025.                     if(autenticazionePrincipal==null) {
  5026.                         autenticazionePrincipal = TipoAutenticazionePrincipal.CONTAINER;    
  5027.                     }
  5028.                     if(allHidden) {
  5029.                         de.setType(DataElementType.HIDDEN);
  5030.                         de.setValue(autenticazionePrincipal.getValue());
  5031.                     }
  5032.                     else {
  5033.                         de.setType(DataElementType.SELECT);
  5034.                         de.setValues(autenticazionePrincipalValues);
  5035.                         de.setLabels(autenticazionePrincipalLabels);
  5036.                         de.setPostBack(true);
  5037.                         de.setSelected(autenticazionePrincipal.getValue());
  5038.                     }
  5039.                     dati.add(de);
  5040.                    
  5041.                     switch (autenticazionePrincipal) {
  5042.                     case CONTAINER:
  5043.                     case INDIRIZZO_IP:
  5044.                     case INDIRIZZO_IP_X_FORWARDED_FOR:
  5045.                         break;
  5046.                     case HEADER:
  5047.                     case FORM:
  5048.                        
  5049.                         // posizione 0: nome
  5050.                         String autenticazioneParametro = null;
  5051.                         if(autenticazioneParametroList!=null && !autenticazioneParametroList.isEmpty()) {
  5052.                             autenticazioneParametro = autenticazioneParametroList.get(0);
  5053.                         }
  5054.                         de = new DataElement();
  5055.                         if(TipoAutenticazionePrincipal.HEADER.equals(autenticazionePrincipal)) {
  5056.                             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_HEADER);
  5057.                         }
  5058.                         else {
  5059.                             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_FORM);
  5060.                         }
  5061.                         de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+0);
  5062.                         de.setValue(autenticazioneParametro);
  5063.                         if(allHidden) {
  5064.                             de.setType(DataElementType.HIDDEN);
  5065.                         }
  5066.                         else {
  5067.                             de.setType(DataElementType.TEXT_EDIT);
  5068.                             de.setRequired(true);
  5069.                         }
  5070.                         dati.add(de);
  5071.                        
  5072.                         // posizione 1: clean
  5073.                         if(autenticazioneParametroList!=null && !autenticazioneParametroList.isEmpty() &&
  5074.                                 autenticazioneParametroList.size()>1) {
  5075.                             autenticazioneParametro = autenticazioneParametroList.get(1);
  5076.                         }
  5077.                         de = new DataElement();
  5078.                         de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+1);
  5079.                         if(TipoAutenticazionePrincipal.HEADER.equals(autenticazionePrincipal)) {
  5080.                             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_FORWARD_HEADER);
  5081.                         }else {
  5082.                             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_FORWARD_FORM);
  5083.                         }
  5084.                         if(autenticazioneParametro==null || "".equals(autenticazioneParametro)) {
  5085.                             autenticazioneParametro = Costanti.CHECK_BOX_DISABLED;
  5086.                         }
  5087.                         if(allHidden) {
  5088.                             de.setType(DataElementType.HIDDEN);
  5089.                             de.setValue(autenticazioneParametro);
  5090.                         }
  5091.                         else {
  5092.                             de.setType(DataElementType.CHECKBOX);
  5093.                             de.setSelected(ServletUtils.isCheckBoxEnabled(autenticazioneParametro));
  5094.                         }
  5095.                         dati.add(de);
  5096.                        
  5097.                         break;
  5098.                        
  5099.                     case URL:
  5100.                        
  5101.                         // posizione 0: pattern
  5102.                         autenticazioneParametro = null;
  5103.                         if(autenticazioneParametroList!=null && !autenticazioneParametroList.isEmpty()) {
  5104.                             autenticazioneParametro = autenticazioneParametroList.get(0);
  5105.                         }
  5106.                         de = new DataElement();
  5107.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_ESPRESSIONE);
  5108.                         de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+0);
  5109.                         de.setValue(autenticazioneParametro);
  5110.                         if(allHidden) {
  5111.                             de.setType(DataElementType.HIDDEN);
  5112.                         }
  5113.                         else {
  5114.                             de.setType(DataElementType.TEXT_AREA);
  5115.                             de.setRequired(true);
  5116.                         }
  5117.                         dati.add(de);
  5118.                        
  5119.                         break;
  5120.                        
  5121.                     case TOKEN:
  5122.                        
  5123.                         // posizione 0: tipoToken
  5124.                         autenticazioneParametro = null;
  5125.                         if(autenticazioneParametroList!=null && !autenticazioneParametroList.isEmpty()) {
  5126.                             autenticazioneParametro = autenticazioneParametroList.get(0);
  5127.                         }
  5128.                         de = new DataElement();
  5129.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TOKEN_CLAIM);
  5130.                         de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+0);
  5131.                         de.setValue(autenticazioneParametro);
  5132.                         if(allHidden) {
  5133.                             de.setType(DataElementType.HIDDEN);
  5134.                         }
  5135.                         else {
  5136.                             de.setType(DataElementType.SELECT);
  5137.                            
  5138.                             List<String> values = new ArrayList<>();
  5139.                             /**values.add(ParametriAutenticazionePrincipal.TOKEN_CLAIM_ISSUER);*/
  5140.                             values.add(ParametriAutenticazionePrincipal.TOKEN_CLAIM_SUBJECT);
  5141.                             values.add(ParametriAutenticazionePrincipal.TOKEN_CLAIM_CLIENT_ID);
  5142.                             values.add(ParametriAutenticazionePrincipal.TOKEN_CLAIM_EMAIL);
  5143.                             values.add(ParametriAutenticazionePrincipal.TOKEN_CLAIM_USERNAME);
  5144.                             List<String> labels = new ArrayList<>();
  5145.                             labels.addAll(values);
  5146.                             values.add(ParametriAutenticazionePrincipal.TOKEN_CLAIM_CUSTOM);
  5147.                             labels.add(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TOKEN_CLAIM_PERSONALIZZATO);
  5148.                            
  5149.                             de.setValues(values);
  5150.                             de.setLabels(labels);
  5151.                             de.setSelected(autenticazioneParametro);
  5152.                             de.setRequired(true);
  5153.                             de.setPostBack(true);
  5154.                         }
  5155.                         dati.add(de);
  5156.                        
  5157.                         // posizione 1: nome claim proprietario
  5158.                         boolean claimProprietario = ParametriAutenticazionePrincipal.TOKEN_CLAIM_CUSTOM.equals(autenticazioneParametro);
  5159.                         if(claimProprietario) {
  5160.                             if(autenticazioneParametroList!=null && !autenticazioneParametroList.isEmpty() &&
  5161.                                     autenticazioneParametroList.size()>1) {
  5162.                                 autenticazioneParametro = autenticazioneParametroList.get(1);
  5163.                             }
  5164.                             else {
  5165.                                 autenticazioneParametro = null;
  5166.                             }
  5167.                             de = new DataElement();
  5168.                             de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+1);
  5169.                             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TOKEN_CLAIM_PERSONALIZZATO_NOME);
  5170.                             de.setValue(autenticazioneParametro);
  5171.                             if(allHidden) {
  5172.                                 de.setType(DataElementType.HIDDEN);
  5173.                             }
  5174.                             else {
  5175.                                 de.setType(DataElementType.TEXT_EDIT);
  5176.                                 de.setRequired(true);
  5177.                             }
  5178.                             dati.add(de);
  5179.                         }
  5180.                        
  5181.                         break;
  5182.                     }
  5183.                 }
  5184.                 else if(TipoAutenticazione.APIKEY.equals(autenticazione)) {
  5185.                    
  5186.                     ApiKeyState apiKeyState = new ApiKeyState(autenticazioneParametroList);
  5187.                                        
  5188.                     // 0: appId (CHECKBOX)
  5189.                     // 1: posizione (MULTI_SELECT)
  5190.                     // 2: useOAS3Names (CHECKBOX)
  5191.                     // 3: forwardApiKey (CHECKBOX)
  5192.                     // 4: queryParameterApiKey (TEXT_EDIT)
  5193.                     // 5: headerApiKey (TEXT_EDIT)
  5194.                     // 6: cookieApiKey (TEXT_EDIT)
  5195.                     // 7: forwardAppId (CHECKBOX)
  5196.                     // 8: queryParameterAppId (TEXT_EDIT)
  5197.                     // 9: headerAppId (TEXT_EDIT)
  5198.                     // 10: cookieAppId (TEXT_EDIT)
  5199.                    
  5200.                     // appId                
  5201.                     de = new DataElement();
  5202.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+0);
  5203.                     de.setValue(apiKeyState.appId);
  5204.                     if(allHidden) {
  5205.                         de.setType(DataElementType.HIDDEN);
  5206.                     }
  5207.                     else {
  5208.                         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID);
  5209.                         de.setType(DataElementType.CHECKBOX);
  5210.                         de.setSelected(apiKeyState.appIdSelected);
  5211.                         de.setPostBack(true);
  5212.                     }
  5213.                     dati.add(de);
  5214.                    
  5215.                     // opzionale
  5216.                     addOpzionale(dati, allHidden, forceDisableOptional, autenticazioneOpzionale, autenticazione);
  5217.                     addOpzionale = false;
  5218.                    
  5219.                     // posizione
  5220.                     de = new DataElement();
  5221.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+1);
  5222.                     if(allHidden) {
  5223.                         de.setType(DataElementType.HIDDEN);
  5224.                         de.setSelezionati(apiKeyState.posizioneSelected);
  5225.                     }
  5226.                     else {
  5227.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_APIKEY_POSIZIONE);
  5228.                         de.setType(DataElementType.MULTI_SELECT);
  5229.                         de.setSelezionati(apiKeyState.posizioneSelected);
  5230.                         de.setValues(apiKeyState.posizioneValues);
  5231.                         de.setLabels(apiKeyState.posizioneLabels);
  5232.                         de.setRows(3);
  5233.                         de.setPostBack(!apiKeyState.useOAS3NamesSelected);
  5234.                     }
  5235.                     dati.add(de);
  5236.                    
  5237.                     // useOAS3Names            
  5238.                     de = new DataElement();
  5239.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+2);
  5240.                     de.setValue(apiKeyState.useOAS3Names);
  5241.                     if(allHidden) {
  5242.                         de.setType(DataElementType.HIDDEN);
  5243.                     }
  5244.                     else {
  5245.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_APIKEY_NOMI_STANDARD_OAS3);
  5246.                         de.setType(DataElementType.CHECKBOX);
  5247.                         de.setSelected(apiKeyState.useOAS3NamesSelected);
  5248.                         de.setPostBack(true);
  5249.                     }
  5250.                     dati.add(de);
  5251.                    
  5252.                     // ** sezione apiKey **
  5253.                     if(!apiKeyState.useOAS3NamesSelected) {
  5254.                         de = new DataElement();
  5255.                         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY);
  5256.                         de.setType(DataElementType.SUBTITLE);
  5257.                         dati.add(de);
  5258.                     }
  5259.                    
  5260.                     // forwardApiKey
  5261.                     de = new DataElement();
  5262.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+3);
  5263.                     de.setValue(apiKeyState.forwardApiKey);
  5264.                     if(allHidden) {
  5265.                         de.setType(DataElementType.HIDDEN);
  5266.                     }
  5267.                     else {
  5268.                         if(apiKeyState.useOAS3NamesSelected) {
  5269.                             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_APIKEY_FORWARD_PREFIX+
  5270.                                     ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY);
  5271.                         }
  5272.                         else {
  5273.                             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_APIKEY_FORWARD);
  5274.                         }
  5275.                         de.setType(DataElementType.CHECKBOX);
  5276.                         de.setSelected(apiKeyState.forwardApiKeySelected);
  5277.                     }
  5278.                     dati.add(de);
  5279.                    
  5280.                     // queryParameterApiKey
  5281.                     de = new DataElement();
  5282.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+4);
  5283.                     de.setValue(apiKeyState.queryParameterApiKey);
  5284.                     if(allHidden || apiKeyState.useOAS3NamesSelected || !apiKeyState.queryParameterEnabled) {
  5285.                         de.setType(DataElementType.HIDDEN);
  5286.                     }
  5287.                     else {
  5288.                         de.setLabel(ModalitaIdentificazione.FORM_BASED.getLabel());
  5289.                         de.setType(DataElementType.TEXT_EDIT);
  5290.                         de.setValue(apiKeyState.queryParameterApiKey);
  5291.                         de.setRequired(true);
  5292.                     }
  5293.                     dati.add(de);
  5294.                    
  5295.                     // headerApiKey
  5296.                     de = new DataElement();
  5297.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+5);
  5298.                     de.setValue(apiKeyState.headerApiKey);
  5299.                     if(allHidden || apiKeyState.useOAS3NamesSelected || !apiKeyState.headerEnabled) {
  5300.                         de.setType(DataElementType.HIDDEN);
  5301.                     }
  5302.                     else {
  5303.                         de.setLabel(ModalitaIdentificazione.HEADER_BASED.getLabel());
  5304.                         de.setType(DataElementType.TEXT_EDIT);
  5305.                         de.setValue(apiKeyState.headerApiKey);
  5306.                         de.setRequired(true);
  5307.                     }
  5308.                     dati.add(de);
  5309.                    
  5310.                     // cookieApiKey
  5311.                     de = new DataElement();
  5312.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+6);
  5313.                     de.setValue(apiKeyState.cookieApiKey);
  5314.                     if(allHidden || apiKeyState.useOAS3NamesSelected || !apiKeyState.cookieEnabled) {
  5315.                         de.setType(DataElementType.HIDDEN);
  5316.                     }
  5317.                     else {
  5318.                         de.setLabel(ModalitaIdentificazione.COOKIE_BASED.getLabel());
  5319.                         de.setType(DataElementType.TEXT_EDIT);
  5320.                         de.setValue(apiKeyState.cookieApiKey);
  5321.                         de.setRequired(true);
  5322.                     }
  5323.                     dati.add(de);
  5324.                    
  5325.                    
  5326.                    
  5327.                     // ** sezione appId **
  5328.                     if(!apiKeyState.useOAS3NamesSelected && apiKeyState.appIdSelected) {
  5329.                         de = new DataElement();
  5330.                         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID);
  5331.                         de.setType(DataElementType.SUBTITLE);
  5332.                         dati.add(de);
  5333.                     }
  5334.                    
  5335.                     // forwardAppId
  5336.                     de = new DataElement();
  5337.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+7);
  5338.                     de.setValue(apiKeyState.forwardAppId);
  5339.                     if(allHidden || !apiKeyState.appIdSelected) {
  5340.                         de.setType(DataElementType.HIDDEN);
  5341.                     }
  5342.                     else {
  5343.                         if(apiKeyState.useOAS3NamesSelected) {
  5344.                             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_APIKEY_FORWARD_PREFIX+
  5345.                                     ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID);
  5346.                         }
  5347.                         else {
  5348.                             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_APIKEY_FORWARD);
  5349.                         }
  5350.                         de.setType(DataElementType.CHECKBOX);
  5351.                         de.setSelected(apiKeyState.forwardAppIdSelected);
  5352.                     }
  5353.                     dati.add(de);
  5354.                    
  5355.                     // queryParameterAppId
  5356.                     de = new DataElement();
  5357.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+8);
  5358.                     de.setValue(apiKeyState.queryParameterAppId);
  5359.                     if(allHidden || apiKeyState.useOAS3NamesSelected || !apiKeyState.queryParameterEnabled || !apiKeyState.appIdSelected) {
  5360.                         de.setType(DataElementType.HIDDEN);
  5361.                     }
  5362.                     else {
  5363.                         de.setLabel(ModalitaIdentificazione.FORM_BASED.getLabel());
  5364.                         de.setType(DataElementType.TEXT_EDIT);
  5365.                         de.setValue(apiKeyState.queryParameterAppId);
  5366.                         de.setRequired(true);
  5367.                     }
  5368.                     dati.add(de);
  5369.                    
  5370.                     // headerAppId
  5371.                     de = new DataElement();
  5372.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+9);
  5373.                     de.setValue(apiKeyState.headerAppId);
  5374.                     if(allHidden || apiKeyState.useOAS3NamesSelected || !apiKeyState.headerEnabled || !apiKeyState.appIdSelected) {
  5375.                         de.setType(DataElementType.HIDDEN);
  5376.                     }
  5377.                     else {
  5378.                         de.setLabel(ModalitaIdentificazione.HEADER_BASED.getLabel());
  5379.                         de.setType(DataElementType.TEXT_EDIT);
  5380.                         de.setValue(apiKeyState.headerAppId);
  5381.                         de.setRequired(true);
  5382.                     }
  5383.                     dati.add(de);
  5384.                    
  5385.                     // cookieAppId
  5386.                     de = new DataElement();
  5387.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PARAMETRO_LIST+10);
  5388.                     de.setValue(apiKeyState.cookieAppId);
  5389.                     if(allHidden || apiKeyState.useOAS3NamesSelected || !apiKeyState.cookieEnabled || !apiKeyState.appIdSelected) {
  5390.                         de.setType(DataElementType.HIDDEN);
  5391.                     }
  5392.                     else {
  5393.                         de.setLabel(ModalitaIdentificazione.COOKIE_BASED.getLabel());
  5394.                         de.setType(DataElementType.TEXT_EDIT);
  5395.                         de.setValue(apiKeyState.cookieAppId);
  5396.                         de.setRequired(true);
  5397.                     }
  5398.                     dati.add(de);
  5399.                 }
  5400.                
  5401.                 if(addOpzionale) {
  5402.                     addOpzionale(dati, allHidden, forceDisableOptional, autenticazioneOpzionale, autenticazione);
  5403.                 }
  5404.                
  5405.             }
  5406.            
  5407.             if(addTitle) {
  5408.                 this.impostaAperturaTitle(dati, CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TITLE);
  5409.             }
  5410.            
  5411.         } else {
  5412.             DataElement de = new DataElement();
  5413.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE);
  5414.             de.setType(DataElementType.HIDDEN);
  5415.             de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE);
  5416.             de.setValue(TipoAutenticazione.DISABILITATO.getValue());
  5417.             dati.add(de);
  5418.         }
  5419.     }
  5420.    
  5421.     private void addOpzionale(List<DataElement> dati, boolean allHidden, boolean forceDisableOptional, String autenticazioneOpzionale, String autenticazione) {
  5422.         DataElement de = new DataElement();
  5423.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_OPZIONALE);
  5424.         de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_OPZIONALE);
  5425.         if(forceDisableOptional) {
  5426.             de.setType(DataElementType.HIDDEN);
  5427.             de.setSelected(ServletUtils.isCheckBoxEnabled(autenticazioneOpzionale));
  5428.         }
  5429.         else if(!allHidden && TipoAutenticazione.DISABILITATO.getValue().equals(autenticazione)==false){
  5430.             de.setType(DataElementType.CHECKBOX);
  5431.             de.setSelected(ServletUtils.isCheckBoxEnabled(autenticazioneOpzionale));
  5432.         }
  5433.         else{
  5434.             de.setType(DataElementType.HIDDEN);
  5435.             de.setValue("");
  5436.         }
  5437.         dati.add(de);
  5438.     }
  5439.    
  5440.    
  5441.     public void controlloAccessiGestioneToken(List<DataElement> dati, TipoOperazione tipoOperazione, String gestioneToken, String[] gestioneTokenPolicyLabels, String[] gestioneTokenPolicyValues,
  5442.             String gestioneTokenPolicy, String gestioneTokenOpzionale, String gestioneTokenValidazioneInput, String gestioneTokenIntrospection, String gestioneTokenUserInfo, String gestioneTokenForward,
  5443.             Object oggetto, String protocolloParam ,boolean isPortaDelegata, boolean forceGestioneToken) throws DriverControlStationException {
  5444.         this.controlloAccessiGestioneToken(dati, tipoOperazione, gestioneToken, gestioneTokenPolicyLabels, gestioneTokenPolicyValues,
  5445.                 gestioneTokenPolicy, gestioneTokenOpzionale, gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenForward,
  5446.                 oggetto, protocolloParam ,isPortaDelegata, forceGestioneToken, false);
  5447.     }
  5448.     public void controlloAccessiGestioneToken(List<DataElement> dati, TipoOperazione tipoOperazione, String gestioneToken, String[] gestioneTokenPolicyLabels, String[] gestioneTokenPolicyValues,
  5449.             String gestioneTokenPolicy, String gestioneTokenOpzionale, String gestioneTokenValidazioneInput, String gestioneTokenIntrospection, String gestioneTokenUserInfo, String gestioneTokenForward,
  5450.             Object oggetto, String protocolloParam ,boolean isPortaDelegata, boolean forceGestioneToken, boolean forceMostraSezione) throws DriverControlStationException {
  5451.        
  5452.         if(oggetto!=null) {
  5453.             // nop
  5454.         }
  5455.        
  5456.         boolean mostraSezione = !tipoOperazione.equals(TipoOperazione.ADD) ||
  5457.                 (isPortaDelegata ? this.core.isEnabledToken_generazioneAutomaticaPorteDelegate() : this.core.isEnabledToken_generazioneAutomaticaPorteApplicative());
  5458.        
  5459.         if(mostraSezione || forceMostraSezione) {
  5460.            
  5461.             DataElement de = new DataElement();
  5462.             de.setType(DataElementType.TITLE);
  5463.             de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TITLE);
  5464.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_GESTIONE_TOKEN);
  5465.             de.setStatoAperturaSezioni(STATO_APERTURA_SEZIONI.CHIUSO);
  5466.             dati.add(de);
  5467.            
  5468.             String [] valoriAbilitazione = {StatoFunzionalita.DISABILITATO.getValue(), StatoFunzionalita.ABILITATO.getValue()};
  5469.            
  5470.             // stato abilitazione
  5471.             de = new DataElement();
  5472.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN);
  5473.             de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN);
  5474.             if(forceGestioneToken) {
  5475.                 de.setType(DataElementType.HIDDEN);
  5476.                 de.setValue(gestioneToken);
  5477.             }
  5478.             else {
  5479.                 de.setType(DataElementType.SELECT);
  5480.                 de.setValues(valoriAbilitazione);
  5481.                 de.setValoreDefaultSelect(StatoFunzionalita.DISABILITATO.getValue());
  5482.                 de.setPostBack(true);
  5483.                 de.setSelected(gestioneToken);
  5484.             }
  5485.             dati.add(de);
  5486.            
  5487.             if(StatoFunzionalita.ABILITATO.getValue().equals(gestioneToken)){
  5488.                 // nome della policy da utilizzare
  5489.                 de = new DataElement();
  5490.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  5491.                 de.setType(DataElementType.SELECT);
  5492.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  5493.                 de.setValues(gestioneTokenPolicyValues);
  5494.                 de.setValues(gestioneTokenPolicyLabels);
  5495.                 de.setSelected(gestioneTokenPolicy);
  5496.                 de.setRequired(true);
  5497.                 if(forceGestioneToken) {
  5498.                     de.setValoreDefaultSelect(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO);
  5499.                 }
  5500.                 de.setPostBack(true);
  5501.                 dati.add(de);
  5502.                
  5503.                 if(gestioneTokenPolicy != null && !gestioneTokenPolicy.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO)) {
  5504.                    
  5505.                     Map<String, Properties> mappaDB = null;
  5506.                     try {
  5507.                         GenericProperties policySelezionata = this.confCore.getGenericProperties(gestioneTokenPolicy, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN,true);
  5508.                         mappaDB = this.confCore.readGestorePolicyTokenPropertiesConfiguration(policySelezionata.getId());
  5509.                     }catch(Exception e) {
  5510.                         throw new DriverControlStationException(e.getMessage(),e);
  5511.                     }
  5512.                        
  5513.                     de = new DataElement();
  5514.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_OPZIONALE);
  5515.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_OPZIONALE);
  5516.                     if(!isPortaDelegata && protocolloParam!=null && this.core.isProfiloModIPA(protocolloParam) &&
  5517.                             (!StatoFunzionalita.ABILITATO.getValue().equals(gestioneTokenOpzionale) )
  5518.                         ) {
  5519.                         if(forceGestioneToken) {
  5520.                             de.setType(DataElementType.HIDDEN);
  5521.                         }
  5522.                         else {
  5523.                             /** Ripristino la possibilità di impostarlo opzionale se non previsto l'utilizzo da pattern tramite indicazione sorgente */
  5524.                             de.setType(DataElementType.CHECKBOX);
  5525.                             de.setSelected(ServletUtils.isCheckBoxEnabled(gestioneTokenOpzionale));
  5526.                         }
  5527.                     }
  5528.                     else {
  5529.                         de.setType(DataElementType.CHECKBOX);
  5530.                         de.setSelected(ServletUtils.isCheckBoxEnabled(gestioneTokenOpzionale));
  5531.                     }
  5532.                     dati.add(de);
  5533.                    
  5534.                     // validazione input
  5535.                     de = new DataElement();
  5536.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  5537.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  5538.                     try {
  5539.                         if(TokenUtilities.isValidazioneEnabled(mappaDB)) {
  5540.                             if(forceGestioneToken && tipoOperazione.equals(TipoOperazione.ADD)) {
  5541.                                 de.setType(DataElementType.TEXT);
  5542.                                 de.setValue(gestioneTokenValidazioneInput);
  5543.                             }
  5544.                             else {
  5545.                                 de.setType(DataElementType.SELECT);
  5546.                                 de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA_CON_WARNING);
  5547.                                 de.setSelected(gestioneTokenValidazioneInput);
  5548.                                 de.setPostBack(true);
  5549.                             }
  5550.                         }else {
  5551.                             de.setType(DataElementType.HIDDEN);
  5552.                             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  5553.                         }
  5554.                     }catch(Exception e) {
  5555.                         throw new DriverControlStationException(e.getMessage(),e);
  5556.                     }
  5557.                     dati.add(de);
  5558.                    
  5559.                     // introspection
  5560.                     de = new DataElement();
  5561.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  5562.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  5563.                     try {
  5564.                         if(TokenUtilities.isIntrospectionEnabled(mappaDB)) {
  5565.                             if(forceGestioneToken && tipoOperazione.equals(TipoOperazione.ADD)) {
  5566.                                 de.setType(DataElementType.TEXT);
  5567.                                 de.setValue(gestioneTokenIntrospection);
  5568.                             }
  5569.                             else {
  5570.                                 de.setType(DataElementType.SELECT);
  5571.                                 de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA_CON_WARNING);
  5572.                                 de.setSelected(gestioneTokenIntrospection);
  5573.                                 de.setPostBack(true);
  5574.                             }
  5575.                         }else {
  5576.                             de.setType(DataElementType.HIDDEN);
  5577.                             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  5578.                         }
  5579.                     }catch(Exception e) {
  5580.                         throw new DriverControlStationException(e.getMessage(),e);
  5581.                     }
  5582.                     dati.add(de);
  5583.                    
  5584.                     // userInfo
  5585.                     de = new DataElement();
  5586.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  5587.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  5588.                     try {
  5589.                         if(TokenUtilities.isUserInfoEnabled(mappaDB)) {
  5590.                             if(forceGestioneToken && tipoOperazione.equals(TipoOperazione.ADD)) {
  5591.                                 de.setType(DataElementType.TEXT);
  5592.                                 de.setValue(gestioneTokenUserInfo);
  5593.                             }
  5594.                             else {
  5595.                                 de.setType(DataElementType.SELECT);
  5596.                                 de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA_CON_WARNING);
  5597.                                 de.setSelected(gestioneTokenUserInfo);
  5598.                                 de.setPostBack(true);
  5599.                             }
  5600.                         }else {
  5601.                             de.setType(DataElementType.HIDDEN);
  5602.                             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  5603.                         }
  5604.                     }catch(Exception e) {
  5605.                         throw new DriverControlStationException(e.getMessage(),e);
  5606.                     }
  5607.                     dati.add(de);
  5608.                    
  5609.                     // token forward
  5610.                     de = new DataElement();
  5611.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  5612.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  5613.                     try {
  5614.                         if(TokenUtilities.isTokenForwardEnabled(mappaDB)) {
  5615.                             if(forceGestioneToken && tipoOperazione.equals(TipoOperazione.ADD)) {
  5616.                                 de.setType(DataElementType.TEXT);
  5617.                                 de.setValue(gestioneTokenForward);
  5618.                             }
  5619.                             else {
  5620.                                 de.setType(DataElementType.SELECT);
  5621.                                 de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA);
  5622.                                 de.setSelected(gestioneTokenForward);
  5623.                                 de.setPostBack(true);
  5624.                             }
  5625.                         }else {
  5626.                             de.setType(DataElementType.HIDDEN);
  5627.                             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  5628.                         }
  5629.                     }catch(Exception e) {
  5630.                         throw new DriverControlStationException(e.getMessage(),e);
  5631.                     }
  5632.                     dati.add(de);
  5633.                 }
  5634.             }
  5635.            
  5636.             this.impostaAperturaTitle(dati, CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TITLE);
  5637.            
  5638.         } else {
  5639.             // stato abilitazione
  5640.             DataElement de = new DataElement();
  5641.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN);
  5642.             de.setType(DataElementType.HIDDEN);
  5643.             de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN);
  5644.             de.setValue(gestioneToken);
  5645.             dati.add(de);
  5646.            
  5647.             if(StatoFunzionalita.ABILITATO.getValue().equals(gestioneToken)){
  5648.                
  5649.                 // nome della policy da utilizzare
  5650.                 de = new DataElement();
  5651.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  5652.                 de.setType(DataElementType.HIDDEN);
  5653.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  5654.                 de.setValue(gestioneTokenPolicy);
  5655.                 dati.add(de);
  5656.                
  5657.                 if(gestioneTokenPolicy != null && !gestioneTokenPolicy.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO)) {
  5658.                    
  5659.                     Map<String, Properties> mappaDB = null;
  5660.                     try {
  5661.                         GenericProperties policySelezionata = this.confCore.getGenericProperties(gestioneTokenPolicy, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN,true);
  5662.                         mappaDB = this.confCore.readGestorePolicyTokenPropertiesConfiguration(policySelezionata.getId());
  5663.                     }catch(Exception e) {
  5664.                         throw new DriverControlStationException(e.getMessage(),e);
  5665.                     }
  5666.                    
  5667.                     de = new DataElement();
  5668.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_OPZIONALE);
  5669.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_OPZIONALE);
  5670.                     if(!isPortaDelegata && protocolloParam!=null && this.core.isProfiloModIPA(protocolloParam) &&
  5671.                             (!StatoFunzionalita.ABILITATO.getValue().equals(gestioneTokenOpzionale) )
  5672.                         ) {
  5673.                         de.setType(DataElementType.HIDDEN);
  5674.                     }
  5675.                     else {
  5676.                         de.setType(DataElementType.HIDDEN);
  5677.                         de.setValue(ServletUtils.isCheckBoxEnabled(gestioneTokenOpzionale) ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  5678.                     }
  5679.                     dati.add(de);
  5680.                    
  5681.                     // validazione input
  5682.                     de = new DataElement();
  5683.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  5684.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  5685.                     de.setType(DataElementType.HIDDEN);
  5686.                     try {
  5687.                         if(TokenUtilities.isValidazioneEnabled(mappaDB)) {
  5688.                             de.setValue(gestioneTokenValidazioneInput);
  5689.                         }else {
  5690.                             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  5691.                         }
  5692.                     }catch(Exception e) {
  5693.                         throw new DriverControlStationException(e.getMessage(),e);
  5694.                     }
  5695.                     dati.add(de);
  5696.                    
  5697.                     // introspection
  5698.                     de = new DataElement();
  5699.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  5700.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  5701.                     de.setType(DataElementType.HIDDEN);
  5702.                     try {
  5703.                         if(TokenUtilities.isIntrospectionEnabled(mappaDB)) {
  5704.                             de.setValue(gestioneTokenIntrospection);
  5705.                         }else {
  5706.                             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  5707.                         }
  5708.                     }catch(Exception e) {
  5709.                         throw new DriverControlStationException(e.getMessage(),e);
  5710.                     }
  5711.                     dati.add(de);
  5712.                    
  5713.                     // userInfo
  5714.                     de = new DataElement();
  5715.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  5716.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  5717.                     de.setType(DataElementType.HIDDEN);
  5718.                     try {
  5719.                         if(TokenUtilities.isUserInfoEnabled(mappaDB)) {
  5720.                             de.setValue(gestioneTokenUserInfo);
  5721.                         }else {
  5722.                             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  5723.                         }
  5724.                     }catch(Exception e) {
  5725.                         throw new DriverControlStationException(e.getMessage(),e);
  5726.                     }
  5727.                     dati.add(de);
  5728.                    
  5729.                     // token forward
  5730.                     de = new DataElement();
  5731.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  5732.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  5733.                     de.setType(DataElementType.HIDDEN);
  5734.                     try {
  5735.                         if(TokenUtilities.isTokenForwardEnabled(mappaDB)) {
  5736.                             de.setValue(gestioneTokenForward);
  5737.                         }else {
  5738.                             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  5739.                         }
  5740.                     }catch(Exception e) {
  5741.                         throw new DriverControlStationException(e.getMessage(),e);
  5742.                     }
  5743.                     dati.add(de);
  5744.                 }
  5745.             }
  5746.         }
  5747.     }
  5748.    
  5749.     public void controlloAccessiAutorizzazione(List<DataElement> dati, TipoOperazione tipoOperazione, String servletChiamante, Object oggetto, String protocolloParam,
  5750.             String autenticazione, String autenticazioneCustom,
  5751.             String autorizzazione, String autorizzazioneCustom,
  5752.             String autorizzazioneAutenticati, String urlAutorizzazioneAutenticati, int numAutenticati, List<String> autenticati, String autenticato,
  5753.             String autorizzazioneRuoli,  String urlAutorizzazioneRuoli, int numRuoli, String ruolo, String autorizzazioneRuoliTipologia, String autorizzazioneRuoliMatch,
  5754.             boolean confPers, boolean isSupportatoAutenticazione, boolean contaListe, boolean isPortaDelegata,
  5755.             boolean addTitoloSezione,String autorizzazioneScope,  String urlAutorizzazioneScope, int numScope, String scope, String autorizzazioneScopeMatch,
  5756.             String gestioneToken, String gestioneTokenPolicy, String autorizzazione_token, String autorizzazione_tokenOptions,BinaryParameter allegatoXacmlPolicy,
  5757.             String urlAutorizzazioneErogazioneApplicativiAutenticati, int numErogazioneApplicativiAutenticati,
  5758.             String urlAutorizzazioneCustomPropertiesList, int numAutorizzazioneCustomPropertiesList,
  5759.             String identificazioneAttributiStato, String[] attributeAuthorityLabels, String[] attributeAuthorityValues, String [] attributeAuthoritySelezionate, String attributeAuthorityAttributi,
  5760.             String autorizzazioneAutenticatiToken, String urlAutorizzazioneAutenticatiToken, int numAutenticatiToken,
  5761.             String autorizzazioneRuoliToken,  String urlAutorizzazioneRuoliToken, int numRuoliToken, String autorizzazioneRuoliTipologiaToken, String autorizzazioneRuoliMatchToken) throws DriverControlStationException{
  5762.         this.controlloAccessiAutorizzazione(dati, tipoOperazione, servletChiamante, oggetto, protocolloParam,
  5763.                 autenticazione, autenticazioneCustom,
  5764.                 autorizzazione, autorizzazioneCustom,
  5765.                 autorizzazioneAutenticati, urlAutorizzazioneAutenticati, numAutenticati, autenticati, null, autenticato,
  5766.                 autorizzazioneRuoli, urlAutorizzazioneRuoli, numRuoli, ruolo, autorizzazioneRuoliTipologia, autorizzazioneRuoliMatch,
  5767.                 confPers, isSupportatoAutenticazione, contaListe, isPortaDelegata, addTitoloSezione,autorizzazioneScope,urlAutorizzazioneScope,numScope,scope,autorizzazioneScopeMatch,
  5768.                 gestioneToken, gestioneTokenPolicy, autorizzazione_token, autorizzazione_tokenOptions,allegatoXacmlPolicy,
  5769.                 urlAutorizzazioneErogazioneApplicativiAutenticati, numErogazioneApplicativiAutenticati,
  5770.                 urlAutorizzazioneCustomPropertiesList, numAutorizzazioneCustomPropertiesList,
  5771.                 identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  5772.                 autorizzazioneAutenticatiToken, urlAutorizzazioneAutenticatiToken, numAutenticatiToken,
  5773.                 autorizzazioneRuoliToken,  urlAutorizzazioneRuoliToken, numRuoliToken, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);
  5774.        
  5775.     }
  5776.    
  5777.     public void controlloAccessiAutorizzazione(List<DataElement> dati, TipoOperazione tipoOperazione, String servletChiamante, Object oggetto, String protocolloParam,
  5778.             String autenticazione, String autenticazioneCustom,
  5779.             String autorizzazione, String autorizzazioneCustom,
  5780.             String autorizzazioneAutenticati, String urlAutorizzazioneAutenticati, int numAutenticati, List<String> autenticati, List<String> autenticatiLabel, String autenticato,
  5781.             String autorizzazioneRuoli,  String urlAutorizzazioneRuoli, int numRuoli, String ruolo, String autorizzazioneRuoliTipologia, String autorizzazioneRuoliMatch,
  5782.             boolean confPers, boolean isSupportatoAutenticazione, boolean contaListe, boolean isPortaDelegata, boolean addTitoloSezione,
  5783.             String autorizzazioneScope,  String urlAutorizzazioneScope, int numScope, String scope, String autorizzazioneScopeMatch,
  5784.             String gestioneToken, String gestioneTokenPolicy, String autorizzazione_token, String autorizzazione_tokenOptions, BinaryParameter allegatoXacmlPolicy,
  5785.             String urlAutorizzazioneErogazioneApplicativiAutenticati, int numErogazioneApplicativiAutenticati,
  5786.             String urlAutorizzazioneCustomPropertiesList, int numAutorizzazioneCustomPropertiesList,
  5787.             String identificazioneAttributiStato, String[] attributeAuthorityLabels, String[] attributeAuthorityValues, String [] attributeAuthoritySelezionate, String attributeAuthorityAttributi,
  5788.             String autorizzazioneAutenticatiToken, String urlAutorizzazioneAutenticatiToken, int numAutenticatiToken,
  5789.             String autorizzazioneRuoliToken,  String urlAutorizzazioneRuoliToken, int numRuoliToken, String autorizzazioneRuoliTipologiaToken, String autorizzazioneRuoliMatchToken
  5790.             ) throws DriverControlStationException{
  5791.        
  5792.         boolean allHidden = false;
  5793.         if(!this.isModalitaCompleta() && TipoOperazione.ADD.equals(tipoOperazione)) {
  5794.             allHidden = true;
  5795.         }
  5796.        
  5797.         String protocollo = protocolloParam;
  5798.         if((protocollo==null || "".equals(protocollo)) && oggetto!=null){
  5799.             if(isPortaDelegata){
  5800.                 PortaDelegata pd = (PortaDelegata) oggetto;
  5801.                 if(pd!=null && pd.getServizio()!=null && pd.getServizio().getTipo()!=null) {
  5802.                     try {
  5803.                         protocollo = this.apsCore.getProtocolloAssociatoTipoServizio(pd.getServizio().getTipo());
  5804.                     }catch(Exception e) {
  5805.                         throw new DriverControlStationException(e.getMessage(),e);
  5806.                     }
  5807.                 }
  5808.             }
  5809.             else {
  5810.                 PortaApplicativa pa = (PortaApplicativa) oggetto;
  5811.                 if(pa!=null && pa.getServizio()!=null && pa.getServizio().getTipo()!=null) {
  5812.                     try {
  5813.                         protocollo = this.apsCore.getProtocolloAssociatoTipoServizio(pa.getServizio().getTipo());
  5814.                     }catch(Exception e) {
  5815.                         throw new DriverControlStationException(e.getMessage(),e);
  5816.                     }
  5817.                 }
  5818.             }
  5819.         }
  5820.        
  5821.         String oldAutenticazione = null;
  5822.         IDServizio idAps = null;
  5823.         if(oggetto!=null) {
  5824.             if(isPortaDelegata){
  5825.                 PortaDelegata pd = (PortaDelegata) oggetto;
  5826.                 if(pd!=null) {
  5827.                     oldAutenticazione = pd.getAutenticazione();
  5828.                 }
  5829.             }
  5830.             else {
  5831.                 PortaApplicativa pa = (PortaApplicativa) oggetto;
  5832.                 if(pa!=null) {
  5833.                     oldAutenticazione = pa.getAutenticazione();
  5834.                     if(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONTROLLO_ACCESSI.equals(servletChiamante)) {
  5835.                         // Altrimenti arriva una porta applicativa con il solo tipo impostato
  5836.                         try {
  5837.                             idAps = IDServizioFactory.getInstance().getIDServizioFromValues(pa.getServizio().getTipo(), pa.getServizio().getNome(),
  5838.                                     pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario(),
  5839.                                     pa.getServizio().getVersione());
  5840.                         }catch(Exception e) {
  5841.                             throw new DriverControlStationException(e.getMessage(),e);
  5842.                         }
  5843.                     }
  5844.                 }
  5845.             }
  5846.         }
  5847.                
  5848.        
  5849.         boolean mostraSezione = false;
  5850.         try {
  5851.             mostraSezione = !tipoOperazione.equals(TipoOperazione.ADD) ||
  5852.                     (isPortaDelegata ? this.core.isEnabledAutorizzazione_generazioneAutomaticaPorteDelegate() :
  5853.                         this.core.isEnabledAutorizzazione_generazioneAutomaticaPorteApplicative(protocollo==null ? true : this.soggettiCore.isSupportatoAutenticazioneSoggetti(protocollo)));
  5854.         }catch(Exception e) {
  5855.             throw new DriverControlStationException(e.getMessage(),e);
  5856.         }
  5857.        
  5858.         boolean tokenAbilitato = StatoFunzionalita.ABILITATO.getValue().equalsIgnoreCase(gestioneToken) &&
  5859.                 gestioneTokenPolicy != null && !gestioneTokenPolicy.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO);
  5860.        
  5861.         boolean profiloModi = this.isProfiloModIPA(protocollo);
  5862.        
  5863.         @SuppressWarnings("unused")
  5864.         boolean isSupportatoAutenticazioneApplicativiEsterni = false;
  5865.         try{
  5866.             isSupportatoAutenticazioneApplicativiEsterni = this.saCore.isSupportatoAutenticazioneApplicativiEsterniErogazione(protocollo);
  5867.         }catch(Exception e) {
  5868.             throw new DriverControlStationException(e.getMessage(),e);
  5869.         }
  5870.        
  5871.         boolean modiSicurezzaMessaggio = false;
  5872.         if(!isPortaDelegata && profiloModi && !allHidden && PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONTROLLO_ACCESSI.equals(servletChiamante) && idAps!=null) {
  5873.             try {
  5874.                 AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idAps);
  5875.                 idAps.setPortType(asps.getPortType());
  5876.                 idAps.setUriAccordoServizioParteComune(asps.getAccordoServizioParteComune());
  5877.                
  5878.                 IProtocolFactory<?> protocolFactory = ProtocolFactoryManager.getInstance().getProtocolFactoryByName(protocollo);
  5879.                 IConsoleDynamicConfiguration consoleDynamicConfiguration = protocolFactory.createDynamicConfigurationConsole();
  5880.                 IRegistryReader registryReader = this.apcCore.getRegistryReader(protocolFactory);
  5881.                 IConfigIntegrationReader configRegistryReader = this.apcCore.getConfigIntegrationReader(protocolFactory);
  5882.                 ConsoleConfiguration consoleConfiguration = consoleDynamicConfiguration.getDynamicConfigAccordoServizioParteSpecifica(ConsoleOperationType.CHANGE, this,
  5883.                         registryReader, configRegistryReader, idAps );
  5884.                 if(consoleConfiguration!=null && consoleConfiguration.getConsoleItem()!=null && !consoleConfiguration.getConsoleItem().isEmpty()) {
  5885.                     modiSicurezzaMessaggio = true;
  5886.                 }
  5887.             }catch(Exception e) {
  5888.                 throw new DriverControlStationException(e.getMessage(),e);
  5889.             }
  5890.         }
  5891.        
  5892.        
  5893.         if(mostraSezione) {
  5894.            
  5895.             if(!tipoOperazione.equals(TipoOperazione.ADD) && attributeAuthorityValues!=null && attributeAuthorityValues.length>0){
  5896.                 DataElement de = new DataElement();
  5897.                 de.setType(DataElementType.TITLE); //SUBTITLE);
  5898.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO_TITLE);
  5899.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_TITLE);
  5900.                 de.setStatoAperturaSezioni(STATO_APERTURA_SEZIONI.CHIUSO);
  5901.                 dati.add(de);
  5902.            
  5903.                 de = new DataElement();
  5904.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_STATO);
  5905.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO);
  5906.                 de.setValue(identificazioneAttributiStato);
  5907.                 if(allHidden) {
  5908.                     de.setType(DataElementType.HIDDEN);
  5909.                 }
  5910.                 else {
  5911.                     de.setType(DataElementType.SELECT);
  5912.                     String [] valoriAbilitazione = {StatoFunzionalita.DISABILITATO.getValue(), StatoFunzionalita.ABILITATO.getValue()};
  5913.                     de.setValues(valoriAbilitazione);
  5914.                     de.setPostBack(true);
  5915.                     de.setSelected(identificazioneAttributiStato);
  5916.                     de.setValoreDefaultSelect(StatoFunzionalita.DISABILITATO.getValue());
  5917.                 }
  5918.                 dati.add(de);
  5919.                
  5920.                 de = new DataElement();
  5921.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  5922.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  5923.                 if(allHidden || !StatoFunzionalita.ABILITATO.getValue().equals(identificazioneAttributiStato)) {
  5924.                     de.setType(DataElementType.HIDDEN);
  5925.                     de.setSelezionati(attributeAuthoritySelezionate);
  5926.                 }
  5927.                 else {
  5928.                     de.setRequired(true);
  5929.                     de.setType(DataElementType.MULTI_SELECT);
  5930.                     de.setValues(attributeAuthorityValues);
  5931.                     de.setLabels(attributeAuthorityLabels);
  5932.                     de.setPostBack(true); // cambia la descrizione in autorizzazione per claims
  5933.                     de.setSelezionati(attributeAuthoritySelezionate);
  5934.                 }
  5935.                 dati.add(de);
  5936.                
  5937.                 de = new DataElement();
  5938.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI);
  5939.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI);
  5940.                 int sizeAA = 0;
  5941.                 if(attributeAuthoritySelezionate!=null) {
  5942.                     sizeAA = attributeAuthoritySelezionate.length;
  5943.                 }
  5944.                 de.setValue(attributeAuthorityAttributi);
  5945.                 if(allHidden || !StatoFunzionalita.ABILITATO.getValue().equals(identificazioneAttributiStato)) {
  5946.                     de.setType(DataElementType.HIDDEN);
  5947.                 }
  5948.                 else if(sizeAA>1) {
  5949.                     de.setType(DataElementType.TEXT_AREA);
  5950.                     de.setNote(CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI_NOTE_MULTIPLE_AA);
  5951.                     de.setRows(sizeAA<=10 ? sizeAA : 10);
  5952.                 }
  5953.                 else {
  5954.                     de.setType(DataElementType.TEXT_EDIT);
  5955.                     de.setNote(CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI_NOTE_SINGLE_AA);
  5956.                 }
  5957.                 dati.add(de);
  5958.                
  5959.                 this.impostaAperturaTitle(dati, CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO_TITLE);
  5960.             }
  5961.            
  5962.            
  5963.             boolean addTitle = false;
  5964.             if(!allHidden) {
  5965.                 addTitle = true;
  5966.                 DataElement de = new DataElement();
  5967.                 de.setType(DataElementType.TITLE);
  5968.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TITLE);
  5969.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_DIFFERENTE_DA_TRASPORTO_E_TOKEN);
  5970.                 de.setStatoAperturaSezioni(STATO_APERTURA_SEZIONI.APERTO);
  5971.                 dati.add(de);
  5972.             }
  5973.            
  5974.             IDServizio idServizio = null;
  5975.             AccordoServizioParteSpecifica asps = null;
  5976.             boolean isModISignaHubPush = false;
  5977.             if(isPortaDelegata && this.isProfiloModIPA(protocollo)) {
  5978.                 PortaDelegata portaDelegata = (PortaDelegata) oggetto;
  5979.                 if(portaDelegata!=null &&
  5980.                         portaDelegata.getServizio()!=null && portaDelegata.getServizio().getTipo()!=null && portaDelegata.getServizio().getNome()!=null && portaDelegata.getServizio().getVersione()!=null &&
  5981.                         portaDelegata.getSoggettoErogatore()!=null && portaDelegata.getSoggettoErogatore().getTipo()!=null && portaDelegata.getSoggettoErogatore().getNome()!=null) {
  5982.                     try {
  5983.                         idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(portaDelegata.getServizio().getTipo(), portaDelegata.getServizio().getNome(),
  5984.                                 portaDelegata.getSoggettoErogatore().getTipo(), portaDelegata.getSoggettoErogatore().getNome(),
  5985.                                 portaDelegata.getServizio().getVersione());
  5986.                         if(idServizio!=null) {
  5987.                             asps = this.apsCore.getServizio(idServizio,false);
  5988.                         }
  5989.                         if(asps!=null) {
  5990.                             IDAccordo modisignalHubPushApi = ModIUtils.buildSignalHubPushIdAPI(this.soggettiCore.getSoggettoOperativoDefault(null, protocollo));
  5991.                             IDAccordo idAccordoServizio = IDAccordoFactory.getInstance().getIDAccordoFromUri(asps.getAccordoServizioParteComune());
  5992.                             isModISignaHubPush = modisignalHubPushApi.equals(idAccordoServizio);
  5993.                         }
  5994.                     }catch(Exception e) {
  5995.                         throw new DriverControlStationException(e.getMessage(),e);
  5996.                     }
  5997.                 }              
  5998.             }
  5999.            
  6000.             List<String> auturizzazioneValues = AutorizzazioneUtilities.getStati(isModISignaHubPush);
  6001.             int totEl = auturizzazioneValues.size();
  6002.             if (confPers ) {
  6003.                 totEl++;
  6004.             }
  6005.             String[] tipoAutorizzazione = new String[totEl];
  6006.             String[] tipoAutorizzazioneLabel = new String[totEl];
  6007.             for (int i = 0; i < auturizzazioneValues.size(); i++) {
  6008.                 tipoAutorizzazione[i]=auturizzazioneValues.get(i);
  6009.                 tipoAutorizzazioneLabel[i]=auturizzazioneValues.get(i);
  6010.             }
  6011.             if (confPers ){
  6012.                 tipoAutorizzazione[totEl-1] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM;
  6013.                 tipoAutorizzazioneLabel[totEl-1] = CostantiControlStation.DEFAULT_LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM;
  6014.             }
  6015.            
  6016.             if(modiSicurezzaMessaggio) {
  6017.                 // backward compatibility
  6018.                 if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione) && numErogazioneApplicativiAutenticati>0) {
  6019.                     autorizzazione=AutorizzazioneUtilities.STATO_ABILITATO;
  6020.                 }
  6021.             }
  6022.            
  6023.             DataElement de = new DataElement();
  6024.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE);
  6025.             de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE);
  6026.             if(allHidden) {
  6027.                 de.setType(DataElementType.HIDDEN);
  6028.                 de.setValue(autorizzazione);
  6029.             }
  6030.             else {
  6031.                 de.setType(DataElementType.SELECT);
  6032.                 de.setValues(tipoAutorizzazione);
  6033.                 de.setLabels(tipoAutorizzazioneLabel);
  6034.                 de.setPostBack(true);
  6035.                 de.setSelected(autorizzazione);
  6036.                 de.setValoreDefaultSelect(StatoFunzionalita.DISABILITATO.getValue());
  6037.             }
  6038.             dati.add(de);
  6039.            
  6040.             String tipoAutorizzazioneCustom = isPortaDelegata ? Filtri.FILTRO_RUOLO_VALORE_FRUIZIONE : Filtri.FILTRO_RUOLO_VALORE_EROGAZIONE;
  6041.             boolean autorizzazioneCustomHidden = (allHidden || (autorizzazione == null) || (!autorizzazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM)));
  6042.             this.addCustomField(TipoPlugin.AUTORIZZAZIONE,
  6043.                     tipoAutorizzazioneCustom,
  6044.                     null,
  6045.                     CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE,
  6046.                     CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM,
  6047.                     CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM,
  6048.                     autorizzazioneCustom, autorizzazioneCustomHidden, dati,
  6049.                     false);
  6050.                        
  6051.             boolean old_autorizzazione_autenticazione = false;
  6052.             boolean old_autorizzazione_ruoli = false;
  6053.             boolean old_autorizzazione_token_autenticazione = false;
  6054.             boolean old_autorizzazione_token_ruoli = false;
  6055.             boolean old_autorizzazione_scope = false;
  6056.             boolean old_xacmlPolicy = false;
  6057.             boolean old_autorizzazione_custom = false;
  6058.             String old_autorizzazione = null;
  6059.             Long idPorta = null;
  6060.            
  6061.             String nomePostback = this.getPostBackElementName();
  6062.             if(!CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE.equals(nomePostback) &&
  6063.                     TipoOperazione.CHANGE.equals(tipoOperazione) && (numAutenticati>0)) {
  6064.                 autorizzazioneAutenticati = Costanti.CHECK_BOX_ENABLED;
  6065.             }
  6066.             if(!CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI.equals(nomePostback) &&
  6067.                     TipoOperazione.CHANGE.equals(tipoOperazione) && (numRuoli>0)) {
  6068.                 autorizzazioneRuoli = Costanti.CHECK_BOX_ENABLED;
  6069.             }
  6070.            
  6071.             if(TipoOperazione.CHANGE.equals(tipoOperazione) && oggetto!=null){
  6072.                 if(isPortaDelegata){
  6073.                     PortaDelegata pd = (PortaDelegata) oggetto;
  6074.                     old_autorizzazione = AutorizzazioneUtilities.convertToStato(pd.getAutorizzazione());
  6075.                     old_autorizzazione_autenticazione = TipoAutorizzazione.isAuthenticationRequired(pd.getAutorizzazione());
  6076.                     old_autorizzazione_ruoli = TipoAutorizzazione.isRolesRequired(pd.getAutorizzazione());
  6077.                     old_autorizzazione_token_autenticazione = pd.getAutorizzazioneToken()!=null && StatoFunzionalita.ABILITATO.equals(pd.getAutorizzazioneToken().getAutorizzazioneApplicativi());
  6078.                     old_autorizzazione_token_ruoli = pd.getAutorizzazioneToken()!=null && StatoFunzionalita.ABILITATO.equals(pd.getAutorizzazioneToken().getAutorizzazioneRuoli());
  6079.                     old_autorizzazione_scope = pd.getScope() != null && pd.getScope().getStato().equals(StatoFunzionalita.ABILITATO);
  6080.                     old_xacmlPolicy = StringUtils.isNotEmpty(pd.getXacmlPolicy());
  6081.                     idPorta = pd.getId();
  6082.                     if(idServizio==null) {
  6083.                         try {
  6084.                             idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(pd.getServizio().getTipo(), pd.getServizio().getNome(),
  6085.                                     pd.getSoggettoErogatore().getTipo(), pd.getSoggettoErogatore().getNome(),
  6086.                                     pd.getServizio().getVersione());
  6087.                         }catch(Exception e) {
  6088.                             throw new DriverControlStationException(e.getMessage(),e);
  6089.                         }
  6090.                     }
  6091.                     old_autorizzazione_custom = pd.getAutorizzazione() != null && !TipoAutorizzazione.getAllValues().contains(pd.getAutorizzazione());
  6092.                 }
  6093.                 else {
  6094.                     PortaApplicativa pa = (PortaApplicativa) oggetto;
  6095.                     old_autorizzazione = AutorizzazioneUtilities.convertToStato(pa.getAutorizzazione());
  6096.                     old_autorizzazione_autenticazione = TipoAutorizzazione.isAuthenticationRequired(pa.getAutorizzazione());
  6097.                     old_autorizzazione_ruoli = TipoAutorizzazione.isRolesRequired(pa.getAutorizzazione());
  6098.                     old_autorizzazione_token_autenticazione = pa.getAutorizzazioneToken()!=null && StatoFunzionalita.ABILITATO.equals(pa.getAutorizzazioneToken().getAutorizzazioneApplicativi());
  6099.                     old_autorizzazione_token_ruoli = pa.getAutorizzazioneToken()!=null && StatoFunzionalita.ABILITATO.equals(pa.getAutorizzazioneToken().getAutorizzazioneRuoli());
  6100.                     old_autorizzazione_scope = pa.getScope() != null && pa.getScope().getStato().equals(StatoFunzionalita.ABILITATO);
  6101.                     old_xacmlPolicy = StringUtils.isNotEmpty(pa.getXacmlPolicy());
  6102.                     idPorta = pa.getId();
  6103.                     try {
  6104.                         idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(pa.getServizio().getTipo(), pa.getServizio().getNome(),
  6105.                                 pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario(),
  6106.                                 pa.getServizio().getVersione());
  6107.                     }catch(Exception e) {
  6108.                         throw new DriverControlStationException(e.getMessage(),e);
  6109.                     }
  6110.                     old_autorizzazione_custom = pa.getAutorizzazione() != null && !TipoAutorizzazione.getAllValues().contains(pa.getAutorizzazione());
  6111.                 }
  6112.             }
  6113.            
  6114.             // se ho salvato il tipo custom faccio vedere il link alle proprieta'
  6115.             if(autorizzazione != null && autorizzazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM)) {
  6116.                 if(old_autorizzazione_custom) {
  6117.                     de = new DataElement();
  6118.                     de.setType(DataElementType.LINK);
  6119.                     de.setUrl(urlAutorizzazioneCustomPropertiesList);
  6120.                     String labelCustomProperties = CostantiControlStation.LABEL_PARAMETRO_AUTORIZZAZIONE_CUSTOM_PROPERTIES;
  6121.                     if (contaListe) {
  6122.                         ServletUtils.setDataElementCustomLabel(de,labelCustomProperties,Long.valueOf(numAutorizzazioneCustomPropertiesList));
  6123.                     } else {
  6124.                         ServletUtils.setDataElementCustomLabel(de,labelCustomProperties);
  6125.                     }
  6126.                     dati.add(de);
  6127.                 }
  6128.             }

  6129.             // ** Trasporto Richiedente **
  6130.             boolean labelAutorizzazioneTrasportoAttuata = false;
  6131.             if(!AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)){
  6132.            
  6133.                 boolean autorizzazione_autenticazione =  false;
  6134.                 boolean isSupportatoAutorizzazioneRichiedentiSenzaAutenticazione = false;
  6135.                 try {
  6136.                     isSupportatoAutorizzazioneRichiedentiSenzaAutenticazione = this.soggettiCore.isSupportatoAutorizzazioneRichiedenteSenzaAutenticazioneErogazione(protocollo);
  6137.                 }catch(Exception e) {
  6138.                     throw new DriverControlStationException(e.getMessage(),e);
  6139.                 }
  6140.                
  6141.                            
  6142.                 if(AutorizzazioneUtilities.STATO_ABILITATO.equals(autorizzazione) || AutorizzazioneUtilities.STATO_SIGNAL_HUB_PUSH_SIGNALS.equals(autorizzazione)) {
  6143.                
  6144.                     if(!allHidden) {
  6145.                         if( !isSupportatoAutenticazione
  6146.                                 ||
  6147.                                 (autenticazione!=null && !TipoAutenticazione.DISABILITATO.equals(autenticazione))
  6148.                                 ||
  6149.                                 isSupportatoAutorizzazioneRichiedentiSenzaAutenticazione
  6150.                                 ){  
  6151.                             de = new DataElement();
  6152.                             de.setType(DataElementType.SUBTITLE);
  6153.                             if(isPortaDelegata){
  6154.                                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TRASPORTO);
  6155.                             }
  6156.                             else{
  6157.                                
  6158.                                 String labelTrasporto = CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TRASPORTO;
  6159.                                 if(profiloModi && !isPortaDelegata) {
  6160.                                     labelTrasporto = CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CANALE;
  6161.                                 }
  6162.                                
  6163.                                 String labelSoggetti = (isSupportatoAutenticazione &&
  6164.                                         (
  6165.                                                 (autenticazione!=null && !TipoAutenticazione.DISABILITATO.equals(autenticazione))
  6166.                                                 ||
  6167.                                                 isSupportatoAutorizzazioneRichiedentiSenzaAutenticazione
  6168.                                         )
  6169.                                         ) ? labelTrasporto : CostantiControlStation.LABEL_PARAMETRO_SOGGETTI;
  6170.                                 de.setLabel(labelSoggetti);
  6171.                             }
  6172.                             labelAutorizzazioneTrasportoAttuata=true;
  6173.                             dati.add(de);
  6174.                         }
  6175.                     }
  6176.                    
  6177.                     autorizzazione_autenticazione = ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticati);
  6178.                    
  6179.                     de = new DataElement();
  6180.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_PER_RICHIEDENTE);
  6181.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE);
  6182.                     if( !isSupportatoAutenticazione
  6183.                             ||
  6184.                             (autenticazione!=null && !TipoAutenticazione.DISABILITATO.equals(autenticazione))
  6185.                             ||
  6186.                             isSupportatoAutorizzazioneRichiedentiSenzaAutenticazione
  6187.                             ){  
  6188.                         if(allHidden) {
  6189.                             de.setType(DataElementType.HIDDEN);
  6190.                             de.setValue(autorizzazione_autenticazione+"");
  6191.                         }
  6192.                         else {
  6193.                             de.setType(DataElementType.CHECKBOX);
  6194.                             de.setSelected(autorizzazione_autenticazione);
  6195.                             de.setPostBack(true);
  6196.                         }
  6197.                     }
  6198.                     else{
  6199.                         de.setType(DataElementType.HIDDEN);
  6200.                         de.setValue(Costanti.CHECK_BOX_DISABLED);
  6201.                     }
  6202.                     dati.add(de);
  6203.                    
  6204.                 }
  6205.                
  6206.                 if(TipoOperazione.CHANGE.equals(tipoOperazione)){
  6207.                    
  6208.                     if( !isSupportatoAutenticazione
  6209.                             ||
  6210.                             (autenticazione!=null && !TipoAutenticazione.DISABILITATO.equals(autenticazione))
  6211.                             ||
  6212.                             isSupportatoAutorizzazioneRichiedentiSenzaAutenticazione
  6213.                             ){  
  6214.                    
  6215.                         if(urlAutorizzazioneAutenticati!=null && autorizzazione_autenticazione &&
  6216.                                 (old_autorizzazione_autenticazione || CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM.equals(old_autorizzazione)) &&
  6217.                                 (oldAutenticazione!=null && (
  6218.                                             oldAutenticazione.equals(autenticazione)
  6219.                                             ||  
  6220.                                             (CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM.equals(autenticazione) && oldAutenticazione.equals(autenticazioneCustom) )
  6221.                                         )
  6222.                                 )
  6223.                                 ){
  6224.                             de = new DataElement();
  6225.                             de.setType(DataElementType.LINK);
  6226.                             de.setUrl(urlAutorizzazioneAutenticati);
  6227.                             if(isPortaDelegata){
  6228.                                 String labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZI_APPLICATIVI;
  6229.                                 if(!this.isModalitaCompleta()) {
  6230.                                     labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVI;
  6231.                                 }
  6232.                                 if (contaListe) {
  6233.                                     ServletUtils.setDataElementCustomLabel(de,labelApplicativi,Long.valueOf(numAutenticati));
  6234.                                 } else
  6235.                                     ServletUtils.setDataElementCustomLabel(de,labelApplicativi);
  6236.                             }
  6237.                             else{
  6238.                                 if (contaListe) {
  6239.                                     ServletUtils.setDataElementCustomLabel(de,PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_SOGGETTI,Long.valueOf(numAutenticati));
  6240.                                 } else
  6241.                                     ServletUtils.setDataElementCustomLabel(de,PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_SOGGETTI);
  6242.                             }
  6243.                             dati.add(de);
  6244.                         }
  6245.                        
  6246.                         boolean supportatoAutenticazioneApplicativiErogazione = false;
  6247.                         try {
  6248.                             supportatoAutenticazioneApplicativiErogazione = this.saCore.isSupportatoAutenticazioneApplicativiErogazione(protocollo);
  6249.                         }catch(Exception e) {
  6250.                             throw new DriverControlStationException(e.getMessage(),e);
  6251.                         }
  6252.                         if(!isPortaDelegata &&  supportatoAutenticazioneApplicativiErogazione
  6253.                                 && isSupportatoAutenticazione // il link degli applicativi sulla pa deve essere visualizzato SOLO se è abilitata l'autenticazione
  6254.                                 && !profiloModi // e non siamo nel profilo ModI
  6255.                                 &&
  6256.                                 (oldAutenticazione!=null && (
  6257.                                         oldAutenticazione.equals(autenticazione)
  6258.                                         ||  
  6259.                                         (CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM.equals(autenticazione) && oldAutenticazione.equals(autenticazioneCustom) )
  6260.                                     )
  6261.                                 )
  6262.                                 ){
  6263.                             if(urlAutorizzazioneErogazioneApplicativiAutenticati!=null && autorizzazione_autenticazione && (old_autorizzazione_autenticazione || CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM.equals(old_autorizzazione)) ){
  6264.                                 de = new DataElement();
  6265.                                 de.setType(DataElementType.LINK);
  6266.                                 de.setUrl(urlAutorizzazioneErogazioneApplicativiAutenticati);
  6267.                                 String labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZI_APPLICATIVI; // uso cmq label PD
  6268.                                 if(!this.isModalitaCompleta()) {
  6269.                                     labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVI;// uso cmq label PD
  6270.                                 }
  6271.                                 if (contaListe) {
  6272.                                     ServletUtils.setDataElementCustomLabel(de,labelApplicativi,Long.valueOf(numErogazioneApplicativiAutenticati));
  6273.                                 } else {
  6274.                                     ServletUtils.setDataElementCustomLabel(de,labelApplicativi);
  6275.                                 }
  6276.                                 dati.add(de);
  6277.                             }
  6278.                         }
  6279.                     }
  6280.                 }
  6281.                 else{
  6282.                     if(!allHidden) {
  6283.                         if(!isSupportatoAutenticazione ||  (autenticazione!=null && !TipoAutenticazione.DISABILITATO.equals(autenticazione))) {
  6284.                             if(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD.equals(servletChiamante) && autorizzazione_autenticazione && isPortaDelegata){
  6285.                                 String [] saArray = null;
  6286.                                 if(autenticati!=null && autenticati.size()>0){
  6287.                                     saArray = autenticati.toArray(new String[1]);
  6288.                                 }
  6289.                                 this.addPorteServizioApplicativoToDati(tipoOperazione, dati, autenticato, saArray, 0, false, false, false);
  6290.                             }
  6291.         //                  if(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD.equals(servletChiamante) && autorizzazione_autenticazione && !isPortaDelegata && isSupportatoAutenticazione) {
  6292.                             if(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD.equals(servletChiamante) && autorizzazione_autenticazione && !isPortaDelegata) {
  6293.                                 String soggettiList [] = null;
  6294.                                 String soggettiLabelList[] = null;
  6295.                                 if(autenticati!=null && autenticati.size()>0){
  6296.                                     soggettiList = autenticati.toArray(new String[1]);
  6297.                                     if(autenticatiLabel!=null && autenticatiLabel.size()>0){
  6298.                                         soggettiLabelList = autenticatiLabel.toArray(new String[1]);
  6299.                                     }
  6300.                                 }
  6301.                                 this.addPorteSoggettoToDati(tipoOperazione, dati, soggettiLabelList, soggettiList, autenticato, 0, false, false);
  6302.                             }
  6303.                         }
  6304.                     }
  6305.                 }
  6306.             }
  6307.            
  6308.             // ** Trasporto Ruoli **
  6309.             if(!AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)){
  6310.                    
  6311.                 boolean autorizzazione_ruoli = false;
  6312.                
  6313.                 if(AutorizzazioneUtilities.STATO_ABILITATO.equals(autorizzazione)){
  6314.                    
  6315.                     if(!allHidden && !labelAutorizzazioneTrasportoAttuata) {
  6316.                         de = new DataElement();
  6317.                         de.setType(DataElementType.SUBTITLE);
  6318.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TRASPORTO);
  6319.                         dati.add(de);
  6320.                     }
  6321.                
  6322.                     autorizzazione_ruoli = ServletUtils.isCheckBoxEnabled(autorizzazioneRuoli);
  6323.                    
  6324.                     de = new DataElement();
  6325.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_PER_RUOLI);
  6326.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI);
  6327.                     if(allHidden) {
  6328.                         de.setType(DataElementType.HIDDEN);
  6329.                         de.setValue(autorizzazione_ruoli+"");
  6330.                     }
  6331.                     else {
  6332.                         de.setType(DataElementType.CHECKBOX);
  6333.                         de.setSelected(autorizzazione_ruoli);
  6334.                         de.setPostBack(true);
  6335.                     }
  6336.                     dati.add(de);
  6337.                
  6338.                 }
  6339.                        
  6340.                 if(autorizzazione_ruoli || AutorizzazioneUtilities.STATO_XACML_POLICY.equals(autorizzazione)){
  6341.                    
  6342.                     de = new DataElement();
  6343.                     if(autorizzazione_ruoli){
  6344.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RUOLO_TIPOLOGIA);
  6345.                     }
  6346.                     else{
  6347.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RUOLO_TIPOLOGIA_XACML_POLICY);
  6348.                     }
  6349.                     de.setName(CostantiControlStation.PARAMETRO_RUOLO_TIPOLOGIA);
  6350.                     de.setValue(autorizzazioneRuoliTipologia);      
  6351.                     if(allHidden) {
  6352.                         de.setType(DataElementType.HIDDEN);
  6353.                     }
  6354.                     else {
  6355.                         de.setType(DataElementType.SELECT);
  6356.                         de.setValues(RuoliCostanti.getRuoliTipologia());
  6357.                         de.setLabels(RuoliCostanti.getRuoliTipologiaLabel());
  6358.                         de.setSelected(autorizzazioneRuoliTipologia);
  6359.                         if(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD.equals(servletChiamante) ||
  6360.                                 AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD.equals(servletChiamante)){
  6361.                             de.setPostBack(true);
  6362.                         }
  6363.                     }
  6364.                     dati.add(de);
  6365.                    
  6366.                 }
  6367.                
  6368.                 String postbackElement = this.getPostBackElementName();
  6369.                 boolean aggiornatoFile = false;
  6370.                 if(postbackElement != null) {
  6371.                     if(postbackElement.equals(allegatoXacmlPolicy.getName())) {
  6372.                         aggiornatoFile = true;
  6373.                     }
  6374.                 }
  6375.                 if(AutorizzazioneUtilities.STATO_XACML_POLICY.equals(autorizzazione)) {
  6376.                     String filePolicyLabel = CostantiControlStation.LABEL_PARAMETRO_DOCUMENTO_SICUREZZA_XACML_POLICY;
  6377.                     if(old_xacmlPolicy && !aggiornatoFile) {
  6378.                         filePolicyLabel = CostantiControlStation.LABEL_PARAMETRO_DOCUMENTO_SICUREZZA_XACML_NUOVA_POLICY;
  6379.                         DataElement saveAs = new DataElement();
  6380.                         saveAs.setValue(CostantiControlStation.LABEL_DOWNLOAD_DOCUMENTO_SICUREZZA_XACML_POLICY);
  6381.                         saveAs.setType(DataElementType.LINK);
  6382.                         Parameter pIdAccordo = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_ID_ACCORDO, idPorta+ "");
  6383.                         Parameter pTipoAllegato = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, isPortaDelegata ? "pd" : "pa");
  6384.                         Parameter pTipoDoc = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, isPortaDelegata ? ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_PORTA_DELEGATA_XACML_POLICY : ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_PORTA_APPLICATIVA_XACML_POLICY);
  6385.                         saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT, pIdAccordo, pTipoAllegato, pTipoDoc);
  6386.                         saveAs.setDisabilitaAjaxStatus();
  6387.                         dati.add(saveAs);
  6388.                        
  6389.                         de = new DataElement();
  6390.                         de.setType(DataElementType.SUBTITLE);
  6391.                         de.setLabel(CostantiControlStation.LABEL_AGGIORNAMENTO_DOCUMENTO_SICUREZZA_XACML_POLICY);
  6392.                         de.setLabelStyleClass("noBold");
  6393.                         dati.add(de);
  6394.                     }
  6395.                     dati.add(allegatoXacmlPolicy.getFileDataElement(filePolicyLabel, "", getSize()));
  6396.                     dati.addAll(allegatoXacmlPolicy.getFileNameDataElement());
  6397.                     dati.add(allegatoXacmlPolicy.getFileIdDataElement());
  6398.                 }
  6399.                
  6400.                 if(autorizzazione_ruoli){
  6401.                     String[] tipoRole = { RuoloTipoMatch.ALL.getValue(),
  6402.                             RuoloTipoMatch.ANY.getValue() };
  6403.                     String[] labelRole = { CostantiControlStation.LABEL_PARAMETRO_RUOLO_MATCH_ALL, CostantiControlStation.LABEL_PARAMETRO_RUOLO_MATCH_ANY };
  6404.                     de = new DataElement();
  6405.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RUOLO_MATCH);
  6406.                     de.setName(CostantiControlStation.PARAMETRO_RUOLO_MATCH);
  6407.                     de.setValue(autorizzazioneRuoliMatch);          
  6408.                     if(allHidden) {
  6409.                         de.setType(DataElementType.HIDDEN);
  6410.                     }
  6411.                     else {
  6412.                         de.setType(DataElementType.SELECT);
  6413.                         de.setValues(tipoRole);
  6414.                         de.setLabels(labelRole);
  6415.                         de.setSelected(autorizzazioneRuoliMatch);
  6416.                     }
  6417.                     dati.add(de);
  6418.                 }
  6419.                
  6420.                 if(TipoOperazione.CHANGE.equals(tipoOperazione)){
  6421.                     if(urlAutorizzazioneRuoli!=null && autorizzazione_ruoli && (old_autorizzazione_ruoli || CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM.equals(old_autorizzazione)) ){
  6422.                        
  6423.                         de = new DataElement();
  6424.                         de.setType(DataElementType.LINK);
  6425.                         de.setUrl(urlAutorizzazioneRuoli);
  6426.                         if (contaListe) {
  6427.                             ServletUtils.setDataElementCustomLabel(de,RuoliCostanti.LABEL_RUOLI,Long.valueOf(numRuoli));
  6428.                         } else
  6429.                             ServletUtils.setDataElementCustomLabel(de,RuoliCostanti.LABEL_RUOLI);
  6430.                         dati.add(de);
  6431.                                    
  6432.                     }
  6433.                 }
  6434.                 else{
  6435.                     if(!allHidden) {
  6436.                         if( (AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD.equals(servletChiamante) ||
  6437.                                 AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD.equals(servletChiamante))
  6438.                                 && autorizzazione_ruoli){
  6439.                             FiltroRicercaRuoli filtroRuoli = new FiltroRicercaRuoli();
  6440.                             if(isPortaDelegata){
  6441.                                 filtroRuoli.setContesto(RuoloContesto.PORTA_DELEGATA);
  6442.                             }
  6443.                             else{
  6444.                                 filtroRuoli.setContesto(RuoloContesto.PORTA_APPLICATIVA);
  6445.                             }
  6446.                             filtroRuoli.setTipologia(RuoloTipologia.QUALSIASI);
  6447.                             if(RuoloTipologia.INTERNO.equals(autorizzazioneRuoliTipologia) ){
  6448.                                 filtroRuoli.setTipologia(RuoloTipologia.INTERNO);
  6449.                             }
  6450.                             else if(RuoloTipologia.ESTERNO.equals(autorizzazioneRuoliTipologia) ){
  6451.                                 filtroRuoli.setTipologia(RuoloTipologia.ESTERNO);
  6452.                             }
  6453.                             try {
  6454.                                 this.addRuoliToDati(tipoOperazione, dati, false, filtroRuoli, ruolo, null, true, false,
  6455.                                         AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_RUOLO, addTitoloSezione, null, false);
  6456.                             }catch(Exception e) {
  6457.                                 throw new DriverControlStationException(e.getMessage(),e);
  6458.                             }
  6459.                         }
  6460.                     }
  6461.                 }
  6462.                
  6463.             }
  6464.                    
  6465.            
  6466.            
  6467.             boolean labelAutorizzazioneTokenAttuata = false;
  6468.            
  6469.             // ** Token **
  6470.             if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)==false){
  6471.            
  6472.                 // ** Token Richiedente **
  6473.                 if( (tokenAbilitato || modiSicurezzaMessaggio) && !AutorizzazioneUtilities.STATO_XACML_POLICY.equals(autorizzazione)) {
  6474.                    
  6475.                     boolean autorizzazione_autenticazione_token =  false;
  6476.                                                
  6477.                     if(!allHidden && !labelAutorizzazioneTokenAttuata) {
  6478.                         de = new DataElement();
  6479.                         de.setType(DataElementType.SUBTITLE);
  6480.                        
  6481.                         String labelToken = CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN;
  6482.                         if(profiloModi && !isPortaDelegata) {
  6483.                             labelToken = CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_MESSAGGIO;
  6484.                         }
  6485.                        
  6486.                         de.setLabel(labelToken);
  6487.                         labelAutorizzazioneTokenAttuata=true;
  6488.                         dati.add(de);
  6489.                     }
  6490.                    
  6491.                     autorizzazione_autenticazione_token = ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticatiToken);
  6492.                    
  6493.                     if(modiSicurezzaMessaggio) {
  6494.                         // backward compatibility
  6495.                         if(!old_autorizzazione_token_autenticazione && !autorizzazione_autenticazione_token && numErogazioneApplicativiAutenticati>0) {
  6496.                             autorizzazione_autenticazione_token=true;
  6497.                         }
  6498.                     }
  6499.                    
  6500.                     de = new DataElement();
  6501.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_PER_RICHIEDENTE);
  6502.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE_TOKEN);
  6503.                     if(allHidden) {
  6504.                         de.setType(DataElementType.HIDDEN);
  6505.                         de.setValue(autorizzazione_autenticazione_token+"");
  6506.                     }
  6507.                     else {
  6508.                         de.setType(DataElementType.CHECKBOX);
  6509.                         de.setSelected(autorizzazione_autenticazione_token);
  6510.                         de.setPostBack(true);
  6511.                     }
  6512.                     dati.add(de);
  6513.                    
  6514.                                    
  6515.                     if(TipoOperazione.CHANGE.equals(tipoOperazione)){

  6516.                         if((urlAutorizzazioneAutenticatiToken!=null && autorizzazione_autenticazione_token && old_autorizzazione_token_autenticazione) ||
  6517.                                 (modiSicurezzaMessaggio && (numErogazioneApplicativiAutenticati>0))){
  6518.                             de = new DataElement();
  6519.                             de.setType(DataElementType.LINK);
  6520.                             if(!isPortaDelegata && profiloModi) {
  6521.                                 de.setUrl(urlAutorizzazioneErogazioneApplicativiAutenticati,
  6522.                                         new Parameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_MODIPA, modiSicurezzaMessaggio+""),
  6523.                                         new Parameter(CostantiControlStation.PARAMETRO_TOKEN_AUTHORIZATION, tokenAbilitato+""));
  6524.                             }
  6525.                             else {
  6526.                                 de.setUrl(urlAutorizzazioneAutenticatiToken);
  6527.                             }
  6528.                             String labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZI_APPLICATIVI;
  6529.                             if(!this.isModalitaCompleta()) {
  6530.                                 labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVI;
  6531.                             }
  6532.                             if (contaListe) {
  6533.                                 if(!isPortaDelegata && profiloModi) {
  6534.                                     ServletUtils.setDataElementCustomLabel(de,labelApplicativi,Long.valueOf(numErogazioneApplicativiAutenticati));
  6535.                                 }
  6536.                                 else {
  6537.                                     ServletUtils.setDataElementCustomLabel(de,labelApplicativi,Long.valueOf(numAutenticatiToken));
  6538.                                 }
  6539.                             } else {
  6540.                                 ServletUtils.setDataElementCustomLabel(de,labelApplicativi);
  6541.                             }
  6542.                             dati.add(de);
  6543.                         }
  6544.                        
  6545.                     }

  6546.                 }
  6547.                
  6548.                 // ** Token Ruoli **
  6549.                 if((tokenAbilitato || modiSicurezzaMessaggio) && !AutorizzazioneUtilities.STATO_XACML_POLICY.equals(autorizzazione)) {
  6550.                    
  6551.                     boolean autorizzazione_ruoli_token = false;
  6552.                        
  6553.                     if(!allHidden && !labelAutorizzazioneTokenAttuata) {
  6554.                         de = new DataElement();
  6555.                         de.setType(DataElementType.SUBTITLE);
  6556.                        
  6557.                         String labelToken = CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN;
  6558.                         if(profiloModi && !isPortaDelegata) {
  6559.                             labelToken = CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_MESSAGGIO;
  6560.                         }
  6561.                        
  6562.                         de.setLabel(labelToken);
  6563.                         dati.add(de);
  6564.                     }
  6565.                
  6566.                     autorizzazione_ruoli_token = ServletUtils.isCheckBoxEnabled(autorizzazioneRuoliToken);
  6567.                    
  6568.                     de = new DataElement();
  6569.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_PER_RUOLI);
  6570.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_TOKEN);
  6571.                     if(allHidden) {
  6572.                         de.setType(DataElementType.HIDDEN);
  6573.                         de.setValue(autorizzazione_ruoli_token+"");
  6574.                     }
  6575.                     else {
  6576.                         de.setType(DataElementType.CHECKBOX);
  6577.                         de.setSelected(autorizzazione_ruoli_token);
  6578.                         de.setPostBack(true);
  6579.                     }
  6580.                     dati.add(de);
  6581.                    
  6582.                            
  6583.                     if(autorizzazione_ruoli_token){
  6584.                        
  6585.                         de = new DataElement();
  6586.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RUOLO_TIPOLOGIA);
  6587.                         de.setName(CostantiControlStation.PARAMETRO_RUOLO_TIPOLOGIA_TOKEN);
  6588.                         de.setValue(autorizzazioneRuoliTipologiaToken);    
  6589.                         if(allHidden) {
  6590.                             de.setType(DataElementType.HIDDEN);
  6591.                         }
  6592.                         else {
  6593.                             de.setType(DataElementType.SELECT);
  6594.                             de.setValues(RuoliCostanti.getRuoliTipologia());
  6595.                             de.setLabels(RuoliCostanti.getRuoliTipologiaLabel());
  6596.                             de.setSelected(autorizzazioneRuoliTipologiaToken);
  6597.                             if(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD.equals(servletChiamante) ||
  6598.                                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD.equals(servletChiamante)){
  6599.                                 de.setPostBack(true);
  6600.                             }
  6601.                         }
  6602.                         dati.add(de);
  6603.                        
  6604.                     }
  6605.                    
  6606.                     if(autorizzazione_ruoli_token){
  6607.                         String[] tipoRole = { RuoloTipoMatch.ALL.getValue(),
  6608.                                 RuoloTipoMatch.ANY.getValue() };
  6609.                         String[] labelRole = { CostantiControlStation.LABEL_PARAMETRO_RUOLO_MATCH_ALL, CostantiControlStation.LABEL_PARAMETRO_RUOLO_MATCH_ANY };
  6610.                         de = new DataElement();
  6611.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RUOLO_MATCH);
  6612.                         de.setName(CostantiControlStation.PARAMETRO_RUOLO_MATCH_TOKEN);
  6613.                         de.setValue(autorizzazioneRuoliMatchToken);        
  6614.                         if(allHidden) {
  6615.                             de.setType(DataElementType.HIDDEN);
  6616.                         }
  6617.                         else {
  6618.                             de.setType(DataElementType.SELECT);
  6619.                             de.setValues(tipoRole);
  6620.                             de.setLabels(labelRole);
  6621.                             de.setSelected(autorizzazioneRuoliMatchToken);
  6622.                         }
  6623.                         dati.add(de);
  6624.                     }
  6625.                    
  6626.                     if(TipoOperazione.CHANGE.equals(tipoOperazione)){
  6627.                         if(urlAutorizzazioneRuoliToken!=null && autorizzazione_ruoli_token && old_autorizzazione_token_ruoli ){
  6628.                            
  6629.                             de = new DataElement();
  6630.                             de.setType(DataElementType.LINK);
  6631.                             if(!isPortaDelegata && profiloModi) {
  6632.                                 de.setUrl(urlAutorizzazioneRuoliToken,
  6633.                                         new Parameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_MODIPA, modiSicurezzaMessaggio+""));
  6634.                             }
  6635.                             else {
  6636.                                 de.setUrl(urlAutorizzazioneRuoliToken);
  6637.                             }
  6638.                             if (contaListe) {
  6639.                                 ServletUtils.setDataElementCustomLabel(de,RuoliCostanti.LABEL_RUOLI,Long.valueOf(numRuoliToken));
  6640.                             } else
  6641.                                 ServletUtils.setDataElementCustomLabel(de,RuoliCostanti.LABEL_RUOLI);
  6642.                             dati.add(de);
  6643.                                        
  6644.                         }
  6645.                     }
  6646.                    
  6647.                 }
  6648.                
  6649.                
  6650.                
  6651.                 // ** Token Claims **
  6652.                
  6653.                 if(tokenAbilitato && !AutorizzazioneUtilities.STATO_XACML_POLICY.equals(autorizzazione)) {
  6654.                    
  6655.                     if(!allHidden) {
  6656.                         de = new DataElement();
  6657.                         de.setType(DataElementType.SUBTITLE);
  6658.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_CLAIMS_SUBTITLE);
  6659.                         dati.add(de);
  6660.                     }

  6661.                     boolean autorizzazioneTokenEnabled = ServletUtils.isCheckBoxEnabled(autorizzazione_token);
  6662.                    
  6663.                     de = new DataElement();
  6664.                     de.setLabel(CostantiControlStation.LABEL_ABILITATO);
  6665.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN);
  6666.                     if(allHidden) {
  6667.                         de.setType(DataElementType.HIDDEN);
  6668.                         de.setValue(autorizzazioneTokenEnabled+"");
  6669.                     }
  6670.                     else {
  6671.                         de.setType(DataElementType.CHECKBOX);
  6672.                         de.setSelected(autorizzazioneTokenEnabled);
  6673.                         de.setPostBack(true);
  6674.                     }
  6675.                     dati.add(de);
  6676.                    
  6677.                     if(autorizzazioneTokenEnabled) {
  6678.                         de = new DataElement();
  6679.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_CLAIMS);
  6680.                         de.setNote(DynamicHelperCostanti.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_NOTE);
  6681.                         de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_OPTIONS);
  6682.                         de.setValue(autorizzazione_tokenOptions);
  6683.                         if(allHidden) {
  6684.                             de.setType(DataElementType.HIDDEN);
  6685.                         }
  6686.                         else {
  6687.                             de.setType(DataElementType.TEXT_AREA);
  6688.                             de.setRows(6);
  6689.                             de.setCols(55);
  6690.                         }
  6691.                        
  6692.                         org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding = org.openspcoop2.core.registry.constants.ServiceBinding.REST;
  6693.                         if(idServizio!=null) {
  6694.                             try {
  6695.                                 if(asps==null) {
  6696.                                     asps = this.apsCore.getServizio(idServizio,false);
  6697.                                 }
  6698.                                 AccordoServizioParteComuneSintetico aspc = this.apcCore.getAccordoServizioSintetico(this.idAccordoFactory.getIDAccordoFromUri(asps.getAccordoServizioParteComune()));
  6699.                                 serviceBinding = aspc.getServiceBinding();
  6700.                             }catch(Exception e) {
  6701.                                 throw new DriverControlStationException(e.getMessage(),e);
  6702.                             }
  6703.                         }
  6704.                         int sizeAA = 0;
  6705.                         if(attributeAuthoritySelezionate!=null) {
  6706.                             sizeAA = attributeAuthoritySelezionate.length;
  6707.                         }
  6708.                        
  6709.                         DataElementInfo dInfoTokenClaims = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_CLAIMS);
  6710.                         if(sizeAA>1) {
  6711.                             dInfoTokenClaims.setHeaderBody(DynamicHelperCostanti.LABEL_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TOKEN_CLAIMS_MULTI_ATTRIBUTE_AUTHORITY);
  6712.                         }
  6713.                         else if(sizeAA==1) {
  6714.                             dInfoTokenClaims.setHeaderBody(DynamicHelperCostanti.LABEL_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TOKEN_CLAIMS_SINGLE_ATTRIBUTE_AUTHORITY);
  6715.                         }
  6716.                         else {
  6717.                             dInfoTokenClaims.setHeaderBody(DynamicHelperCostanti.LABEL_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TOKEN_CLAIMS_NO_ATTRIBUTE_AUTHORITY);
  6718.                         }
  6719.                         if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  6720.                             dInfoTokenClaims.setListBody(DynamicHelperCostanti.getLABEL_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TOKEN_CLAIMS_REST_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata));
  6721.                         }
  6722.                         else {
  6723.                             dInfoTokenClaims.setListBody(DynamicHelperCostanti.getLABEL_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TOKEN_CLAIMS_SOAP_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata));
  6724.                         }
  6725.                         de.setInfo(dInfoTokenClaims);
  6726.                        
  6727.                         dati.add(de);
  6728.                     }
  6729.                 }
  6730.                
  6731.                
  6732.                 boolean autorizzazione_scope = false;
  6733.            
  6734.                 if((AutorizzazioneUtilities.STATO_ABILITATO.equals(autorizzazione) || AutorizzazioneUtilities.STATO_SIGNAL_HUB_PUSH_SIGNALS.equals(autorizzazione))
  6735.                         && tokenAbilitato){
  6736.                    
  6737.                     // ** Scope **
  6738.                    
  6739.                     if(!allHidden) {
  6740.                         de = new DataElement();
  6741.                         de.setType(DataElementType.SUBTITLE);
  6742.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE);
  6743.                         dati.add(de);
  6744.                     }
  6745.                
  6746.                     autorizzazione_scope = ServletUtils.isCheckBoxEnabled(autorizzazioneScope);
  6747.                    
  6748.                     de = new DataElement();
  6749.                     de.setLabel(CostantiControlStation.LABEL_ABILITATO);
  6750.                     de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE);
  6751.                     if(allHidden) {
  6752.                         de.setType(DataElementType.HIDDEN);
  6753.                         de.setValue(autorizzazione_scope+"");
  6754.                     }
  6755.                     else {
  6756.                         de.setType(DataElementType.CHECKBOX);
  6757.                         de.setSelected(autorizzazione_scope);
  6758.                         de.setPostBack(true);
  6759.                     }
  6760.                     dati.add(de);
  6761.                
  6762.                     if(autorizzazione_scope){
  6763.                         String[] tipoScope = { ScopeTipoMatch.ALL.getValue(),   ScopeTipoMatch.ANY.getValue() };
  6764.                         String[] labelScope = { CostantiControlStation.LABEL_PARAMETRO_SCOPE_MATCH_ALL, CostantiControlStation.LABEL_PARAMETRO_SCOPE_MATCH_ANY };
  6765.                         de = new DataElement();
  6766.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_SCOPE_MATCH);
  6767.                         de.setName(CostantiControlStation.PARAMETRO_SCOPE_MATCH);
  6768.                         if(allHidden) {
  6769.                             de.setType(DataElementType.HIDDEN);
  6770.                             de.setValue(autorizzazioneScopeMatch+"");
  6771.                         }
  6772.                         else {
  6773.                             de.setType(DataElementType.SELECT);
  6774.                             de.setValues(tipoScope);
  6775.                             de.setLabels(labelScope);
  6776.                             de.setSelected(autorizzazioneScopeMatch);
  6777.                         }
  6778.                         dati.add(de);
  6779.                     }
  6780.                    
  6781.                     if(TipoOperazione.CHANGE.equals(tipoOperazione)){
  6782.                         if(urlAutorizzazioneScope!=null && autorizzazione_scope && old_autorizzazione_scope){
  6783.                            
  6784.                             de = new DataElement();
  6785.                             de.setType(DataElementType.LINK);
  6786.                             de.setUrl(urlAutorizzazioneScope);
  6787.                             if (contaListe) {
  6788.                                 ServletUtils.setDataElementCustomLabel(de,ScopeCostanti.LABEL_SCOPE,Long.valueOf(numScope));
  6789.                             } else
  6790.                                 ServletUtils.setDataElementCustomLabel(de,ScopeCostanti.LABEL_SCOPE);
  6791.                             dati.add(de);
  6792.                                        
  6793.                         }
  6794.                     }
  6795.                     else{
  6796.                         if(!allHidden) {
  6797.                             if( (AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD.equals(servletChiamante) ||
  6798.                                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD.equals(servletChiamante))
  6799.                                     && autorizzazione_scope){
  6800.                                 FiltroRicercaScope filtroScope = new FiltroRicercaScope();
  6801.                                 if(isPortaDelegata){
  6802.                                     filtroScope.setContesto(ScopeContesto.PORTA_DELEGATA);
  6803.                                 }
  6804.                                 else{
  6805.                                     filtroScope.setContesto(ScopeContesto.PORTA_APPLICATIVA);
  6806.                                 }

  6807.                                 try {
  6808.                                     this.addScopeToDati(tipoOperazione, dati, false, filtroScope, scope, null, true, false,
  6809.                                         AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_SCOPE, addTitoloSezione);
  6810.                                 }catch(Exception e) {
  6811.                                     throw new DriverControlStationException(e.getMessage(),e);
  6812.                                 }
  6813.                             }
  6814.                         }
  6815.                     }
  6816.                    
  6817.                 }
  6818.                
  6819.             }
  6820.            
  6821.             if(addTitle) {
  6822.                 this.impostaAperturaTitle(dati, CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TITLE);
  6823.             }
  6824.            
  6825.         } else {
  6826.             DataElement de = new DataElement();
  6827.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE);
  6828.             de.setType(DataElementType.HIDDEN);
  6829.             de.setName(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE);
  6830.             de.setValue(AutorizzazioneUtilities.STATO_DISABILITATO);
  6831.             dati.add(de);
  6832.         }
  6833.        
  6834.     }
  6835.    
  6836.     public void controlloAccessiAutorizzazioneContenuti(List<DataElement> dati, TipoOperazione tipoOperazione, boolean isPortaDelegata, Object oggetto, String protocolloParam,
  6837.             String autorizzazioneContenutiStato, String autorizzazioneContenuti, String autorizzazioneContenutiProperties, ServiceBinding serviceBinding,
  6838.             boolean old_autorizzazione_contenuti_custom, String urlAutorizzazioneContenutiCustomPropertiesList, int numAutorizzazioneContenutiCustomPropertiesList,
  6839.             boolean confPers) throws DriverControlStationException{
  6840.        
  6841.         String protocollo = protocolloParam;
  6842.         if((protocollo==null || "".equals(protocollo)) && oggetto!=null){
  6843.             if(isPortaDelegata){
  6844.                 PortaDelegata pd = (PortaDelegata) oggetto;
  6845.                 if(pd!=null && pd.getServizio()!=null && pd.getServizio().getTipo()!=null) {
  6846.                     try {
  6847.                         protocollo = this.apsCore.getProtocolloAssociatoTipoServizio(pd.getServizio().getTipo());
  6848.                     }catch(Exception e) {
  6849.                         throw new DriverControlStationException(e.getMessage(),e);
  6850.                     }
  6851.                 }
  6852.             }
  6853.             else {
  6854.                 PortaApplicativa pa = (PortaApplicativa) oggetto;
  6855.                 if(pa!=null && pa.getServizio()!=null && pa.getServizio().getTipo()!=null) {
  6856.                     try {
  6857.                         protocollo = this.apsCore.getProtocolloAssociatoTipoServizio(pa.getServizio().getTipo());
  6858.                     }catch(Exception e) {
  6859.                         throw new DriverControlStationException(e.getMessage(),e);
  6860.                     }
  6861.                 }
  6862.             }
  6863.         }
  6864.        
  6865.         DataElement de = new DataElement();
  6866.         de.setType(DataElementType.TITLE);
  6867.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI);
  6868.         de.setName(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_STATO_TITLE);
  6869.         de.setStatoAperturaSezioni(STATO_APERTURA_SEZIONI.CHIUSO);
  6870.         dati.add(de);
  6871.        
  6872.         List<String> authContenutiLabels = new ArrayList<>();
  6873.         List<String> authContenutiValues = new ArrayList<>();
  6874.        
  6875.         authContenutiLabels.addAll(Arrays.asList(CostantiControlStation.PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_LABELS));
  6876.         authContenutiValues.addAll(Arrays.asList(CostantiControlStation.PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_VALUES));
  6877.        
  6878.         if(confPers || autorizzazioneContenutiStato.equals(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_CUSTOM)) {
  6879.             authContenutiLabels.add(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_CUSTOM);
  6880.             authContenutiValues.add(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_CUSTOM);
  6881.         }
  6882.        
  6883.         de = new DataElement();
  6884.         de.setType(DataElementType.SELECT);
  6885.         de.setSelected(autorizzazioneContenutiStato);
  6886.         de.setValues(authContenutiValues);
  6887.         de.setLabels(authContenutiLabels);
  6888.         de.setName(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_STATO);
  6889.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_AUTORIZZAZIONE_CONTENUTI_STATO);
  6890.         de.setPostBack(true);
  6891.         de.setValoreDefaultSelect(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_DISABILITATO);
  6892.         dati.add(de);
  6893.        
  6894.         if(!autorizzazioneContenutiStato.equals(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_DISABILITATO)) {
  6895.             // abilitato
  6896.             if(autorizzazioneContenutiStato.equals(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_ABILITATO)) {
  6897.                 de = new DataElement();
  6898.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_AUTORIZZAZIONE_CONTENUTI);
  6899.                 de.setType(DataElementType.HIDDEN);
  6900.                 de.setName(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI);
  6901.                 de.setValue(autorizzazioneContenuti);
  6902.                 dati.add(de);
  6903.                
  6904.                
  6905.                 de = new DataElement();
  6906.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_AUTORIZZAZIONE_CONTENUTI);
  6907.                 de.setType(DataElementType.TEXT_AREA);
  6908.                 de.setName(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_PROPERTIES);
  6909.                 de.setValue(autorizzazioneContenutiProperties);
  6910.                 de.setNote(DynamicHelperCostanti.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_CONTENUTI_NOTE);
  6911.                 DataElementInfo info = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI);
  6912.                 info.setHeaderBody(DynamicHelperCostanti.LABEL_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI);
  6913.                 if(ServiceBinding.REST.equals(serviceBinding)) {
  6914.                     info.setListBody(DynamicHelperCostanti.getLABEL_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_REST_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata));
  6915.                 }
  6916.                 else {
  6917.                     info.setListBody(DynamicHelperCostanti.getLABEL_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_SOAP_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata));
  6918.                 }
  6919.                 de.setValoreDefault("");
  6920.                 de.setInfo(info );
  6921.                 dati.add(de);
  6922.             }
  6923.            
  6924.             // custom
  6925.             if(autorizzazioneContenutiStato.equals(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_CUSTOM)) {
  6926.                
  6927.                 String tipoAutorizzazioneCustom = isPortaDelegata ? Filtri.FILTRO_RUOLO_VALORE_FRUIZIONE : Filtri.FILTRO_RUOLO_VALORE_EROGAZIONE;
  6928.                 boolean autorizzazioneCustomHidden = false;
  6929.                 this.addCustomField(TipoPlugin.AUTORIZZAZIONE_CONTENUTI,
  6930.                         tipoAutorizzazioneCustom,
  6931.                         null,
  6932.                         CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_STATO,
  6933.                         CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI,
  6934.                         CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM,
  6935.                         autorizzazioneContenuti, autorizzazioneCustomHidden, dati,
  6936.                         false);
  6937.                
  6938. //              de = new DataElement();
  6939. //              de.setLabel(CostantiControlStation.LABEL_PARAMETRO_AUTORIZZAZIONE_CONTENUTI);
  6940. //              de.setType(DataElementType.TEXT_EDIT);
  6941. //              de.setName(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI);
  6942. //              de.setValue(autorizzazioneContenuti);
  6943. //              de.setRequired(true);
  6944. //              dati.add(de);
  6945.                
  6946.                 // link proprieta
  6947.                 if(old_autorizzazione_contenuti_custom) {
  6948.                     Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  6949.                     de = new DataElement();
  6950.                     de.setType(DataElementType.LINK);
  6951.                     de.setUrl(urlAutorizzazioneContenutiCustomPropertiesList);
  6952.                     String labelCustomProperties = CostantiControlStation.LABEL_PARAMETRO_AUTORIZZAZIONE_CONTENUTI_CUSTOM_PROPERTIES;
  6953.                     if (contaListe) {
  6954.                         ServletUtils.setDataElementCustomLabel(de,labelCustomProperties,Long.valueOf(numAutorizzazioneContenutiCustomPropertiesList));
  6955.                     } else {
  6956.                         ServletUtils.setDataElementCustomLabel(de,labelCustomProperties);
  6957.                     }
  6958.                     dati.add(de);
  6959.                 }
  6960.             }
  6961.         }
  6962.        
  6963.         this.impostaAperturaTitle(dati, CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_STATO_TITLE);
  6964.     }
  6965.    
  6966.     public boolean controlloAccessiCheck(TipoOperazione tipoOperazione,
  6967.             String autenticazione, String autenticazioneOpzionale, TipoAutenticazionePrincipal autenticazionePrincipal, List<String> autenticazioneParametroList,
  6968.             String autorizzazione, String autorizzazioneAutenticati, String autorizzazioneRuoli,  
  6969.             String autorizzazioneRuoliTipologia, String autorizzazioneRuoliMatch,
  6970.             boolean isSupportatoAutenticazione, boolean isPortaDelegata, Object oggetto,
  6971.             List<String> ruoli,String gestioneToken,
  6972.             String policy, String validazioneInput, String introspection, String userInfo, String forward,
  6973.             String autorizzazioneAutenticatiToken, String autorizzazioneRuoliToken,
  6974.             String autorizzazione_token, String autorizzazione_tokenOptions,
  6975.             String autorizzazioneScope, String autorizzazioneScopeMatch, BinaryParameter allegatoXacmlPolicy,
  6976.             String autorizzazioneContenutiStato, String autorizzazioneContenuto, String autorizzazioneContenutiProperties,
  6977.             String protocollo,
  6978.             String identificazioneAttributiStato, String [] attributeAuthoritySelezionate, String attributeAuthorityAttributi) throws DriverControlStationException{
  6979.         try {
  6980.            
  6981.             if(TipoAutenticazione.PRINCIPAL.equals(autenticazione) &&  autenticazionePrincipal!=null) {
  6982.                 switch (autenticazionePrincipal) {
  6983.                 case CONTAINER:
  6984.                 case INDIRIZZO_IP:
  6985.                 case INDIRIZZO_IP_X_FORWARDED_FOR:
  6986.                     break;
  6987.                 case HEADER:
  6988.                     if(autenticazioneParametroList==null || autenticazioneParametroList.isEmpty() || StringUtils.isEmpty(autenticazioneParametroList.get(0))){
  6989.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_HEADER));
  6990.                         return false;
  6991.                     }
  6992.                     break;
  6993.                 case FORM:
  6994.                     if(autenticazioneParametroList==null || autenticazioneParametroList.isEmpty() || StringUtils.isEmpty(autenticazioneParametroList.get(0))){
  6995.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_FORM));
  6996.                         return false;
  6997.                     }
  6998.                     break;
  6999.                 case URL:
  7000.                     if(autenticazioneParametroList==null || autenticazioneParametroList.isEmpty() || StringUtils.isEmpty(autenticazioneParametroList.get(0))){
  7001.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_ESPRESSIONE));
  7002.                         return false;
  7003.                     }
  7004.                    
  7005.                     if(this.checkRegexp(autenticazioneParametroList.get(0),ModalitaIdentificazione.URL_BASED.getLabelParametro())==false){
  7006.                         return false;
  7007.                     }
  7008.                    
  7009.                     break;
  7010.                 case TOKEN:
  7011.                     if(autenticazioneParametroList==null || autenticazioneParametroList.isEmpty() || StringUtils.isEmpty(autenticazioneParametroList.get(0))){
  7012.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TOKEN_CLAIM));
  7013.                         return false;
  7014.                     }
  7015.                     String tipo = autenticazioneParametroList.get(0);
  7016.                     if(ParametriAutenticazionePrincipal.TOKEN_CLAIM_CUSTOM.equals(tipo)) {
  7017.                         if(autenticazioneParametroList.size()<=1 || StringUtils.isEmpty(autenticazioneParametroList.get(1))){
  7018.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  
  7019.                                     CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TOKEN_CLAIM_PERSONALIZZATO_ESTESO));
  7020.                             return false;
  7021.                         }
  7022.                     }
  7023.                     break;
  7024.                 }
  7025.             }
  7026.            
  7027.             if(TipoAutenticazione.APIKEY.equals(autenticazione)) {
  7028.                 if(autenticazioneParametroList==null || autenticazioneParametroList.isEmpty()){
  7029.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  
  7030.                             CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_APIKEY_POSIZIONE));
  7031.                     return false;
  7032.                 }
  7033.                
  7034.                 ApiKeyState apiKeyState = new ApiKeyState(autenticazioneParametroList);
  7035.                 if(!apiKeyState.queryParameterEnabled && !apiKeyState.headerEnabled && !apiKeyState.cookieEnabled) {
  7036.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  
  7037.                             CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_APIKEY_POSIZIONE));
  7038.                     return false;
  7039.                 }
  7040.                
  7041.                 if(!apiKeyState.useOAS3NamesSelected) {
  7042.                     if(apiKeyState.queryParameterEnabled) {
  7043.                         if(apiKeyState.queryParameterApiKey==null || "".equals(apiKeyState.queryParameterApiKey)) {
  7044.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  
  7045.                                     ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY+" - "+ModalitaIdentificazione.FORM_BASED.getLabel()));
  7046.                             return false;
  7047.                         }
  7048.                     }
  7049.                     if(apiKeyState.headerEnabled) {
  7050.                         if(apiKeyState.headerApiKey==null || "".equals(apiKeyState.headerApiKey)) {
  7051.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  
  7052.                                     ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY+" - "+ModalitaIdentificazione.HEADER_BASED.getLabel()));
  7053.                             return false;
  7054.                         }
  7055.                     }
  7056.                     if(apiKeyState.cookieEnabled) {
  7057.                         if(apiKeyState.cookieApiKey==null || "".equals(apiKeyState.cookieApiKey)) {
  7058.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  
  7059.                                     ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY+" - "+ModalitaIdentificazione.COOKIE_BASED.getLabel()));
  7060.                             return false;
  7061.                         }
  7062.                     }
  7063.                    
  7064.                     if(apiKeyState.appIdSelected) {
  7065.                         if(apiKeyState.queryParameterEnabled) {
  7066.                             if(apiKeyState.queryParameterAppId==null || "".equals(apiKeyState.queryParameterAppId)) {
  7067.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  
  7068.                                         ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID+" - "+ModalitaIdentificazione.FORM_BASED.getLabel()));
  7069.                                 return false;
  7070.                             }
  7071.                             if(apiKeyState.queryParameterAppId.equalsIgnoreCase(apiKeyState.queryParameterApiKey)) {
  7072.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_CAMPI_DIFFERENTI,  
  7073.                                         "'"+ModalitaIdentificazione.FORM_BASED.getLabel()+"' tra "+ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY,
  7074.                                         ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID));
  7075.                                 return false;
  7076.                             }
  7077.                         }
  7078.                         if(apiKeyState.headerEnabled) {
  7079.                             if(apiKeyState.headerAppId==null || "".equals(apiKeyState.headerAppId)) {
  7080.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  
  7081.                                         ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID+" - "+ModalitaIdentificazione.HEADER_BASED.getLabel()));
  7082.                                 return false;
  7083.                             }
  7084.                             if(apiKeyState.headerAppId.equalsIgnoreCase(apiKeyState.headerApiKey)) {
  7085.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_CAMPI_DIFFERENTI,  
  7086.                                         "'"+ModalitaIdentificazione.HEADER_BASED.getLabel()+"' tra "+ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY,
  7087.                                         ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID));
  7088.                                 return false;
  7089.                             }
  7090.                         }
  7091.                         if(apiKeyState.cookieEnabled) {
  7092.                             if(apiKeyState.cookieAppId==null || "".equals(apiKeyState.cookieAppId)) {
  7093.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  
  7094.                                         ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID+" - "+ModalitaIdentificazione.COOKIE_BASED.getLabel()));
  7095.                                 return false;
  7096.                             }
  7097.                             if(apiKeyState.cookieAppId.equalsIgnoreCase(apiKeyState.cookieApiKey)) {
  7098.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_CAMPI_DIFFERENTI,  
  7099.                                         "'"+ModalitaIdentificazione.COOKIE_BASED.getLabel()+"' tra "+ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY,
  7100.                                         ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID));
  7101.                                 return false;
  7102.                             }
  7103.                         }
  7104.                     }
  7105.                 }
  7106.             }
  7107.            
  7108.             // tipo autenticazione custom
  7109.             String autenticazioneCustom = null;
  7110.             if(autenticazione != null && autenticazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM)) {
  7111.                 autenticazioneCustom = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM );
  7112.                
  7113.                 if(StringUtils.isEmpty(autenticazioneCustom) || CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_VALORE_UNDEFINED.equals(autenticazioneCustom)){
  7114.                     if(this.confCore.isConfigurazionePluginsEnabled()) {
  7115.                         this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTENTICAZIONE_CUSTOM_NON_INDICATA);
  7116.                     }
  7117.                     else {
  7118.                         this.pd.setMessage(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM+" obbligatorio per il tipo di autenticazione selezionato");
  7119.                     }
  7120.                     return false;
  7121.                 }
  7122.                
  7123.                 if(this.checkLength255(autenticazioneCustom, CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE_CUSTOM)==false) {
  7124.                     return false;
  7125.                 }
  7126.             }
  7127.            
  7128.             // check token
  7129.             if(AutorizzazioneUtilities.STATO_ABILITATO.equals(gestioneToken)){
  7130.                
  7131.                 if(StringUtils.isEmpty(policy) || policy.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO)){
  7132.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY));
  7133.                     return false;
  7134.                 }
  7135.                
  7136.                 boolean validazioneInputB = !StatoFunzionalitaConWarning.DISABILITATO.getValue().equals(validazioneInput);
  7137.                 boolean introspectionB = !StatoFunzionalitaConWarning.DISABILITATO.getValue().equals(introspection);
  7138.                 boolean userInfoB = !StatoFunzionalitaConWarning.DISABILITATO.getValue().equals(userInfo);
  7139.                 boolean forwardB = !StatoFunzionalitaConWarning.DISABILITATO.getValue().equals(forward);
  7140.                
  7141.                 if(!validazioneInputB && !introspectionB && !userInfoB && !forwardB) {
  7142.                     StringBuilder sb = new StringBuilder();
  7143.                     sb.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT).append(", ");
  7144.                     sb.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION).append(", ");
  7145.                     sb.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO).append(" o ");
  7146.                     sb.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  7147.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_POLICY_TOKEN_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_UNA_MODALITA, sb.toString()));
  7148.                     return false;
  7149.                 }
  7150.                
  7151.             }
  7152.            
  7153.             // check attribute authority
  7154.             if(AutorizzazioneUtilities.STATO_ABILITATO.equals(identificazioneAttributiStato)){
  7155.                 if(attributeAuthoritySelezionate==null || attributeAuthoritySelezionate.length<=0) {
  7156.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,  
  7157.                             CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY));
  7158.                     return false;
  7159.                 }
  7160.                 if (!checkAttributes(attributeAuthoritySelezionate, attributeAuthorityAttributi)) {
  7161.                     return false;
  7162.                 }
  7163.             }
  7164.            
  7165.             if(AutorizzazioneUtilities.STATO_ABILITATO.equals(autorizzazione) || AutorizzazioneUtilities.STATO_SIGNAL_HUB_PUSH_SIGNALS.equals(autorizzazione)) {
  7166.                
  7167.                 // autorizzazione abilitata
  7168.                
  7169.                 if(ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticati)==false &&
  7170.                         ServletUtils.isCheckBoxEnabled(autorizzazioneRuoli)==false &&
  7171.                         ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticatiToken)==false &&
  7172.                         ServletUtils.isCheckBoxEnabled(autorizzazioneRuoliToken)==false &&
  7173.                         ServletUtils.isCheckBoxEnabled(autorizzazioneScope)==false &&
  7174.                         (autorizzazione_tokenOptions==null || "".equals(autorizzazione_tokenOptions))){
  7175.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SELEZIONARE_ALMENO_UNA_MODALITÀ_DI_AUTORIZZAZIONE);
  7176.                     return false;
  7177.                 }
  7178.                
  7179.                 if(ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticati) &&
  7180.                         ServletUtils.isCheckBoxEnabled(autorizzazioneRuoli)==false){
  7181.                     // Se l'autorizzazione è solamente basata sull'autenticazione dei chiamanti, una autenticazione DEVE essere presente e non deve essere opzionale
  7182.                     if(isSupportatoAutenticazione){
  7183.                         if(isPortaDelegata || !this.soggettiCore.isSupportatoAutorizzazioneRichiedenteSenzaAutenticazioneErogazione(protocollo)) {
  7184.                            
  7185.                             boolean modipa = this.isProfiloModIPA(protocollo);
  7186.                             String label = CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TRASPORTO_SENZA_PREFIX;
  7187.                             if(modipa && !isPortaDelegata) {
  7188.                                 label = CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_CANALE_SENZA_PREFIX;
  7189.                             }
  7190.                            
  7191.                             if(TipoAutenticazione.DISABILITATO.equals(autenticazione)){
  7192.                                 this.pd.setMessage(MessageFormat.format(
  7193.                                         CostantiControlStation.MESSAGGIO_ERRORE_CON_LA_SOLA_MODALITA_DI_AUTORIZZAZIONE_XX_DEVE_ESSERE_INDICATA_ANCHE_UNA_MODALITA_DI_AUTENTICAZIONE_YY,
  7194.                                         label));
  7195.                                 return false;
  7196.                             }
  7197.                             if(ServletUtils.isCheckBoxEnabled(autenticazioneOpzionale)){
  7198.                                 this.pd.setMessage(MessageFormat.format(
  7199.                                         CostantiControlStation.MESSAGGIO_ERRORE_CON_LA_SOLA_MODALITA_DI_AUTORIZZAZIONE_XX_NON_E_POSSIBILE_ASSOCIATA_UNA_MODALITÀ_DI_AUTENTICAZIONE_OPZIONALE,
  7200.                                         label));
  7201.                                 return false;
  7202.                             }
  7203.                         }
  7204.                     }
  7205.                 }
  7206.                
  7207.                 if(ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticati) &&
  7208.                         ServletUtils.isCheckBoxEnabled(autorizzazioneRuoli)){
  7209.                     if(isSupportatoAutenticazione && ServletUtils.isCheckBoxEnabled(autenticazioneOpzionale)==false){
  7210.                         // Rilasso questo vincolo alla solta autenticazione di tipo http-basic, poiche' nelle altre l'identificazione di un applicativo o soggetto non e' obbligatoria
  7211.                         // Inoltre serve solo se si seleziona una fonte esterna per i ruoli che quindi non richiede obbligatoriamente una autenticazione
  7212.                         RuoloTipologia ruoloTipologia = RuoloTipologia.toEnumConstant(autorizzazioneRuoliTipologia);
  7213.                         if(TipoAutenticazione.BASIC.equals(autenticazione) &&
  7214.                                 (ruoloTipologia==null || RuoloTipologia.QUALSIASI.equals(autorizzazioneRuoliTipologia)  || RuoloTipologia.ESTERNO.equals(autorizzazioneRuoliTipologia))){
  7215.                             this.pd.setMessage(MessageFormat.format(
  7216.                                     CostantiControlStation.MESSAGGIO_ERRORE_CON_UNA_MODALITA_DI_AUTENTICAZIONE_BASIC_OBBLIGATORIA_NON_E_POSSIBILE_SELEZIONARE_ENTRAMBE_LE_MODALITA_DI_AUTORIZZAZIONE,
  7217.                                     CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_PER_RICHIEDENTE, CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_PER_RUOLI_FONTE_ESTERNA_QUALSIASI));
  7218.                             return false;
  7219.                         }
  7220.                     }
  7221.                 }
  7222.                
  7223.                 if(ServletUtils.isCheckBoxEnabled(autorizzazione_token)) {
  7224.                     if(autorizzazione_tokenOptions==null || "".equals(autorizzazione_tokenOptions)) {
  7225.                         this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_TOKEN_OPTIONS_NON_INDICATI);
  7226.                         return false;
  7227.                     }
  7228.                 }
  7229.                 if(autorizzazione_tokenOptions!=null) {
  7230.                     Scanner scanner = new Scanner(autorizzazione_tokenOptions);
  7231.                     try {
  7232.                         while (scanner.hasNextLine()) {
  7233.                             String line = scanner.nextLine();
  7234.                             if(line==null || line.trim().equals("")) {
  7235.                                 continue;
  7236.                             }
  7237.                             line = line.trim();
  7238.                             if(line!=null && line.startsWith("#")) {
  7239.                                 continue;
  7240.                             }
  7241.                             if(line!=null && line.contains("=")==false) {
  7242.                                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_TOKEN);
  7243.                                 return false;
  7244.                             }
  7245.                         }
  7246.                     }finally {
  7247.                         scanner.close();
  7248.                     }
  7249.                    
  7250.                     if(this.checkLength(autorizzazione_tokenOptions, CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_OPTIONS,-1,4000)==false) {
  7251.                         return false;
  7252.                     }
  7253.                 }
  7254.             }
  7255.            
  7256.             if(AutorizzazioneUtilities.STATO_ABILITATO.equals(autorizzazione) ||
  7257.                     AutorizzazioneUtilities.STATO_XACML_POLICY.equals(autorizzazione) ){
  7258.                
  7259.                 if(AutorizzazioneUtilities.STATO_XACML_POLICY.equals(autorizzazione)){
  7260.                     if(ruoli!=null && ruoli.size()>0){
  7261.                         this.pd.setMessage(MessageFormat.format(
  7262.                                 CostantiControlStation.MESSAGGIO_ERRORE_LA_PORTA_CONTIENE_GIA_DEI_RUOLI_CHE_NON_SONO_COMPATIBILI_CON_LA_NUOVA_AUTORIZZAZIONE,
  7263.                                 AutorizzazioneUtilities.STATO_XACML_POLICY));
  7264.                         return false;
  7265.                     }
  7266.                    
  7267.                     // se questo parametro e' diverso da null vuol dire che ho aggiornato il valore dell'allegato e devo validare il contenuto
  7268.                     if(allegatoXacmlPolicy.getValue() != null) {
  7269.                         IProtocolFactory<?> pf = ProtocolFactoryManager.getInstance().getProtocolFactoryByName(protocollo);
  7270.                         Documento documento = new Documento();
  7271.                         documento.setFile("xacmlPolicy");
  7272.                         documento.setByteContenuto(allegatoXacmlPolicy.getValue());
  7273.                         documento.setTipo(TipiDocumentoSicurezza.XACML_POLICY.getNome());
  7274.                         documento.setRuolo(RuoliDocumento.specificaSicurezza.toString());
  7275.                         ValidazioneResult valida = pf.createValidazioneDocumenti().valida (documento);
  7276.                         if(!valida.isEsito()) {
  7277.                             this.pd.setMessage(valida.getMessaggioErrore());
  7278.                             return false;
  7279.                         }
  7280.                     } else {
  7281.                         if(oggetto!=null){
  7282.                             if(isPortaDelegata){
  7283.                                 PortaDelegata pd = (PortaDelegata) oggetto;
  7284.                                 if(StringUtils.isEmpty(pd.getXacmlPolicy())) {
  7285.                                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_POLICY_OBBLIGATORIA_CON_LA_NUOVA_AUTORIZZAZIONE, AutorizzazioneUtilities.STATO_XACML_POLICY));
  7286.                                     return false;
  7287.                                 }
  7288.                             }else {
  7289.                                 PortaApplicativa pa = (PortaApplicativa) oggetto;
  7290.                                 if(StringUtils.isEmpty(pa.getXacmlPolicy())) {
  7291.                                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_POLICY_OBBLIGATORIA_CON_LA_NUOVA_AUTORIZZAZIONE, AutorizzazioneUtilities.STATO_XACML_POLICY));
  7292.                                     return false;
  7293.                                 }
  7294.                             }
  7295.                         }
  7296.                     }
  7297.                 }
  7298.                
  7299.                 RuoloTipologia ruoloTipologia = RuoloTipologia.toEnumConstant(autorizzazioneRuoliTipologia);
  7300.                 if(RuoloTipologia.INTERNO.equals(ruoloTipologia)){
  7301.                     if(isSupportatoAutenticazione && !AutorizzazioneUtilities.STATO_ABILITATO.equals(gestioneToken)){
  7302.                         if(TipoAutenticazione.DISABILITATO.equals(autenticazione)){
  7303.                             this.pd.setMessage(MessageFormat.format(
  7304.                                     CostantiControlStation.MESSAGGIO_ERRORE_CON_UNA_FONTE_PER_I_RUOLI_DI_TIPO_XX_DEVE_ESSERE_ASSOCIATA_UNA_MODALITÀ_DI_AUTENTICAZIONE,
  7305.                                     RuoliCostanti.LABEL_PARAMETRO_RUOLO_TIPOLOGIA.toLowerCase(), RuoliCostanti.RUOLI_TIPOLOGIA_LABEL_INTERNO));
  7306.                             return false;
  7307.                         }
  7308.                         if(ServletUtils.isCheckBoxEnabled(autenticazioneOpzionale)){
  7309.                             this.pd.setMessage(MessageFormat.format(
  7310.                                     CostantiControlStation.MESSAGGIO_ERRORE_CON_UNA_FONTE_PER_I_RUOLI_DI_TIPO_XX_NON_E_POSSIBILE_ASSOCIATA_UNA_MODALITÀ_DI_AUTENTICAZIONE_OPZIONALE,
  7311.                                     RuoliCostanti.LABEL_PARAMETRO_RUOLO_TIPOLOGIA.toLowerCase(), RuoliCostanti.RUOLI_TIPOLOGIA_LABEL_INTERNO));
  7312.                             return false;
  7313.                         }
  7314.                     }
  7315.                 }
  7316.                
  7317.                 // check tipologia rispetto ai ruoli esistenti
  7318.                 List<String> ruoliNonCompatibili = new ArrayList<>();
  7319.                 if(ruoli!=null && ruoli.size()>0){
  7320.                     for (String ruolo : ruoli) {
  7321.                         Ruolo ruoloObject = this.ruoliCore.getRuolo(ruolo);
  7322.                         if(RuoloTipologia.INTERNO.equals(ruoloTipologia)){
  7323.                             if(RuoloTipologia.ESTERNO.equals(ruoloObject.getTipologia())){
  7324.                                 ruoliNonCompatibili.add(ruolo);
  7325.                             }
  7326.                         }
  7327.                         if(RuoloTipologia.ESTERNO.equals(ruoloTipologia)){
  7328.                             if(RuoloTipologia.INTERNO.equals(ruoloObject.getTipologia())){
  7329.                                 ruoliNonCompatibili.add(ruolo);
  7330.                             }
  7331.                         }
  7332.                     }
  7333.                 }
  7334.                 if(ruoliNonCompatibili.size()>0){
  7335.                     String label = "";
  7336.                     if(RuoloTipologia.INTERNO.equals(ruoloTipologia)){
  7337.                         label = RuoliCostanti.RUOLI_TIPOLOGIA_LABEL_INTERNO;
  7338.                     }
  7339.                     else{
  7340.                         label = RuoliCostanti.RUOLI_TIPOLOGIA_LABEL_ESTERNO;
  7341.                     }
  7342.                     this.pd.setMessage(MessageFormat.format(
  7343.                             CostantiControlStation.MESSAGGIO_ERRORE_LA_PORTA_CONTIENE_DEI_RUOLI_XX_CHE_NON_SONO_COMPATIBILI_CON_LA_NUOVA_FONTE_SCELTA,
  7344.                             ruoliNonCompatibili.toString(), RuoliCostanti.LABEL_PARAMETRO_RUOLO_TIPOLOGIA.toLowerCase(), label));
  7345.                     return false;
  7346.                 }
  7347.             }

  7348.             if(oggetto!=null){
  7349.                 if(isPortaDelegata){
  7350.                     PortaDelegata pd = (PortaDelegata) oggetto;
  7351.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione) ){
  7352.                         if(pd.getRuoli()!=null && pd.getRuoli().sizeRuoloList()>0) {
  7353.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTORIZZAZIONE_TRASPORTO_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  7354.                             return false;
  7355.                         }
  7356.                     }
  7357.                     if((ServletUtils.isCheckBoxEnabled(autorizzazioneRuoli)==false) ){
  7358.                         if(pd.getRuoli()!=null && pd.getRuoli().sizeRuoloList()>0) {
  7359.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTORIZZAZIONE_TRASPORTO_DISABILITATA_PUNTUALMENTE);
  7360.                             return false;
  7361.                         }
  7362.                     }
  7363.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)){
  7364.                         if(pd.sizeServizioApplicativoList()>0) {
  7365.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_TRASPORTO_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  7366.                             return false;
  7367.                         }
  7368.                        
  7369.                         /*
  7370.                          * Vale solo per l'autenticazione
  7371.                         Trasformazioni trasformazioni = pd.getTrasformazioni();
  7372.                         if(trasformazioni != null) {
  7373.                             StringBuilder sb = new StringBuilder();
  7374.                             for(TrasformazioneRegola regola: trasformazioni.getRegolaList()) {
  7375.                                 if(regola.getApplicabilita()!= null) {
  7376.                                     if(regola.getApplicabilita().sizeServizioApplicativoList() > 0) {
  7377.                                         sb.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7378.                                         sb.append("- ");
  7379.                                         sb.append(regola.getNome());
  7380.                                     }
  7381.                                 }
  7382.                             }
  7383.                            
  7384.                             if(sb.length() > 0) {
  7385.                                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_TRASFORMAZIONI_AUTORIZZAZIONE_DISABILITATA + sb.toString());
  7386.                                 return false;
  7387.                             }
  7388.                         }
  7389.                         */
  7390.                     }
  7391.                     if((ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticati)==false) ){
  7392.                         if(pd.sizeServizioApplicativoList()>0) {
  7393.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_TRASPORTO_DISABILITATA_PUNTUALMENTE);
  7394.                             return false;
  7395.                         }
  7396.                     }
  7397.                    
  7398.                     StringBuilder sbCheckTrasformazioni = null;
  7399.                     StringBuilder sbCheckRateLimiting = null;
  7400.                     StringBuilder sbCheckAllarmi = null;
  7401.                     if(isSupportatoAutenticazione && pd.getAutenticazione()!=null){
  7402.                        
  7403.                         String prefix = "";
  7404.                        
  7405.                         boolean modificataAutenticazione = !pd.getAutenticazione().equals(autenticazione);
  7406.                         if(autenticazioneCustom!=null && !"".equals(autenticazioneCustom)) {
  7407.                             modificataAutenticazione = !pd.getAutenticazione().equals(autenticazioneCustom);
  7408.                         }
  7409.                         if(!modificataAutenticazione) {
  7410.                             if (ConnettoriCostanti.AUTENTICAZIONE_TIPO_APIKEY.equals(autenticazione)) {
  7411.                                 // verifico che non sia stato cambiato 'AppId'
  7412.                                 ApiKeyState immagineAttuale = new ApiKeyState(autenticazioneParametroList);
  7413.                                 ApiKeyState immaginePd = new ApiKeyState(this.porteDelegateCore.getParametroAutenticazione(autenticazione, pd.getProprietaAutenticazioneList()));
  7414.                                 if(immagineAttuale.appIdSelected!=immaginePd.appIdSelected) {
  7415.                                     modificataAutenticazione = true;
  7416.                                     prefix = "(Modifica "+ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID+") ";
  7417.                                 }
  7418.                             }
  7419.                         }
  7420.                        
  7421.                         // modiifcata autenticazione
  7422.                         if(modificataAutenticazione) {
  7423.                             if(pd.sizeServizioApplicativoList()>0) {
  7424.                                 this.pd.setMessage(prefix+CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTENTICAZIONE_TRASPORTO_MODIFICATA);
  7425.                                 return false;
  7426.                             }
  7427.                            
  7428.                             Trasformazioni trasformazioni = pd.getTrasformazioni();
  7429.                             if(trasformazioni != null) {
  7430.                                 StringBuilder sbSoggetti = new StringBuilder();
  7431.                                 sbCheckTrasformazioni = new StringBuilder();
  7432.                                 for(TrasformazioneRegola regola: trasformazioni.getRegolaList()) {
  7433.                                     if(regola.getApplicabilita()!= null) {
  7434.                                         if(regola.getApplicabilita().sizeSoggettoList() > 0) {
  7435.                                             sbSoggetti.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7436.                                             sbSoggetti.append("- ");
  7437.                                             sbSoggetti.append(regola.getNome());
  7438.                                         }
  7439.                                         if(regola.getApplicabilita().sizeServizioApplicativoList() > 0) {
  7440.                                             sbCheckTrasformazioni.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7441.                                             sbCheckTrasformazioni.append("- ");
  7442.                                             sbCheckTrasformazioni.append(regola.getNome());
  7443.                                         }
  7444.                                     }
  7445.                                 }
  7446.                                
  7447.                                 if(sbSoggetti!=null && sbSoggetti.length() > 0) {
  7448.                                     this.pd.setMessage(prefix+
  7449.                                             (CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TRASPORTO_MODIFICATA) +
  7450.                                             sbSoggetti.toString());
  7451.                                     return false;
  7452.                                 }
  7453.                                 if(sbCheckTrasformazioni.length() > 0) {
  7454.                                     this.pd.setMessage(prefix+
  7455.                                             (CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TRASPORTO_MODIFICATA) +
  7456.                                             sbCheckTrasformazioni.toString());
  7457.                                     return false;
  7458.                                 }
  7459.                             }

  7460.                             ConsoleSearch ricercaAll = new ConsoleSearch(true);
  7461.                             List<AttivazionePolicy> listaRateLimiting = this.confCore.attivazionePolicyList(ricercaAll, RuoloPolicy.DELEGATA, pd.getNome());
  7462.                             if(listaRateLimiting!=null && !listaRateLimiting.isEmpty()) {
  7463.                                 sbCheckRateLimiting = new StringBuilder();
  7464.                                 for(AttivazionePolicy policyRT: listaRateLimiting) {
  7465.                                     if(policyRT.getFiltro()!= null && policyRT.getFiltro().getServizioApplicativoFruitore()!=null) {
  7466.                                         sbCheckRateLimiting.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7467.                                         sbCheckRateLimiting.append("- ");
  7468.                                         sbCheckRateLimiting.append(policyRT.getAlias()!=null ? policyRT.getAlias() : policyRT.getIdActivePolicy());
  7469.                                     }
  7470.                                 }
  7471.                                
  7472.                                 if(sbCheckRateLimiting.length() > 0) {
  7473.                                     this.pd.setMessage(prefix+CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_RATE_LIMITING_AUTENTICAZIONE_TRASPORTO_MODIFICATA + sbCheckRateLimiting.toString());
  7474.                                     return false;
  7475.                                 }
  7476.                             }
  7477.                            
  7478.                             if(this.confCore.isConfigurazioneAllarmiEnabled()) {
  7479.                                 ricercaAll = new ConsoleSearch(true);
  7480.                                 List<ConfigurazioneAllarmeBean> allarmi = this.confCore.allarmiList(ricercaAll, RuoloPorta.DELEGATA, pd.getNome());
  7481.                                 if(allarmi!=null && !allarmi.isEmpty()) {
  7482.                                     sbCheckAllarmi = new StringBuilder();
  7483.                                     for(ConfigurazioneAllarmeBean allarme: allarmi) {
  7484.                                         if(allarme.getFiltro()!= null && allarme.getFiltro().getServizioApplicativoFruitore()!=null) {
  7485.                                             sbCheckAllarmi.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7486.                                             sbCheckAllarmi.append("- ");
  7487.                                             sbCheckAllarmi.append(allarme.getAlias()!=null ? allarme.getAlias() : allarme.getNome());
  7488.                                         }
  7489.                                     }
  7490.                                    
  7491.                                     if(sbCheckAllarmi.length() > 0) {
  7492.                                         this.pd.setMessage(prefix+CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_ALLARMI_AUTENTICAZIONE_TRASPORTO_MODIFICATA + sbCheckAllarmi.toString());
  7493.                                         return false;
  7494.                                     }
  7495.                                 }
  7496.                             }
  7497.                         }
  7498.                     }
  7499.                    
  7500.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(gestioneToken)){
  7501.                         if(pd.getAutorizzazioneToken()!=null && pd.getAutorizzazioneToken().getRuoli()!=null &&
  7502.                                 pd.getAutorizzazioneToken().getRuoli().sizeRuoloList()>0) {
  7503.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA);
  7504.                             return false;
  7505.                         }
  7506.                     }
  7507.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)){
  7508.                         if(pd.getAutorizzazioneToken()!=null && pd.getAutorizzazioneToken().getRuoli()!=null &&
  7509.                                 pd.getAutorizzazioneToken().getRuoli().sizeRuoloList()>0) {
  7510.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTORIZZAZIONE_TOKEN_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  7511.                             return false;
  7512.                         }
  7513.                     }
  7514.                     if((ServletUtils.isCheckBoxEnabled(autorizzazioneRuoliToken)==false) ){
  7515.                         if(pd.getAutorizzazioneToken()!=null && pd.getAutorizzazioneToken().getRuoli()!=null &&
  7516.                                 pd.getAutorizzazioneToken().getRuoli().sizeRuoloList()>0) {
  7517.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTORIZZAZIONE_TOKEN_DISABILITATA_PUNTUALMENTE);
  7518.                             return false;
  7519.                         }
  7520.                     }
  7521.                    
  7522.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(gestioneToken)){
  7523.                         if(pd.getAutorizzazioneToken()!=null && pd.getAutorizzazioneToken().getServiziApplicativi()!=null &&
  7524.                                 pd.getAutorizzazioneToken().getServiziApplicativi().sizeServizioApplicativoList()>0) {
  7525.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA);
  7526.                             return false;
  7527.                         }
  7528.                     }
  7529.                     if(pd.getGestioneToken()!=null && pd.getGestioneToken().getPolicy()!=null && !pd.getGestioneToken().getPolicy().equals(policy)){
  7530.                         if(pd.getAutorizzazioneToken()!=null && pd.getAutorizzazioneToken().getServiziApplicativi()!=null &&
  7531.                                 pd.getAutorizzazioneToken().getServiziApplicativi().sizeServizioApplicativoList()>0) {
  7532.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY);
  7533.                             return false;
  7534.                         }
  7535.                     }
  7536.                                        
  7537.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)){
  7538.                         if(pd.getAutorizzazioneToken()!=null && pd.getAutorizzazioneToken().getServiziApplicativi()!=null &&
  7539.                                 pd.getAutorizzazioneToken().getServiziApplicativi().sizeServizioApplicativoList()>0) {
  7540.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_TOKEN_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  7541.                             return false;
  7542.                         }
  7543.                     }
  7544.                     if((ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticatiToken)==false) ){
  7545.                         if(pd.getAutorizzazioneToken()!=null && pd.getAutorizzazioneToken().getServiziApplicativi()!=null &&
  7546.                                 pd.getAutorizzazioneToken().getServiziApplicativi().sizeServizioApplicativoList()>0) {
  7547.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_TOKEN_DISABILITATA_PUNTUALMENTE);
  7548.                             return false;
  7549.                         }
  7550.                     }
  7551.                    
  7552.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(gestioneToken)){
  7553.                         if(pd.getScope()!=null && pd.getScope().sizeScopeList()>0) {
  7554.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SCOPE_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA);
  7555.                             return false;
  7556.                         }
  7557.                     }
  7558.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)){
  7559.                         if(pd.getScope()!=null && pd.getScope().sizeScopeList()>0) {
  7560.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SCOPE_PRESENTI_AUTORIZZAZIONE_SCOPE_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  7561.                             return false;
  7562.                         }
  7563.                     }
  7564.                     if((ServletUtils.isCheckBoxEnabled(autorizzazioneScope)==false) ){
  7565.                         if(pd.getScope()!=null && pd.getScope().sizeScopeList()>0) {
  7566.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SCOPE_PRESENTI_AUTORIZZAZIONE_SCOPE_DISABILITATA_PUNTUALMENTE);
  7567.                             return false;
  7568.                         }
  7569.                     }
  7570.                    
  7571.                     boolean disabilitatoGestioneToken = AutorizzazioneUtilities.STATO_DISABILITATO.equals(gestioneToken);
  7572.                     boolean modificataTokenPolicy = pd.getGestioneToken()!=null && pd.getGestioneToken().getPolicy()!=null && !pd.getGestioneToken().getPolicy().equals(policy);
  7573.                    
  7574.                     if(disabilitatoGestioneToken || modificataTokenPolicy) {
  7575.                        
  7576.                         StringBuilder sbSoggetti = new StringBuilder();
  7577.                         if(sbCheckTrasformazioni==null) {
  7578.                             Trasformazioni trasformazioni = pd.getTrasformazioni();
  7579.                             if(trasformazioni != null) {
  7580.                                 sbCheckTrasformazioni = new StringBuilder();
  7581.                                 for(TrasformazioneRegola regola: trasformazioni.getRegolaList()) {
  7582.                                     if(regola.getApplicabilita()!= null) {
  7583.                                         if(regola.getApplicabilita().sizeSoggettoList() > 0) {
  7584.                                             sbSoggetti.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7585.                                             sbSoggetti.append("- ");
  7586.                                             sbSoggetti.append(regola.getNome());
  7587.                                         }
  7588.                                         if(regola.getApplicabilita().sizeServizioApplicativoList() > 0) {
  7589.                                             sbCheckTrasformazioni.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7590.                                             sbCheckTrasformazioni.append("- ");
  7591.                                             sbCheckTrasformazioni.append(regola.getNome());
  7592.                                         }
  7593.                                     }
  7594.                                 }
  7595.                             }
  7596.                         }
  7597.                         if(sbSoggetti!=null && sbSoggetti.length() > 0) {
  7598.                             this.pd.setMessage((disabilitatoGestioneToken ?
  7599.                                     CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TOKEN_MODIFICATA
  7600.                                     :
  7601.                                     CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY) +
  7602.                                     sbSoggetti.toString());
  7603.                             return false;
  7604.                         }
  7605.                         if(sbCheckTrasformazioni!=null && sbCheckTrasformazioni.length() > 0) {
  7606.                             this.pd.setMessage((disabilitatoGestioneToken ?
  7607.                                     CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TOKEN_MODIFICATA
  7608.                                     :
  7609.                                     CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY) +
  7610.                                     sbCheckTrasformazioni.toString());
  7611.                             return false;
  7612.                         }
  7613.                        
  7614.                         if(sbCheckRateLimiting==null) {
  7615.                             ConsoleSearch ricercaAll = new ConsoleSearch(true);
  7616.                             List<AttivazionePolicy> listaRateLimiting = this.confCore.attivazionePolicyList(ricercaAll, RuoloPolicy.DELEGATA, pd.getNome());
  7617.                             if(listaRateLimiting!=null && !listaRateLimiting.isEmpty()) {
  7618.                                 sbCheckRateLimiting = new StringBuilder();
  7619.                                 for(AttivazionePolicy policyRT: listaRateLimiting) {
  7620.                                     if(policyRT.getFiltro()!= null && policyRT.getFiltro().getServizioApplicativoFruitore()!=null) {
  7621.                                         sbCheckRateLimiting.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7622.                                         sbCheckRateLimiting.append("- ");
  7623.                                         sbCheckRateLimiting.append(policyRT.getAlias()!=null ? policyRT.getAlias() : policyRT.getIdActivePolicy());
  7624.                                     }
  7625.                                 }
  7626.                             }
  7627.                         }
  7628.                         if(sbCheckRateLimiting!=null && sbCheckRateLimiting.length() > 0) {
  7629.                             this.pd.setMessage((disabilitatoGestioneToken ?
  7630.                                     CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_RATE_LIMITING_AUTENTICAZIONE_TOKEN_MODIFICATA
  7631.                                     :
  7632.                                     CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_RATE_LIMITING_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY) +
  7633.                                     sbCheckRateLimiting.toString());
  7634.                             return false;
  7635.                         }
  7636.                        
  7637.                         if(this.confCore.isConfigurazioneAllarmiEnabled()) {
  7638.                             if(sbCheckAllarmi==null) {
  7639.                                 ConsoleSearch ricercaAll = new ConsoleSearch(true);
  7640.                                 List<ConfigurazioneAllarmeBean> allarmi = this.confCore.allarmiList(ricercaAll, RuoloPorta.DELEGATA, pd.getNome());
  7641.                                 if(allarmi!=null && !allarmi.isEmpty()) {
  7642.                                     sbCheckAllarmi = new StringBuilder();
  7643.                                     for(ConfigurazioneAllarmeBean allarme: allarmi) {
  7644.                                         if(allarme.getFiltro()!= null && allarme.getFiltro().getServizioApplicativoFruitore()!=null) {
  7645.                                             sbCheckAllarmi.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7646.                                             sbCheckAllarmi.append("- ");
  7647.                                             sbCheckAllarmi.append(allarme.getAlias()!=null ? allarme.getAlias() : allarme.getNome());
  7648.                                         }
  7649.                                     }
  7650.                                 }
  7651.                             }
  7652.                             if(sbCheckAllarmi!=null && sbCheckAllarmi.length() > 0) {
  7653.                                 this.pd.setMessage((disabilitatoGestioneToken ?
  7654.                                         CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_ALLARMI_AUTENTICAZIONE_TOKEN_MODIFICATA
  7655.                                         :
  7656.                                         CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_ALLARMI_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY) +
  7657.                                         sbCheckAllarmi.toString());
  7658.                                 return false;
  7659.                             }
  7660.                         }
  7661.                        
  7662.                     }
  7663.                 }
  7664.                 else {
  7665.                     PortaApplicativa pa = (PortaApplicativa) oggetto;
  7666.                     boolean profiloModi = this.isProfiloModIPA(protocollo);
  7667.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione) ){
  7668.                         if(pa.getRuoli()!=null && pa.getRuoli().sizeRuoloList()>0) {
  7669.                             this.pd.setMessage(profiloModi ?
  7670.                                 CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTORIZZAZIONE_CANALE_DISABILITATA_AUTORIZZAZIONE_GENERALE
  7671.                                 :
  7672.                                 CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTORIZZAZIONE_TRASPORTO_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  7673.                             return false;
  7674.                         }
  7675.                     }
  7676.                     if((ServletUtils.isCheckBoxEnabled(autorizzazioneRuoli)==false) ){
  7677.                         if(pa.getRuoli()!=null && pa.getRuoli().sizeRuoloList()>0) {
  7678.                             this.pd.setMessage(profiloModi ?
  7679.                                 CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTORIZZAZIONE_CANALE_DISABILITATA_PUNTUALMENTE
  7680.                                 :
  7681.                                 CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTORIZZAZIONE_TRASPORTO_DISABILITATA_PUNTUALMENTE);
  7682.                             return false;
  7683.                         }
  7684.                     }
  7685.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)){
  7686.                         if(pa.getSoggetti()!=null && pa.getSoggetti().sizeSoggettoList()>0) {
  7687.                             this.pd.setMessage(profiloModi ?
  7688.                                     CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_AUTORIZZAZIONE_CANALE_DISABILITATA_AUTORIZZAZIONE_GENERALE
  7689.                                     :
  7690.                                     CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_AUTORIZZAZIONE_TRASPORTO_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  7691.                             return false;
  7692.                         }
  7693.                         if(!profiloModi) {
  7694.                             if(pa.getServiziApplicativiAutorizzati()!=null && pa.getServiziApplicativiAutorizzati().sizeServizioApplicativoList()>0) {
  7695.                                 this.pd.setMessage(
  7696.                                         //profiloModi ?
  7697.                                         //  CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_CANALE_DISABILITATA_AUTORIZZAZIONE_GENERALE
  7698.                                         //  :
  7699.                                         CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_TRASPORTO_DISABILITATA_AUTORIZZAZIONE_GENERALE
  7700.                                     );
  7701.                                 return false;
  7702.                             }
  7703.                         }
  7704.                        
  7705.                         /*
  7706.                          * Vale solo per l'autenticazione
  7707.                         Trasformazioni trasformazioni = pa.getTrasformazioni();
  7708.                         if(trasformazioni != null) {
  7709.                             StringBuilder sbSoggetti = new StringBuilder();
  7710.                             StringBuilder sbApplicativi = new StringBuilder();
  7711.                            
  7712.                             for(TrasformazioneRegola regola: trasformazioni.getRegolaList()) {
  7713.                                 if(regola.getApplicabilita()!= null) {
  7714.                                     if(regola.getApplicabilita().sizeSoggettoList() > 0) {
  7715.                                         sbSoggetti.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7716.                                         sbSoggetti.append("- ");
  7717.                                         sbSoggetti.append(regola.getNome());
  7718.                                     }
  7719.                                    
  7720.                                     if(regola.getApplicabilita().sizeServizioApplicativoList() > 0) {
  7721.                                         sbApplicativi.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7722.                                         sbApplicativi.append("- ");
  7723.                                         sbApplicativi.append(regola.getNome());
  7724.                                     }
  7725.                                 }
  7726.                             }
  7727.                            
  7728.                             if(sbSoggetti.length() > 0) {
  7729.                                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_TRASFORMAZIONI_AUTORIZZAZIONE_DISABILITATA + sbSoggetti.toString());
  7730.                                 return false;
  7731.                             }
  7732.                            
  7733.                             if(sbApplicativi.length() > 0) {
  7734.                                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_TRASFORMAZIONI_AUTORIZZAZIONE_DISABILITATA + sbApplicativi.toString());
  7735.                                 return false;
  7736.                             }
  7737.                         }
  7738.                         */
  7739.                     }
  7740.                     if((ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticati)==false) ){
  7741.                         if(pa.getSoggetti()!=null && pa.getSoggetti().sizeSoggettoList()>0) {
  7742.                             this.pd.setMessage(profiloModi ?
  7743.                                     CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_AUTORIZZAZIONE_CANALE_DISABILITATA_PUNTUALMENTE
  7744.                                     :
  7745.                                     CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_AUTORIZZAZIONE_TRASPORTO_DISABILITATA_PUNTUALMENTE);
  7746.                             return false;
  7747.                         }
  7748.                         if(!profiloModi) {
  7749.                             if(pa.getServiziApplicativiAutorizzati()!=null && pa.getServiziApplicativiAutorizzati().sizeServizioApplicativoList()>0) {
  7750.                                 this.pd.setMessage(
  7751.                                     //profiloModi ?
  7752.                                     //CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_CANALE_DISABILITATA_PUNTUALMENTE
  7753.                                     //:
  7754.                                     CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_TRASPORTO_DISABILITATA_PUNTUALMENTE
  7755.                                     );
  7756.                                 return false;
  7757.                             }
  7758.                         }
  7759.                     }
  7760.                     StringBuilder sbCheckTrasformazioni = null;
  7761.                     StringBuilder sbCheckRateLimiting = null;
  7762.                     StringBuilder sbCheckAllarmi = null;
  7763.                     if(isSupportatoAutenticazione && pa.getAutenticazione()!=null ){
  7764.                        
  7765.                         String prefix = "";
  7766.                        
  7767.                         boolean modificataAutenticazione = !pa.getAutenticazione().equals(autenticazione);
  7768.                         if(!modificataAutenticazione) {
  7769.                             if (ConnettoriCostanti.AUTENTICAZIONE_TIPO_APIKEY.equals(autenticazione)) {
  7770.                                 // verifico che non sia stato cambiato 'AppId'
  7771.                                 ApiKeyState immagineAttuale = new ApiKeyState(autenticazioneParametroList);
  7772.                                 ApiKeyState immaginePa = new ApiKeyState(this.porteApplicativeCore.getParametroAutenticazione(autenticazione, pa.getProprietaAutenticazioneList()));
  7773.                                 if(immagineAttuale.appIdSelected!=immaginePa.appIdSelected) {
  7774.                                     modificataAutenticazione = true;
  7775.                                     prefix = "(Modifica "+ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID+") ";
  7776.                                 }
  7777.                             }
  7778.                         }
  7779.                        
  7780.                         // modiifcata autenticazione
  7781.                         if(modificataAutenticazione) {
  7782.                             if(pa.getSoggetti()!=null && pa.getSoggetti().sizeSoggettoList()>0) {
  7783.                                 this.pd.setMessage(prefix+
  7784.                                         (profiloModi ?
  7785.                                                 CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_AUTENTICAZIONE_CANALE_MODIFICATA
  7786.                                                 :
  7787.                                                 CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_AUTENTICAZIONE_TRASPORTO_MODIFICATA));
  7788.                                 return false;
  7789.                             }
  7790.                             if(pa.getServiziApplicativiAutorizzati()!=null && pa.getServiziApplicativiAutorizzati().sizeServizioApplicativoList()>0) {
  7791.                                 this.pd.setMessage(prefix+
  7792.                                         (profiloModi ?
  7793.                                                 CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTENTICAZIONE_CANALE_MODIFICATA
  7794.                                                 :
  7795.                                                 CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTENTICAZIONE_TRASPORTO_MODIFICATA));
  7796.                                 return false;
  7797.                             }
  7798.                            
  7799.                             Trasformazioni trasformazioni = pa.getTrasformazioni();
  7800.                             if(trasformazioni != null) {
  7801.                                 StringBuilder sbSoggetti = new StringBuilder();
  7802.                                 sbCheckTrasformazioni = new StringBuilder();
  7803.                                
  7804.                                 for(TrasformazioneRegola regola: trasformazioni.getRegolaList()) {
  7805.                                     if(regola.getApplicabilita()!= null) {
  7806.                                         if(regola.getApplicabilita().sizeSoggettoList() > 0) {
  7807.                                             sbSoggetti.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7808.                                             sbSoggetti.append("- ");
  7809.                                             sbSoggetti.append(regola.getNome());
  7810.                                         }
  7811.                                        
  7812.                                         if(regola.getApplicabilita().sizeServizioApplicativoList() > 0) {
  7813.                                             sbCheckTrasformazioni.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7814.                                             sbCheckTrasformazioni.append("- ");
  7815.                                             sbCheckTrasformazioni.append(regola.getNome());
  7816.                                         }
  7817.                                     }
  7818.                                 }
  7819.                                
  7820.                                 if(sbSoggetti.length() > 0) {
  7821.                                     this.pd.setMessage(prefix+
  7822.                                             (profiloModi ?
  7823.                                                     CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_CANALE_MODIFICATA
  7824.                                                     :
  7825.                                                     CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TRASPORTO_MODIFICATA) +
  7826.                                             sbSoggetti.toString());
  7827.                                     return false;
  7828.                                 }
  7829.                                
  7830.                                 if(sbCheckTrasformazioni.length() > 0) {
  7831.                                     this.pd.setMessage(prefix+
  7832.                                             (profiloModi ?
  7833.                                                     CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_CANALE_MODIFICATA
  7834.                                                     :
  7835.                                                     CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TRASPORTO_MODIFICATA) +
  7836.                                             sbCheckTrasformazioni.toString());
  7837.                                     return false;
  7838.                                 }
  7839.                             }
  7840.                            
  7841.                             ConsoleSearch ricercaAll = new ConsoleSearch(true);
  7842.                             List<AttivazionePolicy> listaRateLimiting = this.confCore.attivazionePolicyList(ricercaAll, RuoloPolicy.APPLICATIVA, pa.getNome());
  7843.                             if(listaRateLimiting!=null && !listaRateLimiting.isEmpty()) {
  7844.                                 sbCheckRateLimiting = new StringBuilder();
  7845.                                 for(AttivazionePolicy policyRT: listaRateLimiting) {
  7846.                                     if(policyRT.getFiltro()!= null &&
  7847.                                             (policyRT.getFiltro().getServizioApplicativoFruitore()!=null || policyRT.getFiltro().getNomeFruitore()!=null)) {
  7848.                                         sbCheckRateLimiting.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7849.                                         sbCheckRateLimiting.append("- ");
  7850.                                         sbCheckRateLimiting.append(policyRT.getAlias()!=null ? policyRT.getAlias() : policyRT.getIdActivePolicy());
  7851.                                     }
  7852.                                 }
  7853.                                
  7854.                                 if(sbCheckRateLimiting.length() > 0) {
  7855.                                     this.pd.setMessage(prefix+
  7856.                                             (profiloModi ?
  7857.                                                     CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_RATE_LIMITING_AUTENTICAZIONE_CANALE_MODIFICATA
  7858.                                                     :
  7859.                                                     CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_RATE_LIMITING_AUTENTICAZIONE_TRASPORTO_MODIFICATA) +
  7860.                                             sbCheckRateLimiting.toString());
  7861.                                     return false;
  7862.                                 }
  7863.                             }
  7864.                            
  7865.                             if(this.confCore.isConfigurazioneAllarmiEnabled()) {
  7866.                                 ricercaAll = new ConsoleSearch(true);
  7867.                                 List<ConfigurazioneAllarmeBean> allarmi = this.confCore.allarmiList(ricercaAll, RuoloPorta.APPLICATIVA, pa.getNome());
  7868.                                 if(allarmi!=null && !allarmi.isEmpty()) {
  7869.                                     sbCheckAllarmi = new StringBuilder();
  7870.                                     for(ConfigurazioneAllarmeBean policyRT: allarmi) {
  7871.                                         if(policyRT.getFiltro()!= null &&
  7872.                                                 (policyRT.getFiltro().getServizioApplicativoFruitore()!=null || policyRT.getFiltro().getNomeFruitore()!=null)) {
  7873.                                             sbCheckAllarmi.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7874.                                             sbCheckAllarmi.append("- ");
  7875.                                             sbCheckAllarmi.append(policyRT.getAlias()!=null ? policyRT.getAlias() : policyRT.getNome());
  7876.                                         }
  7877.                                     }
  7878.                                    
  7879.                                     if(sbCheckAllarmi.length() > 0) {
  7880.                                         this.pd.setMessage(prefix+
  7881.                                                 (profiloModi ?
  7882.                                                         CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_ALLARMI_AUTENTICAZIONE_CANALE_MODIFICATA
  7883.                                                         :
  7884.                                                         CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_ALLARMI_AUTENTICAZIONE_TRASPORTO_MODIFICATA) +
  7885.                                                 sbCheckAllarmi.toString());
  7886.                                         return false;
  7887.                                     }
  7888.                                 }
  7889.                             }
  7890.                         }
  7891.                     }

  7892.                     boolean modiSicurezzaMessaggio = false;
  7893.                     try {
  7894.                         IDServizio idAps = IDServizioFactory.getInstance().getIDServizioFromValues(pa.getServizio().getTipo(), pa.getServizio().getNome(),
  7895.                                 pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario(),
  7896.                                 pa.getServizio().getVersione());
  7897.                         if(idAps!=null) {
  7898.                             AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idAps);
  7899.                             idAps.setPortType(asps.getPortType());
  7900.                             idAps.setUriAccordoServizioParteComune(asps.getAccordoServizioParteComune());
  7901.                            
  7902.                             IProtocolFactory<?> protocolFactory = ProtocolFactoryManager.getInstance().getProtocolFactoryByName(protocollo);
  7903.                             IConsoleDynamicConfiguration consoleDynamicConfiguration = protocolFactory.createDynamicConfigurationConsole();
  7904.                             IRegistryReader registryReader = this.apcCore.getRegistryReader(protocolFactory);
  7905.                             IConfigIntegrationReader configRegistryReader = this.apcCore.getConfigIntegrationReader(protocolFactory);
  7906.                             ConsoleConfiguration consoleConfiguration = consoleDynamicConfiguration.getDynamicConfigAccordoServizioParteSpecifica(ConsoleOperationType.CHANGE, this,
  7907.                                     registryReader, configRegistryReader, idAps );
  7908.                             if(consoleConfiguration!=null && consoleConfiguration.getConsoleItem()!=null && !consoleConfiguration.getConsoleItem().isEmpty()) {
  7909.                                 modiSicurezzaMessaggio = true;
  7910.                             }
  7911.                         }
  7912.                     }catch(Exception t) {
  7913.                         this.logError(t.getMessage(),t);
  7914.                     }
  7915.                    
  7916.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(gestioneToken)){
  7917.                         if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getRuoli()!=null &&
  7918.                                 pa.getAutorizzazioneToken().getRuoli().sizeRuoloList()>0) {
  7919.                             if(profiloModi) {
  7920.                                 if(!modiSicurezzaMessaggio) {
  7921.                                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA_MODI);
  7922.                                     return false;
  7923.                                 }
  7924.                             }
  7925.                             else {
  7926.                                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA);
  7927.                                 return false;
  7928.                             }
  7929.                         }
  7930.                     }
  7931.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)){
  7932.                         if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getRuoli()!=null &&
  7933.                                 pa.getAutorizzazioneToken().getRuoli().sizeRuoloList()>0) {
  7934.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTORIZZAZIONE_TOKEN_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  7935.                             return false;
  7936.                         }
  7937.                     }
  7938.                     if((ServletUtils.isCheckBoxEnabled(autorizzazioneRuoliToken)==false) ){
  7939.                         if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getRuoli()!=null &&
  7940.                                 pa.getAutorizzazioneToken().getRuoli().sizeRuoloList()>0) {
  7941.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_RUOLI_PRESENTI_AUTORIZZAZIONE_TOKEN_DISABILITATA_PUNTUALMENTE);
  7942.                             return false;
  7943.                         }
  7944.                     }
  7945.                    
  7946.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(gestioneToken)){
  7947.                         if(profiloModi) {
  7948.                             if(!modiSicurezzaMessaggio) {
  7949.                                 if(pa.getServiziApplicativiAutorizzati()!=null && pa.getServiziApplicativiAutorizzati().sizeServizioApplicativoList()>0) {
  7950.                                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA_MODI);
  7951.                                     return false;
  7952.                                 }
  7953.                             }
  7954.                         }
  7955.                         else if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getServiziApplicativi()!=null &&
  7956.                                 pa.getAutorizzazioneToken().getServiziApplicativi().sizeServizioApplicativoList()>0) {
  7957.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA);
  7958.                             return false;
  7959.                         }
  7960.                     }
  7961.                     if(pa.getGestioneToken()!=null && pa.getGestioneToken().getPolicy()!=null && !pa.getGestioneToken().getPolicy().equals(policy)){
  7962.                         if(profiloModi) {
  7963.                             if(pa.getServiziApplicativiAutorizzati()!=null && pa.getServiziApplicativiAutorizzati().sizeServizioApplicativoList()>0) {
  7964.                                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY_MODI);
  7965.                                 return false;
  7966.                             }
  7967.                         }
  7968.                         else if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getServiziApplicativi()!=null &&
  7969.                                 pa.getAutorizzazioneToken().getServiziApplicativi().sizeServizioApplicativoList()>0) {
  7970.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY);
  7971.                             return false;
  7972.                         }
  7973.                     }
  7974.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)){

  7975.                         if(profiloModi) {
  7976.                             if(pa.getServiziApplicativiAutorizzati()!=null && pa.getServiziApplicativiAutorizzati().sizeServizioApplicativoList()>0) {
  7977.                                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_MESSAGGIO_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  7978.                                 return false;
  7979.                             }
  7980.                         }
  7981.                         else if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getServiziApplicativi()!=null &&
  7982.                                     pa.getAutorizzazioneToken().getServiziApplicativi().sizeServizioApplicativoList()>0) {
  7983.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_TOKEN_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  7984.                             return false;
  7985.                         }
  7986.                                                
  7987.                         /*
  7988.                          * Vale solo per l'autenticazione
  7989.                         Trasformazioni trasformazioni = pa.getTrasformazioni();
  7990.                         if(trasformazioni != null) {
  7991.                             StringBuilder sbSoggetti = new StringBuilder();
  7992.                             StringBuilder sbApplicativi = new StringBuilder();
  7993.                            
  7994.                             for(TrasformazioneRegola regola: trasformazioni.getRegolaList()) {
  7995.                                 if(regola.getApplicabilita()!= null) {
  7996.                                     if(regola.getApplicabilita().sizeSoggettoList() > 0) {
  7997.                                         sbSoggetti.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  7998.                                         sbSoggetti.append("- ");
  7999.                                         sbSoggetti.append(regola.getNome());
  8000.                                     }
  8001.                                    
  8002.                                     if(regola.getApplicabilita().sizeServizioApplicativoList() > 0) {
  8003.                                         sbApplicativi.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  8004.                                         sbApplicativi.append("- ");
  8005.                                         sbApplicativi.append(regola.getNome());
  8006.                                     }
  8007.                                 }
  8008.                             }
  8009.                            
  8010.                             if(sbSoggetti.length() > 0) {
  8011.                                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_TRASFORMAZIONI_AUTORIZZAZIONE_DISABILITATA + sbSoggetti.toString());
  8012.                                 return false;
  8013.                             }
  8014.                            
  8015.                             if(sbApplicativi.length() > 0) {
  8016.                                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_TRASFORMAZIONI_AUTORIZZAZIONE_DISABILITATA + sbApplicativi.toString());
  8017.                                 return false;
  8018.                             }
  8019.                         }
  8020.                         */
  8021.                     }
  8022.                     if((ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticatiToken)==false) ){

  8023.                         if(profiloModi) {
  8024.                             if(pa.getServiziApplicativiAutorizzati()!=null && pa.getServiziApplicativiAutorizzati().sizeServizioApplicativoList()>0) {
  8025.                                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_MESSAGGIO_DISABILITATA_PUNTUALMENTE);
  8026.                                 return false;
  8027.                             }
  8028.                         }
  8029.                         else if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getServiziApplicativi()!=null &&
  8030.                                     pa.getAutorizzazioneToken().getServiziApplicativi().sizeServizioApplicativoList()>0) {
  8031.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_AUTORIZZAZIONE_TOKEN_DISABILITATA_PUNTUALMENTE);
  8032.                             return false;
  8033.                         }
  8034.                        
  8035.                     }
  8036.                    
  8037.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(gestioneToken)){
  8038.                         if(pa.getScope()!=null && pa.getScope().sizeScopeList()>0) {
  8039.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SCOPE_PRESENTI_AUTENTICAZIONE_TOKEN_MODIFICATA);
  8040.                             return false;
  8041.                         }
  8042.                     }
  8043.                     if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)){
  8044.                         if(pa.getScope()!=null && pa.getScope().sizeScopeList()>0) {
  8045.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SCOPE_PRESENTI_AUTORIZZAZIONE_SCOPE_DISABILITATA_AUTORIZZAZIONE_GENERALE);
  8046.                             return false;
  8047.                         }
  8048.                     }
  8049.                     if((ServletUtils.isCheckBoxEnabled(autorizzazioneScope)==false) ){
  8050.                         if(pa.getScope()!=null && pa.getScope().sizeScopeList()>0) {
  8051.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_SCOPE_PRESENTI_AUTORIZZAZIONE_SCOPE_DISABILITATA_PUNTUALMENTE);
  8052.                             return false;
  8053.                         }
  8054.                     }
  8055.                    
  8056.                     boolean disabilitatoGestioneToken = AutorizzazioneUtilities.STATO_DISABILITATO.equals(gestioneToken);
  8057.                     boolean modificataTokenPolicy = pa.getGestioneToken()!=null && pa.getGestioneToken().getPolicy()!=null && !pa.getGestioneToken().getPolicy().equals(policy);
  8058.                    
  8059.                     if(disabilitatoGestioneToken || modificataTokenPolicy) {
  8060.                        
  8061.                         StringBuilder sbSoggetti = new StringBuilder();
  8062.                         if(sbCheckTrasformazioni==null) {
  8063.                             Trasformazioni trasformazioni = pa.getTrasformazioni();
  8064.                             if(trasformazioni != null) {
  8065.                                 sbCheckTrasformazioni = new StringBuilder();
  8066.                                
  8067.                                 for(TrasformazioneRegola regola: trasformazioni.getRegolaList()) {
  8068.                                     if(regola.getApplicabilita()!= null) {
  8069.                                         if(regola.getApplicabilita().sizeSoggettoList() > 0) {
  8070.                                             sbSoggetti.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  8071.                                             sbSoggetti.append("- ");
  8072.                                             sbSoggetti.append(regola.getNome());
  8073.                                         }
  8074.                                         if(regola.getApplicabilita().sizeServizioApplicativoList() > 0) {
  8075.                                             sbCheckTrasformazioni.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  8076.                                             sbCheckTrasformazioni.append("- ");
  8077.                                             sbCheckTrasformazioni.append(regola.getNome());
  8078.                                         }
  8079.                                     }
  8080.                                 }
  8081.                             }
  8082.                         }
  8083.                         if(sbSoggetti!=null && sbSoggetti.length() > 0) {
  8084.                             this.pd.setMessage((disabilitatoGestioneToken ?
  8085.                                     CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TOKEN_MODIFICATA
  8086.                                     :
  8087.                                     CostantiControlStation.MESSAGGIO_ERRORE_SOGGETTI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY) +
  8088.                                     sbSoggetti.toString());
  8089.                             return false;
  8090.                         }
  8091.                         if(sbCheckTrasformazioni!=null && sbCheckTrasformazioni.length() > 0) {
  8092.                             this.pd.setMessage((disabilitatoGestioneToken ?
  8093.                                             CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TOKEN_MODIFICATA
  8094.                                             :
  8095.                                             CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_TRASFORMAZIONI_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY) +
  8096.                                     sbCheckTrasformazioni.toString());
  8097.                             return false;
  8098.                         }
  8099.                        
  8100.                         if(sbCheckRateLimiting==null) {
  8101.                             ConsoleSearch ricercaAll = new ConsoleSearch(true);
  8102.                             List<AttivazionePolicy> listaRateLimiting = this.confCore.attivazionePolicyList(ricercaAll, RuoloPolicy.APPLICATIVA, pa.getNome());
  8103.                             if(listaRateLimiting!=null && !listaRateLimiting.isEmpty()) {
  8104.                                 sbCheckRateLimiting = new StringBuilder();
  8105.                                 for(AttivazionePolicy policyRT: listaRateLimiting) {
  8106.                                     if(policyRT.getFiltro()!= null &&
  8107.                                             (policyRT.getFiltro().getServizioApplicativoFruitore()!=null || policyRT.getFiltro().getNomeFruitore()!=null)) {
  8108.                                         sbCheckRateLimiting.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  8109.                                         sbCheckRateLimiting.append("- ");
  8110.                                         sbCheckRateLimiting.append(policyRT.getAlias()!=null ? policyRT.getAlias() : policyRT.getIdActivePolicy());
  8111.                                     }
  8112.                                 }
  8113.                             }
  8114.                         }
  8115.                         if(sbCheckRateLimiting!=null && sbCheckRateLimiting.length() > 0) {
  8116.                             this.pd.setMessage((disabilitatoGestioneToken ?
  8117.                                             CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_RATE_LIMITING_AUTENTICAZIONE_TOKEN_MODIFICATA
  8118.                                             :
  8119.                                             CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_RATE_LIMITING_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY) +
  8120.                                     sbCheckRateLimiting.toString());
  8121.                             return false;
  8122.                         }
  8123.                        
  8124.                         if(this.confCore.isConfigurazioneAllarmiEnabled()) {
  8125.                             if(sbCheckAllarmi==null) {
  8126.                                 ConsoleSearch ricercaAll = new ConsoleSearch(true);
  8127.                                 List<ConfigurazioneAllarmeBean> allarmi = this.confCore.allarmiList(ricercaAll, RuoloPorta.APPLICATIVA, pa.getNome());
  8128.                                 if(allarmi!=null && !allarmi.isEmpty()) {
  8129.                                     sbCheckAllarmi = new StringBuilder();
  8130.                                     for(ConfigurazioneAllarmeBean policyRT: allarmi) {
  8131.                                         if(policyRT.getFiltro()!= null &&
  8132.                                                 (policyRT.getFiltro().getServizioApplicativoFruitore()!=null || policyRT.getFiltro().getNomeFruitore()!=null)) {
  8133.                                             sbCheckAllarmi.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  8134.                                             sbCheckAllarmi.append("- ");
  8135.                                             sbCheckAllarmi.append(policyRT.getAlias()!=null ? policyRT.getAlias() : policyRT.getNome());
  8136.                                         }
  8137.                                     }
  8138.                                 }
  8139.                             }
  8140.                             if(sbCheckAllarmi!=null && sbCheckAllarmi.length() > 0) {
  8141.                                 this.pd.setMessage((disabilitatoGestioneToken ?
  8142.                                                 CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_ALLARMI_AUTENTICAZIONE_TOKEN_MODIFICATA
  8143.                                                 :
  8144.                                                 CostantiControlStation.MESSAGGIO_ERRORE_APPLICATIVI_PRESENTI_ALLARMI_AUTENTICAZIONE_TOKEN_MODIFICATA_TOKEN_POLICY) +
  8145.                                         sbCheckAllarmi.toString());
  8146.                                 return false;
  8147.                             }
  8148.                         }
  8149.                     }
  8150.                 }
  8151.             }
  8152.            
  8153.             // tipo autorizzazione custom
  8154.             if(autorizzazione != null && autorizzazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM)) {
  8155.                 String autorizzazioneCustom = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM);
  8156.                
  8157.                 if(StringUtils.isEmpty(autorizzazioneCustom) || CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_VALORE_UNDEFINED.equals(autorizzazioneCustom)){
  8158.                     if(this.confCore.isConfigurazionePluginsEnabled()) {
  8159.                         this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_CUSTOM_NON_INDICATA);
  8160.                     }
  8161.                     else {
  8162.                         this.pd.setMessage(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM+" obbligatorio per il tipo di autorizzazione selezionato");
  8163.                     }
  8164.                     return false;
  8165.                 }
  8166.                
  8167.                 if(this.checkLength255(autorizzazioneCustom,CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CUSTOM)==false) {
  8168.                     return false;
  8169.                 }
  8170.             }
  8171.            
  8172.             if(autorizzazioneContenutiStato!= null && !autorizzazioneContenutiStato.equals(StatoFunzionalita.DISABILITATO.getValue())) {
  8173.                 if(autorizzazioneContenutiStato.equals(StatoFunzionalita.ABILITATO.getValue())) {
  8174.                     if(autorizzazioneContenutiProperties==null || "".equals(autorizzazioneContenutiProperties)) {
  8175.                         this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_CONTENUTO_NON_INDICATA);
  8176.                         return false;
  8177.                     }
  8178.                     if(autorizzazioneContenutiProperties!=null) {
  8179.                         Scanner scanner = new Scanner(autorizzazioneContenutiProperties);
  8180.                         try {
  8181.                             while (scanner.hasNextLine()) {
  8182.                                 String line = scanner.nextLine();
  8183.                                 if(line==null || line.trim().equals("")) {
  8184.                                     continue;
  8185.                                 }
  8186.                                 line = line.trim();
  8187.                                 if(line!=null && line.startsWith("#")) {
  8188.                                     continue;
  8189.                                 }
  8190.                                 if(line.contains("=")==false) {
  8191.                                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_CONTENUTO_TOKEN_NON_VALIDI+line);
  8192.                                     return false;
  8193.                                 }
  8194.                                 String [] tmp = line.split("=");
  8195.                                 if(tmp==null || tmp.length<1) {
  8196.                                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_CONTENUTO_TOKEN_NON_VALIDI+line);
  8197.                                     return false;
  8198.                                 }
  8199.                                 String key = tmp[0];
  8200.                                 if(key==null || !key.contains("$")) {
  8201.                                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_CONTENUTO_TOKEN_NON_VALIDI_RISORSA_NON_DEFINITA_PREFIX+line);
  8202.                                     return false;
  8203.                                 }
  8204.                                 if(key.length()>255) {
  8205.                                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_CONTENUTO_TOKEN_NON_VALIDI_LUNGHEZZA_MASSIMA_SUPERATA_RISORSA+line);
  8206.                                     return false;
  8207.                                 }
  8208.                                 if(tmp.length<2 || tmp[1]==null || tmp[1].equals("")) {
  8209.                                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_CONTENUTO_TOKEN_NON_VALIDI_VALORE_NON_DEFINITO+line);
  8210.                                     return false;
  8211.                                 }
  8212.                                 String value = tmp[1];
  8213.                                 if(value.length()>255) {
  8214.                                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_CONTENUTO_TOKEN_NON_VALIDI_LUNGHEZZA_MASSIMA_SUPERATA_VALORE+line);
  8215.                                     return false;
  8216.                                 }
  8217.                             }
  8218.                         }finally {
  8219.                             scanner.close();
  8220.                         }
  8221.                        
  8222.                         // Viene gestita come singole proprieta
  8223. //                      if(this.checkLength(autorizzazioneContenutiProperties, CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_CONTROLLI_AUTORIZZAZIONE,-1,4000)==false) {
  8224. //                          return false;
  8225. //                      }
  8226.                     }
  8227.                 }
  8228.                
  8229.                 if(autorizzazioneContenutiStato.equals(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_CUSTOM)) {
  8230.                     if(StringUtils.isEmpty(autorizzazioneContenuto) || CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_VALORE_UNDEFINED.equals(autorizzazioneContenuto)){
  8231.                         if(this.confCore.isConfigurazionePluginsEnabled()) {
  8232.                             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AUTORIZZAZIONE_CONTENUTO_CUSTOM_NON_INDICATA);
  8233.                         }
  8234.                         else {
  8235.                             this.pd.setMessage(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM+" obbligatorio per il tipo di autorizzazione selezionato");
  8236.                         }
  8237.                         return false;
  8238.                     }
  8239.                    
  8240.                     if(this.checkLength255(autorizzazioneContenuto, CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_CONTROLLI_AUTORIZZAZIONE_CUSTOM)==false) {
  8241.                         return false;
  8242.                     }
  8243.                 }
  8244.             }
  8245.            
  8246.             return true;

  8247.         } catch (Exception e) {
  8248.             this.logError("Exception: " + e.getMessage(), e);
  8249.             throw new DriverControlStationException(e);
  8250.         }
  8251.     }
  8252.    
  8253.     private boolean checkAttributes(String [] attributeAuthoritySelezionate, String attributeAuthorityAttributi) {
  8254.         if(attributeAuthoritySelezionate!=null && attributeAuthoritySelezionate.length>1) {
  8255.             Properties properties = null;
  8256.             if(attributeAuthorityAttributi!=null && StringUtils.isNotEmpty(attributeAuthorityAttributi)) {
  8257.                 properties = PropertiesUtilities.convertTextToProperties(attributeAuthorityAttributi);
  8258.                 if(properties!=null && properties.size()>0) {
  8259.                     for (Object oKey : properties.keySet()) {
  8260.                         if(oKey instanceof String) {
  8261.                             String aaName = (String) oKey;
  8262.                             boolean find = false;
  8263.                             for (String aa : attributeAuthoritySelezionate) {
  8264.                                 if(aa.equals(aaName)) {
  8265.                                     find = true;
  8266.                                     break;
  8267.                                 }
  8268.                             }
  8269.                             if(!find) {
  8270.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_ATTRIBUTE_AUTHORITY_NON_ESISTENTE_XX,  
  8271.                                         aaName, CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI));
  8272.                                 return false;
  8273.                             }
  8274.                             String p = properties.getProperty(aaName);
  8275.                             List<String> attributi = DBUtils.convertToList(p);
  8276.                             if(attributi==null || attributi.isEmpty()) {
  8277.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_ATTRIBUTE_AUTHORITY_VUOTA_XX,  
  8278.                                         aaName, CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI));
  8279.                                 return false;
  8280.                             }
  8281.                         }
  8282.                     }
  8283.                 }
  8284.                 else {
  8285.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_ATTRIBUTE_AUTHORITY_NON_ESISTENTE_XX,  
  8286.                             attributeAuthorityAttributi, CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI));
  8287.                     return false;  
  8288.                 }
  8289.             }
  8290.         }
  8291.         return true;
  8292.     }
  8293.    
  8294.    
  8295.     // Stato PA
  8296.    
  8297.     public String getStatoMessageSecurityPortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8298.        
  8299.         if(paAssociata==null) {
  8300.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8301.         }
  8302.        
  8303.         String statoMessageSecurity = paAssociata.getStatoMessageSecurity();
  8304.         return statoMessageSecurity;
  8305.     }


  8306.     public String getStatoDumpPortaApplicativa(PortaApplicativa paAssociata, boolean usePrefixDefault) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  8307.        
  8308.         if(paAssociata==null) {
  8309.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8310.         }
  8311.        
  8312.         DumpConfigurazione dumpConfigurazione = paAssociata.getDump();
  8313.         String statoDump = dumpConfigurazione == null ? this.getDumpLabelDefault(usePrefixDefault, true) :
  8314.             (this.isDumpConfigurazioneAbilitato(dumpConfigurazione) ? CostantiControlStation.DEFAULT_VALUE_ABILITATO : CostantiControlStation.DEFAULT_VALUE_DISABILITATO);
  8315.         return statoDump;
  8316.     }
  8317.    
  8318.     public String getStatoDumpRichiestaPortaApplicativa(PortaApplicativa paAssociata, boolean usePrefixDefault) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  8319.        
  8320.         if(paAssociata==null) {
  8321.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8322.         }
  8323.        
  8324.         DumpConfigurazione dumpConfigurazione = paAssociata.getDump();
  8325.         String statoDump = dumpConfigurazione == null ? this.getDumpLabelDefault(usePrefixDefault, true) :
  8326.             (this.isDumpConfigurazioneAbilitato(dumpConfigurazione, false) ? CostantiControlStation.DEFAULT_VALUE_ABILITATO : CostantiControlStation.DEFAULT_VALUE_DISABILITATO);
  8327.         return statoDump;
  8328.     }
  8329.    
  8330.     public String getStatoDumpRispostaPortaApplicativa(PortaApplicativa paAssociata, boolean usePrefixDefault) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  8331.        
  8332.         if(paAssociata==null) {
  8333.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8334.         }
  8335.        
  8336.         DumpConfigurazione dumpConfigurazione = paAssociata.getDump();
  8337.         String statoDump = dumpConfigurazione == null ? this.getDumpLabelDefault(usePrefixDefault, true) :
  8338.             (this.isDumpConfigurazioneAbilitato(dumpConfigurazione, true) ? CostantiControlStation.DEFAULT_VALUE_ABILITATO : CostantiControlStation.DEFAULT_VALUE_DISABILITATO);
  8339.         return statoDump;
  8340.     }


  8341.     public String getStatoTracciamentoPortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8342.        
  8343.         if(paAssociata==null) {
  8344.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8345.         }
  8346.        
  8347.         String statoTracciamento = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CORRELAZIONE_APPLICATIVA_DISABILITATA;
  8348.        
  8349.         boolean isCorrelazioneApplicativaAbilitataReq = false;
  8350.         if (paAssociata.getCorrelazioneApplicativa() != null)
  8351.             isCorrelazioneApplicativaAbilitataReq = paAssociata.getCorrelazioneApplicativa().sizeElementoList() > 0;
  8352.            
  8353.         boolean isCorrelazioneApplicativaAbilitataRes = false;
  8354.         if (paAssociata.getCorrelazioneApplicativaRisposta() != null)
  8355.             isCorrelazioneApplicativaAbilitataRes = paAssociata.getCorrelazioneApplicativaRisposta().sizeElementoList() > 0;
  8356.            
  8357.         boolean tracciamento = false;
  8358.         if(paAssociata.getTracciamento()!=null &&
  8359.                 (
  8360.                     (
  8361.                             paAssociata.getTracciamento().getEsiti()!=null
  8362.                             &&
  8363.                             !(EsitiConfigUtils.TUTTI_ESITI_DISABILITATI+"").equals(paAssociata.getTracciamento().getEsiti())
  8364.                     )
  8365.                     ||
  8366.                     paAssociata.getTracciamento().getSeverita()!=null)
  8367.                 ) {
  8368.             tracciamento = true;
  8369.         }
  8370.        
  8371.         if(tracciamento || isCorrelazioneApplicativaAbilitataReq || isCorrelazioneApplicativaAbilitataRes)
  8372.             statoTracciamento = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CORRELAZIONE_APPLICATIVA_ABILITATA;
  8373.         else
  8374.             statoTracciamento = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CORRELAZIONE_APPLICATIVA_DISABILITATA;
  8375.         return statoTracciamento;
  8376.     }
  8377.    
  8378.     public boolean isRidefinitoTransazioniRegistratePortaApplicativa(PortaApplicativa paAssociata) {
  8379.         return paAssociata.getTracciamento()!=null && paAssociata.getTracciamento().getEsiti()!=null;
  8380.     }
  8381.    
  8382.     public String getStatoTransazioniRegistratePortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8383.        
  8384.         if(paAssociata==null) {
  8385.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8386.         }
  8387.        
  8388.         if(paAssociata.getTracciamento()!=null && paAssociata.getTracciamento().getEsiti()!=null) {
  8389.             return CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO;
  8390.         }
  8391.         else {
  8392.             return CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_DEFAULT;
  8393.         }
  8394.     }
  8395.    
  8396.     public boolean isRidefinitoMessaggiDiagnosticiPortaApplicativa(PortaApplicativa paAssociata) {
  8397.         return paAssociata.getTracciamento()!=null && paAssociata.getTracciamento().getSeverita()!=null;
  8398.     }
  8399.    
  8400.     public String getStatoMessaggiDiagnosticiPortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8401.        
  8402.         if(paAssociata==null) {
  8403.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8404.         }
  8405.        
  8406.         if(paAssociata.getTracciamento()!=null && paAssociata.getTracciamento().getSeverita()!=null) {
  8407.             return paAssociata.getTracciamento().getSeverita().getValue();
  8408.         }
  8409.         else {
  8410.             return CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_DEFAULT;
  8411.         }
  8412.     }

  8413.     public boolean isEnabledCorrelazioneApplicativaPortaApplicativa(PortaApplicativa paAssociata) {
  8414.         boolean isCorrelazioneApplicativaAbilitataReq = false;
  8415.         if (paAssociata.getCorrelazioneApplicativa() != null)
  8416.             isCorrelazioneApplicativaAbilitataReq = paAssociata.getCorrelazioneApplicativa().sizeElementoList() > 0;
  8417.            
  8418.         boolean isCorrelazioneApplicativaAbilitataRes = false;
  8419.         if (paAssociata.getCorrelazioneApplicativaRisposta() != null)
  8420.             isCorrelazioneApplicativaAbilitataRes = paAssociata.getCorrelazioneApplicativaRisposta().sizeElementoList() > 0;
  8421.            
  8422.         return  isCorrelazioneApplicativaAbilitataReq || isCorrelazioneApplicativaAbilitataRes;
  8423.     }
  8424.    
  8425.     public String getStatoCorrelazioneApplicativaPortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8426.        
  8427.         if(paAssociata==null) {
  8428.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8429.         }
  8430.        
  8431.         boolean isCorrelazioneApplicativaAbilitataReq = false;
  8432.         if (paAssociata.getCorrelazioneApplicativa() != null)
  8433.             isCorrelazioneApplicativaAbilitataReq = paAssociata.getCorrelazioneApplicativa().sizeElementoList() > 0;
  8434.            
  8435.         boolean isCorrelazioneApplicativaAbilitataRes = false;
  8436.             if (paAssociata.getCorrelazioneApplicativaRisposta() != null)
  8437.                 isCorrelazioneApplicativaAbilitataRes = paAssociata.getCorrelazioneApplicativaRisposta().sizeElementoList() > 0;
  8438.                
  8439.         if(isCorrelazioneApplicativaAbilitataReq && isCorrelazioneApplicativaAbilitataRes)
  8440.             return PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CORRELAZIONE_APPLICATIVA_ABILITATA;
  8441.        
  8442.         if(isCorrelazioneApplicativaAbilitataReq)
  8443.             return CostantiControlStation.VALUE_PARAMETRO_DUMP_SEZIONE_RICHIESTA;
  8444.        
  8445.         if(isCorrelazioneApplicativaAbilitataRes)
  8446.             return CostantiControlStation.VALUE_PARAMETRO_DUMP_SEZIONE_RISPOSTA;
  8447.            
  8448.         return PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CORRELAZIONE_APPLICATIVA_DISABILITATA;
  8449.     }


  8450.     public String getStatoMTOMPortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8451.        
  8452.         if(paAssociata==null) {
  8453.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8454.         }
  8455.        
  8456.         String statoMTOM = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MTOM_DISABILITATO;
  8457.         boolean isMTOMAbilitatoReq = false;
  8458.         boolean isMTOMAbilitatoRes= false;
  8459.         if(paAssociata.getMtomProcessor()!= null){
  8460.             if(paAssociata.getMtomProcessor().getRequestFlow() != null){
  8461.                 if(paAssociata.getMtomProcessor().getRequestFlow().getMode() != null){
  8462.                     MTOMProcessorType mode = paAssociata.getMtomProcessor().getRequestFlow().getMode();
  8463.                     if(!mode.equals(MTOMProcessorType.DISABLE))
  8464.                         isMTOMAbilitatoReq = true;
  8465.                 }
  8466.             }

  8467.             if(paAssociata.getMtomProcessor().getResponseFlow() != null){
  8468.                 if(paAssociata.getMtomProcessor().getResponseFlow().getMode() != null){
  8469.                     MTOMProcessorType mode = paAssociata.getMtomProcessor().getResponseFlow().getMode();
  8470.                     if(!mode.equals(MTOMProcessorType.DISABLE))
  8471.                         isMTOMAbilitatoRes = true;
  8472.                 }
  8473.             }
  8474.         }

  8475.         if(isMTOMAbilitatoReq || isMTOMAbilitatoRes)
  8476.             statoMTOM = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MTOM_ABILITATO;
  8477.         else
  8478.             statoMTOM = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MTOM_DISABILITATO;
  8479.         return statoMTOM;
  8480.     }

  8481.     public MTOMProcessorType getProcessorTypeRequestMTOMPortaApplicativa(PortaApplicativa paAssociata) {
  8482.         if(paAssociata.getMtomProcessor()!= null){
  8483.             if(paAssociata.getMtomProcessor().getRequestFlow() != null){
  8484.                 if(paAssociata.getMtomProcessor().getRequestFlow().getMode() != null){
  8485.                     MTOMProcessorType mode = paAssociata.getMtomProcessor().getRequestFlow().getMode();
  8486.                     return mode;
  8487.                 }
  8488.             }
  8489.         }
  8490.         return null;
  8491.     }
  8492.    
  8493.     public MTOMProcessorType getProcessorTypeResponseMTOMPortaApplicativa(PortaApplicativa paAssociata) {
  8494.         if(paAssociata.getMtomProcessor()!= null){
  8495.             if(paAssociata.getMtomProcessor().getResponseFlow() != null){
  8496.                 if(paAssociata.getMtomProcessor().getResponseFlow().getMode() != null){
  8497.                     MTOMProcessorType mode = paAssociata.getMtomProcessor().getResponseFlow().getMode();
  8498.                     return mode;
  8499.                 }
  8500.             }
  8501.         }
  8502.         return null;
  8503.     }

  8504.     public String getStatoValidazionePortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8505.        
  8506.         if(paAssociata==null) {
  8507.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8508.         }
  8509.        
  8510.         String statoValidazione = null;
  8511.        
  8512.         ValidazioneContenutiApplicativi vx = paAssociata.getValidazioneContenutiApplicativi();
  8513.         if (vx == null) {
  8514.             statoValidazione = PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_DISABILITATO;
  8515.         } else {
  8516.             if(vx.getStato()!=null)
  8517.                 statoValidazione = vx.getStato().toString();
  8518.             if ((statoValidazione == null) || "".equals(statoValidazione)) {
  8519.                 statoValidazione = PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_DISABILITATO;
  8520.             }
  8521.         }
  8522.         return statoValidazione;
  8523.     }

  8524.     public String getTipoValidazionePortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8525.        
  8526.         if(paAssociata==null) {
  8527.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8528.         }
  8529.        
  8530.         String tipoValidazione = null;
  8531.        
  8532.         ValidazioneContenutiApplicativi vx = paAssociata.getValidazioneContenutiApplicativi();
  8533.         if (vx != null) {
  8534.             if(vx.getTipo()!=null) {
  8535.                 tipoValidazione = vx.getTipo().getValue();
  8536.             }
  8537.         }
  8538.         return tipoValidazione;
  8539.     }

  8540.     public String getStatoResponseCachingPortaApplicativa(PortaApplicativa paAssociata, boolean usePrefixDefault) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  8541.        
  8542.         if(paAssociata==null) {
  8543.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8544.         }
  8545.        
  8546.         String stato = null;
  8547.         ResponseCachingConfigurazione rc = paAssociata.getResponseCaching();
  8548.         if (rc == null) {
  8549.             stato = this.getResponseCachingLabelDefault(usePrefixDefault);
  8550.         } else {
  8551.             if(rc.getStato()!=null) {
  8552.                 stato = rc.getStato().getValue();
  8553.             }
  8554.             else {
  8555.                 stato = PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_DISABILITATO;
  8556.             }
  8557.         }
  8558.         return stato;
  8559.     }
  8560.    
  8561.     public String getStatoGestioneCorsPortaApplicativa(PortaApplicativa paAssociata, boolean usePrefixDefault) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  8562.        
  8563.         if(paAssociata==null) {
  8564.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8565.         }
  8566.        
  8567.         String stato = null;
  8568.         CorsConfigurazione cc = paAssociata.getGestioneCors();
  8569.         if (cc == null) {
  8570.             stato = this.getGestioneCorsLabelDefault(usePrefixDefault);
  8571.         } else {
  8572.             if(cc.getStato()==null || StatoFunzionalita.DISABILITATO.equals(cc.getStato())) {
  8573.                 stato = StatoFunzionalita.DISABILITATO.getValue();
  8574.             }
  8575.             else {
  8576.                 stato = getLabelTipoGestioneCors(cc.getTipo());
  8577.             }
  8578.         }
  8579.         return stato;
  8580.     }
  8581.    
  8582.     public String getStatoOpzioniAvanzatePortaDelegataDefault(PortaDelegata pdAssociata) throws DriverControlStationException {
  8583.        
  8584.         if(pdAssociata==null) {
  8585.             throw new DriverControlStationException("Param pdAssociata is null");
  8586.         }
  8587.        
  8588.         return _getStatoOpzioniAvanzatePortaApplicativaDefault(pdAssociata.getOptions());
  8589.     }
  8590.     public String getStatoOpzioniAvanzatePortaApplicativaDefault(PortaApplicativa paAssociata) throws DriverControlStationException {
  8591.        
  8592.         if(paAssociata==null) {
  8593.             throw new DriverControlStationException("Param paAssociata is null");
  8594.         }
  8595.        
  8596.         return _getStatoOpzioniAvanzatePortaApplicativaDefault(paAssociata.getOptions());
  8597.     }
  8598.     private String _getStatoOpzioniAvanzatePortaApplicativaDefault(String options) throws DriverControlStationException {
  8599.         String stato = null;
  8600.        
  8601.         Map<String, List<String>> props = null;
  8602.         try {
  8603.             props = PropertiesSerializator.convertoFromDBColumnValue(options);
  8604.         }catch(Exception e) {
  8605.             throw new DriverControlStationException(e.getMessage(),e);
  8606.         }
  8607.         if(props==null || props.size()<=0) {
  8608.             stato = StatoFunzionalita.DISABILITATO.getValue();
  8609.         }
  8610.         else {
  8611.             stato = StatoFunzionalita.ABILITATO.getValue();
  8612.         }
  8613.        
  8614.         return stato;
  8615.     }
  8616.    
  8617.     public String getStatoControlloAccessiPortaApplicativa(String protocollo, PortaApplicativa paAssociata) throws DriverControlStationException, DriverControlStationNotFound {
  8618.         return this._getStatoControlloAccessiPortaApplicativa(protocollo, paAssociata, null);
  8619.     }
  8620.     public void setStatoControlloAccessiPortaApplicativa(String protocollo, PortaApplicativa paAssociata, DataElement de) throws DriverControlStationException, DriverControlStationNotFound {
  8621.         this._getStatoControlloAccessiPortaApplicativa(protocollo, paAssociata, de);
  8622.     }
  8623.     private String _getStatoControlloAccessiPortaApplicativa(String protocollo, PortaApplicativa paAssociata, DataElement de) throws DriverControlStationException, DriverControlStationNotFound {
  8624.        
  8625.         if(paAssociata==null) {
  8626.             throw new DriverControlStationException("Param paAssociata is null");
  8627.         }
  8628.        
  8629.         String gestioneToken = null;
  8630.         String gestioneTokenPolicy = null;
  8631.         String gestioneTokenOpzionale = "";
  8632.         GestioneToken gestioneTokenConfig = null;
  8633.         AutorizzazioneScope autorizzazioneScope = null;
  8634.         PortaDelegataAutorizzazioneToken autorizzazioneTokenPortaDelegata = null;
  8635.         PortaApplicativaAutorizzazioneToken autorizzazioneTokenPortaApplicativa = null;
  8636.         if(paAssociata.getGestioneToken()!=null && paAssociata.getGestioneToken().getPolicy()!=null &&
  8637.                 !"".equals(paAssociata.getGestioneToken().getPolicy()) &&
  8638.                 !"-".equals(paAssociata.getGestioneToken().getPolicy())) {
  8639.             gestioneToken = StatoFunzionalita.ABILITATO.getValue();
  8640.             gestioneTokenPolicy = paAssociata.getGestioneToken().getPolicy();
  8641.            
  8642.             if(paAssociata.getGestioneToken()!=null && paAssociata.getGestioneToken().getTokenOpzionale()!=null){
  8643.                 if (paAssociata.getGestioneToken().getTokenOpzionale().equals(StatoFunzionalita.ABILITATO)) {
  8644.                     gestioneTokenOpzionale = Costanti.CHECK_BOX_ENABLED;
  8645.                 }
  8646.             }
  8647.            
  8648.             gestioneTokenConfig = paAssociata.getGestioneToken();
  8649.             autorizzazioneScope = paAssociata.getScope();
  8650.             autorizzazioneTokenPortaApplicativa = paAssociata.getAutorizzazioneToken();
  8651.         }
  8652.        
  8653.         boolean modipa = this.isProfiloModIPA(protocollo);
  8654.         if(modipa && autorizzazioneTokenPortaApplicativa==null) {
  8655.             autorizzazioneTokenPortaApplicativa = paAssociata.getAutorizzazioneToken();
  8656.         }

  8657.         String autenticazione = paAssociata.getAutenticazione();
  8658.         String autenticazioneCustom = null;
  8659.         if (autenticazione != null && !TipoAutenticazione.getValues().contains(autenticazione)) {
  8660.             autenticazioneCustom = autenticazione;
  8661.             autenticazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM;
  8662.                    
  8663.             Plugin plugin = null;
  8664.             try {
  8665.                 plugin = this.confCore.getPlugin(TipoPlugin.AUTENTICAZIONE,autenticazioneCustom, false);
  8666.             }catch(Throwable e) {
  8667.                 // ignore
  8668.             }
  8669.            
  8670.             if(plugin!=null && plugin.getLabel()!=null) {
  8671.                 autenticazioneCustom = plugin.getLabel();
  8672.             }
  8673.         }
  8674.         String autenticazioneOpzionale = "";
  8675.         if(paAssociata.getAutenticazioneOpzionale()!=null){
  8676.             if (paAssociata.getAutenticazioneOpzionale().equals(StatoFunzionalita.ABILITATO)) {
  8677.                 autenticazioneOpzionale = Costanti.CHECK_BOX_ENABLED;
  8678.             }
  8679.         }
  8680.        
  8681.         String autorizzazione= null, autorizzazioneCustom = null;
  8682.         int sizeApplicativi = 0;
  8683.         int sizeSoggetti = 0;
  8684.         int sizeRuoli = 0;
  8685.         if (paAssociata.getAutorizzazione() != null &&
  8686.                 !TipoAutorizzazione.getAllValues().contains(paAssociata.getAutorizzazione())) {
  8687.             autorizzazioneCustom = paAssociata.getAutorizzazione();
  8688.             autorizzazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM;
  8689.            
  8690.             Plugin plugin = null;
  8691.             try {
  8692.                 plugin = this.confCore.getPlugin(TipoPlugin.AUTORIZZAZIONE,autorizzazioneCustom, false);
  8693.             }catch(Throwable e) {
  8694.                 // ignore
  8695.             }
  8696.            
  8697.             if(plugin!=null && plugin.getLabel()!=null) {
  8698.                 autorizzazioneCustom = plugin.getLabel();
  8699.             }
  8700.         }
  8701.         else{
  8702.             if(de!=null) {
  8703.                 autorizzazione = paAssociata.getAutorizzazione();
  8704.             }
  8705.             else {
  8706.                 autorizzazione = AutorizzazioneUtilities.convertToStato(paAssociata.getAutorizzazione());
  8707.             }
  8708.             autorizzazione = paAssociata.getAutorizzazione();
  8709.         }
  8710.         if(paAssociata.getServiziApplicativiAutorizzati()!=null) {
  8711.             sizeApplicativi = paAssociata.getServiziApplicativiAutorizzati().sizeServizioApplicativoList();
  8712.         }
  8713.         if(paAssociata.getSoggetti()!=null) {
  8714.             sizeSoggetti = paAssociata.getSoggetti().sizeSoggettoList();
  8715.         }
  8716.         if(paAssociata.getRuoli()!=null) {
  8717.             sizeRuoli = paAssociata.getRuoli().sizeRuoloList();
  8718.         }
  8719.        
  8720.         String autorizzazioneContenuti = paAssociata.getAutorizzazioneContenuto();
  8721.         if(StringUtils.isNotEmpty(autorizzazioneContenuti) && !CostantiAutorizzazione.AUTORIZZAZIONE_CONTENUTO_BUILT_IN.equals(autorizzazioneContenuti)) {
  8722.             Plugin plugin = null;
  8723.             try {
  8724.                 plugin = this.confCore.getPlugin(TipoPlugin.AUTORIZZAZIONE_CONTENUTI,autorizzazioneContenuti, false);
  8725.             }catch(Throwable e) {
  8726.                 // ignore
  8727.             }
  8728.            
  8729.             if(plugin!=null && plugin.getLabel()!=null) {
  8730.                 autorizzazioneContenuti = plugin.getLabel();
  8731.             }
  8732.         }
  8733.        
  8734.         List<AttributeAuthority> aa = paAssociata.getAttributeAuthorityList();
  8735.         List<String> attributeAuthority = new ArrayList<>();
  8736.         if(aa!=null && !aa.isEmpty()) {
  8737.             for (AttributeAuthority a : aa) {
  8738.                 attributeAuthority.add(a.getNome());
  8739.             }
  8740.         }
  8741.        
  8742.         if(de!=null) {
  8743.             this.setStatoControlloAccessi(de, false,
  8744.                     gestioneToken, gestioneTokenOpzionale, gestioneTokenPolicy, gestioneTokenConfig,
  8745.                     autenticazione,  autenticazioneOpzionale, autenticazioneCustom,
  8746.                     autorizzazione, autorizzazioneCustom, sizeApplicativi, sizeSoggetti, sizeRuoli,
  8747.                     autorizzazioneTokenPortaDelegata, autorizzazioneTokenPortaApplicativa, autorizzazioneScope,
  8748.                     autorizzazioneContenuti,
  8749.                     protocollo,
  8750.                     attributeAuthority);
  8751.             return  null;
  8752.         }
  8753.         else {
  8754.             return this.getLabelStatoControlloAccessi(
  8755.                 false,
  8756.                 gestioneToken, gestioneTokenOpzionale, gestioneTokenPolicy, gestioneTokenConfig,
  8757.                 autenticazione,  autenticazioneOpzionale, autenticazioneCustom,
  8758.                 autorizzazione, autorizzazioneCustom, sizeApplicativi, sizeSoggetti, sizeRuoli,
  8759.                 autorizzazioneTokenPortaDelegata, autorizzazioneTokenPortaApplicativa, autorizzazioneScope,
  8760.                 autorizzazioneContenuti,
  8761.                 attributeAuthority);
  8762.         }
  8763.     }
  8764.    
  8765.     public String getStatoGestioneTokenPortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8766.        
  8767.         if(paAssociata==null) {
  8768.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8769.         }
  8770.        
  8771.         String gestioneToken = null;
  8772.         if(paAssociata.getGestioneToken()!=null && paAssociata.getGestioneToken().getPolicy()!=null &&
  8773.                 !"".equals(paAssociata.getGestioneToken().getPolicy()) &&
  8774.                 !"-".equals(paAssociata.getGestioneToken().getPolicy())) {
  8775.             gestioneToken = StatoFunzionalita.ABILITATO.getValue();
  8776.         }
  8777.        
  8778.         return this.getLabelStatoGestioneToken(gestioneToken);
  8779.     }
  8780.    
  8781.     public String getStatoAutenticazionePortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8782.        
  8783.         if(paAssociata==null) {
  8784.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8785.         }
  8786.        
  8787.         String autenticazione = paAssociata.getAutenticazione();
  8788.         String autenticazioneCustom = null;
  8789.         if (autenticazione != null && !TipoAutenticazione.getValues().contains(autenticazione)) {
  8790.             autenticazioneCustom = autenticazione;
  8791.             autenticazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM;
  8792.         }
  8793.         String autenticazioneOpzionale = "";
  8794.         if(paAssociata.getAutenticazioneOpzionale()!=null){
  8795.             if (paAssociata.getAutenticazioneOpzionale().equals(StatoFunzionalita.ABILITATO)) {
  8796.                 autenticazioneOpzionale = Costanti.CHECK_BOX_ENABLED;
  8797.             }
  8798.         }

  8799.         return this.getLabelStatoAutenticazione(autenticazione, autenticazioneOpzionale, autenticazioneCustom);
  8800.     }
  8801.    
  8802.     public String getStatoAutorizzazionePortaApplicativa(PortaApplicativa paAssociata) throws DriverConfigurazioneException {
  8803.        
  8804.         if(paAssociata==null) {
  8805.             throw new DriverConfigurazioneException("Param paAssociata is null");
  8806.         }
  8807.        
  8808.         String autorizzazioneContenuti = paAssociata.getAutorizzazioneContenuto();
  8809.        
  8810.         String autorizzazione= null, autorizzazioneCustom = null;
  8811.         if (paAssociata.getAutorizzazione() != null &&
  8812.                 !TipoAutorizzazione.getAllValues().contains(paAssociata.getAutorizzazione())) {
  8813.             autorizzazioneCustom = paAssociata.getAutorizzazione();
  8814.             autorizzazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM;
  8815.         }
  8816.         else{
  8817.             autorizzazione = AutorizzazioneUtilities.convertToStato(paAssociata.getAutorizzazione());
  8818.         }
  8819.        
  8820.         return this.getLabelStatoAutorizzazione(autorizzazione, autorizzazioneContenuti, autorizzazioneCustom);
  8821.     }
  8822.    
  8823.    
  8824.    
  8825.     // Stato Porta Delegata
  8826.    
  8827.     public String getStatoDumpPortaDelegata(PortaDelegata pdAssociata, boolean usePrefixDefault)
  8828.             throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  8829.        
  8830.         if(pdAssociata==null) {
  8831.             throw new DriverConfigurazioneException("Param pdAssociata is null");
  8832.         }
  8833.        
  8834.         DumpConfigurazione dumpConfigurazione = pdAssociata.getDump();
  8835.         String statoDump = dumpConfigurazione == null ? this.getDumpLabelDefault(usePrefixDefault, false) :
  8836.             (this.isDumpConfigurazioneAbilitato(dumpConfigurazione) ? CostantiControlStation.DEFAULT_VALUE_ABILITATO : CostantiControlStation.DEFAULT_VALUE_DISABILITATO);
  8837.         return statoDump;
  8838.     }


  8839.     public String getStatoTracciamentoPortaDelegata(PortaDelegata pdAssociata) throws DriverConfigurazioneException {
  8840.        
  8841.         if(pdAssociata==null) {
  8842.             throw new DriverConfigurazioneException("Param pdAssociata is null");
  8843.         }
  8844.        
  8845.         String statoTracciamento = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_DISABILITATA;
  8846.         boolean tracciamento = false;
  8847.         boolean isCorrelazioneApplicativaAbilitataReq = false;
  8848.         boolean isCorrelazioneApplicativaAbilitataRes = false;
  8849.        
  8850.         if (pdAssociata.getCorrelazioneApplicativa() != null)
  8851.             isCorrelazioneApplicativaAbilitataReq = pdAssociata.getCorrelazioneApplicativa().sizeElementoList() > 0;

  8852.         if (pdAssociata.getCorrelazioneApplicativaRisposta() != null)
  8853.             isCorrelazioneApplicativaAbilitataRes = pdAssociata.getCorrelazioneApplicativaRisposta().sizeElementoList() > 0;
  8854.        
  8855.         if(pdAssociata.getTracciamento()!=null &&
  8856.                 (
  8857.                     (
  8858.                             pdAssociata.getTracciamento().getEsiti()!=null
  8859.                             &&
  8860.                             !(EsitiConfigUtils.TUTTI_ESITI_DISABILITATI+"").equals(pdAssociata.getTracciamento().getEsiti())
  8861.                     )
  8862.                     ||
  8863.                     pdAssociata.getTracciamento().getSeverita()!=null)
  8864.                 ) {
  8865.             tracciamento = true;
  8866.         }
  8867.        
  8868.         if(tracciamento || isCorrelazioneApplicativaAbilitataReq || isCorrelazioneApplicativaAbilitataRes)
  8869.             statoTracciamento = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_ABILITATA;
  8870.         else
  8871.             statoTracciamento = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_DISABILITATA;
  8872.         return statoTracciamento;
  8873.     }


  8874.     public String getStatoMTOMPortaDelegata(PortaDelegata pdAssociata) throws DriverConfigurazioneException {
  8875.        
  8876.         if(pdAssociata==null) {
  8877.             throw new DriverConfigurazioneException("Param pdAssociata is null");
  8878.         }
  8879.        
  8880.         String statoMTOM = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_DISABILITATO;
  8881.        
  8882.         boolean isMTOMAbilitatoReq = false;
  8883.         boolean isMTOMAbilitatoRes= false;
  8884.         if(pdAssociata.getMtomProcessor()!= null){
  8885.             if(pdAssociata.getMtomProcessor().getRequestFlow() != null){
  8886.                 if(pdAssociata.getMtomProcessor().getRequestFlow().getMode() != null){
  8887.                     MTOMProcessorType mode = pdAssociata.getMtomProcessor().getRequestFlow().getMode();
  8888.                     if(!mode.equals(MTOMProcessorType.DISABLE))
  8889.                         isMTOMAbilitatoReq = true;
  8890.                 }
  8891.             }

  8892.             if(pdAssociata.getMtomProcessor().getResponseFlow() != null){
  8893.                 if(pdAssociata.getMtomProcessor().getResponseFlow().getMode() != null){
  8894.                     MTOMProcessorType mode = pdAssociata.getMtomProcessor().getResponseFlow().getMode();
  8895.                     if(!mode.equals(MTOMProcessorType.DISABLE))
  8896.                         isMTOMAbilitatoRes = true;
  8897.                 }
  8898.             }
  8899.         }

  8900.         if(isMTOMAbilitatoReq || isMTOMAbilitatoRes)
  8901.             statoMTOM = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_ABILITATO;
  8902.         else
  8903.             statoMTOM = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_DISABILITATO;
  8904.         return statoMTOM;
  8905.     }


  8906.     public String getStatoMessageSecurityPortaDelegata(PortaDelegata pdAssociata) throws DriverConfigurazioneException {
  8907.        
  8908.         if(pdAssociata==null) {
  8909.             throw new DriverConfigurazioneException("Param pdAssociata is null");
  8910.         }
  8911.        
  8912.         String statoMessageSecurity = pdAssociata.getStatoMessageSecurity();
  8913.         return statoMessageSecurity;
  8914.     }


  8915.     public String getStatoValidazionePortaDelegata(PortaDelegata pdAssociata) throws DriverConfigurazioneException {
  8916.        
  8917.         if(pdAssociata==null) {
  8918.             throw new DriverConfigurazioneException("Param pdAssociata is null");
  8919.         }
  8920.        
  8921.         String statoValidazione = null;
  8922.         ValidazioneContenutiApplicativi vx = pdAssociata.getValidazioneContenutiApplicativi();
  8923.         if (vx == null) {
  8924.             statoValidazione = PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_DISABILITATO;
  8925.         } else {
  8926.             if(vx.getStato()!=null)
  8927.                 statoValidazione = vx.getStato().toString();
  8928.             if ((statoValidazione == null) || "".equals(statoValidazione)) {
  8929.                 statoValidazione = PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_DISABILITATO;
  8930.             }
  8931.         }
  8932.         return statoValidazione;
  8933.     }

  8934.     public String getStatoResponseCachingPortaDelegata(PortaDelegata pdAssociata, boolean usePrefixDefault) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  8935.        
  8936.         if(pdAssociata==null) {
  8937.             throw new DriverConfigurazioneException("Param pdAssociata is null");
  8938.         }
  8939.        
  8940.         String stato = null;
  8941.         ResponseCachingConfigurazione rc = pdAssociata.getResponseCaching();
  8942.         if (rc == null) {
  8943.             stato = this.getResponseCachingLabelDefault(usePrefixDefault);
  8944.         } else {
  8945.             if(rc.getStato()!=null) {
  8946.                 stato = rc.getStato().getValue();
  8947.             }
  8948.             else {
  8949.                 stato = PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_DISABILITATO;
  8950.             }
  8951.         }
  8952.         return stato;
  8953.     }
  8954.    
  8955.     public String getStatoGestioneCorsPortaDelegata(PortaDelegata pdAssociata, boolean usePrefixDefault) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  8956.        
  8957.         if(pdAssociata==null) {
  8958.             throw new DriverConfigurazioneException("Param pdAssociata is null");
  8959.         }
  8960.        
  8961.         String stato = null;
  8962.         CorsConfigurazione cc = pdAssociata.getGestioneCors();
  8963.         if (cc == null) {
  8964.             stato = this.getGestioneCorsLabelDefault(usePrefixDefault);
  8965.         } else {
  8966.             if(cc.getStato()==null || StatoFunzionalita.DISABILITATO.equals(cc.getStato())) {
  8967.                 stato = StatoFunzionalita.DISABILITATO.getValue();
  8968.             }
  8969.             else {
  8970.                 stato = getLabelTipoGestioneCors(cc.getTipo());
  8971.             }
  8972.         }
  8973.         return stato;
  8974.     }

  8975.     public String getStatoControlloAccessiPortaDelegata(String protocollo, PortaDelegata pdAssociata) throws DriverControlStationException, DriverControlStationNotFound {
  8976.         return this._getStatoControlloAccessiPortaDelegata(protocollo, pdAssociata, null);
  8977.     }
  8978.     public void setStatoControlloAccessiPortaDelegata(String protocollo, PortaDelegata pdAssociata, DataElement de) throws DriverControlStationException, DriverControlStationNotFound {
  8979.         this._getStatoControlloAccessiPortaDelegata(protocollo, pdAssociata, de);
  8980.     }
  8981.     private String _getStatoControlloAccessiPortaDelegata(String protocollo, PortaDelegata pdAssociata, DataElement de) throws DriverControlStationException, DriverControlStationNotFound {
  8982.        
  8983.         if(pdAssociata==null) {
  8984.             throw new DriverControlStationException("Param pdAssociata is null");
  8985.         }
  8986.        
  8987.         String gestioneToken = null;
  8988.         String gestioneTokenPolicy = null;
  8989.         String gestioneTokenOpzionale = "";
  8990.         GestioneToken gestioneTokenConfig = null;
  8991.         AutorizzazioneScope autorizzazioneScope = null;
  8992.         PortaDelegataAutorizzazioneToken autorizzazioneTokenPortaDelegata = null;
  8993.         PortaApplicativaAutorizzazioneToken autorizzazioneTokenPortaApplicativa = null;
  8994.         if(pdAssociata.getGestioneToken()!=null && pdAssociata.getGestioneToken().getPolicy()!=null &&
  8995.                 !"".equals(pdAssociata.getGestioneToken().getPolicy()) &&
  8996.                 !"-".equals(pdAssociata.getGestioneToken().getPolicy())) {
  8997.             gestioneToken = StatoFunzionalita.ABILITATO.getValue();
  8998.             gestioneTokenPolicy = pdAssociata.getGestioneToken().getPolicy();
  8999.            
  9000.             if(pdAssociata.getGestioneToken()!=null && pdAssociata.getGestioneToken().getTokenOpzionale()!=null){
  9001.                 if (pdAssociata.getGestioneToken().getTokenOpzionale().equals(StatoFunzionalita.ABILITATO)) {
  9002.                     gestioneTokenOpzionale = Costanti.CHECK_BOX_ENABLED;
  9003.                 }
  9004.             }
  9005.            
  9006.             gestioneTokenConfig = pdAssociata.getGestioneToken();
  9007.             autorizzazioneScope = pdAssociata.getScope();
  9008.             autorizzazioneTokenPortaDelegata = pdAssociata.getAutorizzazioneToken();
  9009.         }
  9010.        
  9011.         String autenticazione = pdAssociata.getAutenticazione();
  9012.         String autenticazioneCustom = null;
  9013.         if (autenticazione != null && !TipoAutenticazione.getValues().contains(autenticazione)) {
  9014.             autenticazioneCustom = autenticazione;
  9015.             autenticazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM;
  9016.            
  9017.             Plugin plugin = null;
  9018.             try {
  9019.                 plugin = this.confCore.getPlugin(TipoPlugin.AUTENTICAZIONE,autenticazioneCustom, false);
  9020.             }catch(Throwable e) {
  9021.                 // ignore
  9022.             }
  9023.            
  9024.             if(plugin!=null && plugin.getLabel()!=null) {
  9025.                 autenticazioneCustom = plugin.getLabel();
  9026.             }
  9027.         }
  9028.         String autenticazioneOpzionale = "";
  9029.         if(pdAssociata.getAutenticazioneOpzionale()!=null){
  9030.             if (pdAssociata.getAutenticazioneOpzionale().equals(StatoFunzionalita.ABILITATO)) {
  9031.                 autenticazioneOpzionale = Costanti.CHECK_BOX_ENABLED;
  9032.             }
  9033.         }
  9034.        
  9035.         String autorizzazione= null, autorizzazioneCustom = null;
  9036.         int sizeApplicativi = 0;
  9037.         int sizeSoggetti = 0;
  9038.         int sizeRuoli = 0;
  9039.         if (pdAssociata.getAutorizzazione() != null &&
  9040.                 !TipoAutorizzazione.getAllValues().contains(pdAssociata.getAutorizzazione())) {
  9041.             autorizzazioneCustom = pdAssociata.getAutorizzazione();
  9042.             autorizzazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM;
  9043.            
  9044.             Plugin plugin = null;
  9045.             try {
  9046.                 plugin = this.confCore.getPlugin(TipoPlugin.AUTORIZZAZIONE,autorizzazioneCustom, false);
  9047.             }catch(Throwable e) {
  9048.                 // ignore
  9049.             }
  9050.            
  9051.             if(plugin!=null && plugin.getLabel()!=null) {
  9052.                 autorizzazioneCustom = plugin.getLabel();
  9053.             }
  9054.         }
  9055.         else{
  9056.             if(de!=null) {
  9057.                 autorizzazione = pdAssociata.getAutorizzazione();
  9058.             }
  9059.             else {
  9060.                 autorizzazione = AutorizzazioneUtilities.convertToStato(pdAssociata.getAutorizzazione());
  9061.             }
  9062.         }
  9063.         sizeApplicativi = pdAssociata.sizeServizioApplicativoList();
  9064.         if(pdAssociata.getRuoli()!=null) {
  9065.             sizeRuoli = pdAssociata.getRuoli().sizeRuoloList();
  9066.         }
  9067.        
  9068.         String autorizzazioneContenuti = pdAssociata.getAutorizzazioneContenuto();
  9069.         if(StringUtils.isNotEmpty(autorizzazioneContenuti) && !CostantiAutorizzazione.AUTORIZZAZIONE_CONTENUTO_BUILT_IN.equals(autorizzazioneContenuti)) {
  9070.             Plugin plugin = null;
  9071.             try {
  9072.                 plugin = this.confCore.getPlugin(TipoPlugin.AUTORIZZAZIONE_CONTENUTI,autorizzazioneContenuti, false);
  9073.             }catch(Throwable e) {
  9074.                 // ignore
  9075.             }
  9076.            
  9077.             if(plugin!=null && plugin.getLabel()!=null) {
  9078.                 autorizzazioneContenuti = plugin.getLabel();
  9079.             }
  9080.         }
  9081.        
  9082.         List<AttributeAuthority> aa = pdAssociata.getAttributeAuthorityList();
  9083.         List<String> attributeAuthority = new ArrayList<>();
  9084.         if(aa!=null && !aa.isEmpty()) {
  9085.             for (AttributeAuthority a : aa) {
  9086.                 attributeAuthority.add(a.getNome());
  9087.             }
  9088.         }
  9089.        
  9090.         if(de!=null) {
  9091.             this.setStatoControlloAccessi(de, true,
  9092.                     gestioneToken, gestioneTokenOpzionale, gestioneTokenPolicy, gestioneTokenConfig,
  9093.                     autenticazione,  autenticazioneOpzionale, autenticazioneCustom,
  9094.                     autorizzazione, autorizzazioneCustom, sizeApplicativi, sizeSoggetti, sizeRuoli,
  9095.                     autorizzazioneTokenPortaDelegata, autorizzazioneTokenPortaApplicativa, autorizzazioneScope,
  9096.                     autorizzazioneContenuti, protocollo,
  9097.                     attributeAuthority);
  9098.             return  null;
  9099.         }
  9100.         else {
  9101.             return this.getLabelStatoControlloAccessi(
  9102.                 true,
  9103.                 gestioneToken, gestioneTokenOpzionale, gestioneTokenPolicy, gestioneTokenConfig,
  9104.                 autenticazione,  autenticazioneOpzionale, autenticazioneCustom,
  9105.                 autorizzazione, autorizzazioneCustom, sizeApplicativi, sizeSoggetti, sizeRuoli,
  9106.                 autorizzazioneTokenPortaDelegata, autorizzazioneTokenPortaApplicativa, autorizzazioneScope,
  9107.                 autorizzazioneContenuti,
  9108.                 attributeAuthority);
  9109.         }
  9110.     }
  9111.    
  9112.     public String getStatoAutenticazionePortaDelegata(PortaDelegata pdAssociata) throws DriverConfigurazioneException {
  9113.        
  9114.         if(pdAssociata==null) {
  9115.             throw new DriverConfigurazioneException("Param pdAssociata is null");
  9116.         }
  9117.        
  9118.         String autenticazione = pdAssociata.getAutenticazione();
  9119.         String autenticazioneCustom = null;
  9120.         if (autenticazione != null && !TipoAutenticazione.getValues().contains(autenticazione)) {
  9121.             autenticazioneCustom = autenticazione;
  9122.             autenticazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM;
  9123.         }
  9124.         String autenticazioneOpzionale = "";
  9125.         if(pdAssociata.getAutenticazioneOpzionale()!=null){
  9126.             if (pdAssociata.getAutenticazioneOpzionale().equals(StatoFunzionalita.ABILITATO)) {
  9127.                 autenticazioneOpzionale = Costanti.CHECK_BOX_ENABLED;
  9128.             }
  9129.         }
  9130.         return this.getLabelStatoAutenticazione(autenticazione, autenticazioneOpzionale, autenticazioneCustom);
  9131.     }
  9132.    
  9133.     public String getStatoAutorizzazionePortaDelegata(PortaDelegata pdAssociata) throws DriverConfigurazioneException {
  9134.        
  9135.         if(pdAssociata==null) {
  9136.             throw new DriverConfigurazioneException("Param pdAssociata is null");
  9137.         }
  9138.        
  9139.         String autorizzazioneContenuti = pdAssociata.getAutorizzazioneContenuto();
  9140.         String autorizzazione= null, autorizzazioneCustom = null;
  9141.         if (pdAssociata.getAutorizzazione() != null &&
  9142.                 !TipoAutorizzazione.getAllValues().contains(pdAssociata.getAutorizzazione())) {
  9143.             autorizzazioneCustom = pdAssociata.getAutorizzazione();
  9144.             autorizzazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM;
  9145.         }
  9146.         else{
  9147.             autorizzazione = AutorizzazioneUtilities.convertToStato(pdAssociata.getAutorizzazione());
  9148.         }
  9149.        
  9150.         return this.getLabelStatoAutorizzazione(autorizzazione, autorizzazioneContenuti, autorizzazioneCustom);
  9151.     }
  9152.    
  9153.     public String getStatoGestioneTokenPortaDelegata(PortaDelegata pdAssociata) throws DriverConfigurazioneException {
  9154.        
  9155.         if(pdAssociata==null) {
  9156.             throw new DriverConfigurazioneException("Param pdAssociata is null");
  9157.         }
  9158.        
  9159.         String gestioneToken = null;
  9160.         if(pdAssociata.getGestioneToken()!=null && pdAssociata.getGestioneToken().getPolicy()!=null &&
  9161.                 !"".equals(pdAssociata.getGestioneToken().getPolicy()) &&
  9162.                 !"-".equals(pdAssociata.getGestioneToken().getPolicy())) {
  9163.             gestioneToken = StatoFunzionalita.ABILITATO.getValue();
  9164.         }
  9165.          
  9166.         return this.getLabelStatoGestioneToken(gestioneToken);
  9167.     }
  9168.    
  9169.    
  9170.     // Stato Generico
  9171.    
  9172.     public String getLabelStatoControlloAccessi(
  9173.             boolean portaDelegata,
  9174.             String gestioneToken, String gestioneTokenOpzionale, String gestioneTokenPolicy, GestioneToken gestioneTokenConfig,
  9175.             String autenticazione, String autenticazioneOpzionale, String autenticazioneCustom,
  9176.             String autorizzazione, String autorizzazioneCustom, int sizeApplicativi, int sizeSoggetti, int sizeRuoli,
  9177.             PortaDelegataAutorizzazioneToken autorizzazioneTokenPortaDelegata, PortaApplicativaAutorizzazioneToken autorizzazioneTokenPortaApplicativa, AutorizzazioneScope autorizzazioneScope,
  9178.             String autorizzazioneContenuti,
  9179.             List<String> attributeAuthority
  9180.             ) {
  9181.        
  9182.         if(gestioneToken!=null && StatoFunzionalita.ABILITATO.getValue().equals(gestioneToken)) {
  9183.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  9184.         }
  9185.        
  9186.         if(autenticazione != null && !TipoAutenticazione.DISABILITATO.equals(autenticazione))
  9187.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  9188.        
  9189.         if(autenticazioneOpzionale != null && ServletUtils.isCheckBoxEnabled(autenticazioneOpzionale))
  9190.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  9191.        
  9192.         if(attributeAuthority!=null && !attributeAuthority.isEmpty()) {
  9193.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  9194.         }
  9195.        
  9196.         if(!AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione))
  9197.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  9198.        
  9199.         if(StringUtils.isNotEmpty(autorizzazioneContenuti))
  9200.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  9201.        
  9202.         return CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  9203.        
  9204.     }
  9205.    
  9206.     public void setStatoControlloAccessi(DataElement de,
  9207.             boolean portaDelegata,
  9208.             String gestioneToken, String gestioneTokenOpzionale, String gestioneTokenPolicy, GestioneToken gestioneTokenConfig,
  9209.             String autenticazione, String autenticazioneOpzionale, String autenticazioneCustom,
  9210.             String autorizzazione, String autorizzazioneCustom, int sizeApplicativi, int sizeSoggetti, int sizeRuoli,
  9211.             PortaDelegataAutorizzazioneToken autorizzazioneTokenPortaDelegata, PortaApplicativaAutorizzazioneToken autorizzazioneTokenPortaApplicativa, AutorizzazioneScope autorizzazioneScope,
  9212.             String autorizzazioneContenuti,
  9213.             String protocollo,
  9214.             List<String> attributeAuthority
  9215.             ) throws DriverControlStationException, DriverControlStationNotFound {
  9216.        
  9217.         boolean modipa = this.isProfiloModIPA(protocollo);
  9218.        
  9219.         de.setType(DataElementType.MULTI_SELECT);
  9220.        
  9221.         // gestione token
  9222.         if(gestioneToken!=null && StatoFunzionalita.ABILITATO.getValue().equals(gestioneToken)) {
  9223.            
  9224.             CheckboxStatusType statusGestioneToken = null;
  9225.            
  9226.             StringBuilder bf = new StringBuilder();
  9227.             StringBuilder bfToolTip = new StringBuilder();
  9228.             bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_GESTIONE_TOKEN);
  9229.             bfToolTip.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_GESTIONE_TOKEN);
  9230.             if(ServletUtils.isCheckBoxEnabled(gestioneTokenOpzionale)) {
  9231.                 bfToolTip.append(" (").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_OPZIONALE).append(") ");
  9232.                 statusGestioneToken = CheckboxStatusType.CONFIG_WARNING;
  9233.             }
  9234.             else {
  9235.                 statusGestioneToken = CheckboxStatusType.CONFIG_ENABLE;
  9236.             }
  9237.             bfToolTip.append(": ").append(gestioneTokenPolicy);
  9238.            
  9239.             if(gestioneTokenConfig!=null && gestioneTokenConfig.getAutenticazione()!=null) {
  9240.                 StringBuilder bfTokenAuth = new StringBuilder();
  9241.                 if(StatoFunzionalita.ABILITATO.equals(gestioneTokenConfig.getAutenticazione().getIssuer())) {
  9242.                     if(bfTokenAuth.length()>0) {
  9243.                         bfTokenAuth.append(", ");
  9244.                     }
  9245.                     bfTokenAuth.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_ISSUER);
  9246.                 }
  9247.                 if(StatoFunzionalita.ABILITATO.equals(gestioneTokenConfig.getAutenticazione().getClientId())) {
  9248.                     if(bfTokenAuth.length()>0) {
  9249.                         bfTokenAuth.append(", ");
  9250.                     }
  9251.                     bfTokenAuth.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_CLIENT_ID);
  9252.                 }
  9253.                 if(StatoFunzionalita.ABILITATO.equals(gestioneTokenConfig.getAutenticazione().getSubject())) {
  9254.                     if(bfTokenAuth.length()>0) {
  9255.                         bfTokenAuth.append(", ");
  9256.                     }
  9257.                     bfTokenAuth.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_SUBJECT);
  9258.                 }
  9259.                 if(StatoFunzionalita.ABILITATO.equals(gestioneTokenConfig.getAutenticazione().getUsername())) {
  9260.                     if(bfTokenAuth.length()>0) {
  9261.                         bfTokenAuth.append(", ");
  9262.                     }
  9263.                     bfTokenAuth.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_USERNAME);
  9264.                 }
  9265.                 if(StatoFunzionalita.ABILITATO.equals(gestioneTokenConfig.getAutenticazione().getEmail())) {
  9266.                     if(bfTokenAuth.length()>0) {
  9267.                         bfTokenAuth.append(", ");
  9268.                     }
  9269.                     bfTokenAuth.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_MAIL);
  9270.                 }
  9271.                 if(bfTokenAuth.length()>0) {
  9272.                     bfToolTip.append("\n");
  9273.                 }
  9274.                 bfToolTip.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE_TOKEN_CLAIMS);
  9275.                 bfToolTip.append(": ").append(bfTokenAuth.toString());
  9276.             }
  9277.            
  9278.             de.addStatus(bfToolTip.toString(), bf.toString(), statusGestioneToken);
  9279.         }
  9280.        
  9281.         // autenticazione
  9282.         if(autenticazione != null && !TipoAutenticazione.DISABILITATO.equals(autenticazione)) {
  9283.             StringBuilder bf = new StringBuilder();
  9284.             StringBuilder bfToolTip = new StringBuilder();
  9285.             boolean opzionale = false;
  9286.             String authTrasporto = autenticazione;
  9287.             if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM.equals(autenticazione)) {
  9288.                 authTrasporto = autenticazioneCustom;
  9289.             }
  9290.             bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE);
  9291.             bfToolTip.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE);
  9292.             if(modipa && !portaDelegata) {
  9293.                 bf.append(" ").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE_CANALE);
  9294.                 bfToolTip.append(" ").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE_CANALE);
  9295.             }
  9296.             else {
  9297.                 bf.append(" ").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE_TRASPORTO);
  9298.                 bfToolTip.append(" ").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTENTICAZIONE_TRASPORTO);
  9299.             }
  9300.             if(ServletUtils.isCheckBoxEnabled(autenticazioneOpzionale)) {
  9301.                 bfToolTip.append(" (").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_OPZIONALE).append(") ");
  9302.                 opzionale = true;
  9303.             }
  9304.             bfToolTip.append(": ");
  9305.             if(TipoAutenticazione.contains(authTrasporto)) {
  9306.                 String labelAuth = TipoAutenticazione.toEnumConstant(authTrasporto).getLabel();
  9307.                 bf.append(" [ ").append(labelAuth).append(" ]");
  9308.                 bfToolTip.append(labelAuth);    
  9309.             }
  9310.             else {
  9311.                 //bf.append(" [ ").append(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM).append(" ]");
  9312.                 bf.append(" [ ").append(CostantiControlStation.DEFAULT_LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM).append(" '").append(authTrasporto).append("'").append(" ]");
  9313.                 bfToolTip.append(authTrasporto);
  9314.             }
  9315.            
  9316.             CheckboxStatusType statusAutenticazione = null;
  9317.             if(opzionale) {
  9318.                 statusAutenticazione =CheckboxStatusType.CONFIG_WARNING;
  9319.             }
  9320.             else {
  9321.                 statusAutenticazione = CheckboxStatusType.CONFIG_ENABLE;
  9322.             }
  9323.             de.addStatus(bfToolTip.toString(), bf.toString(), statusAutenticazione);
  9324.         }
  9325.        
  9326.         // attribute authority
  9327.         if(attributeAuthority!=null && !attributeAuthority.isEmpty()) {
  9328.             StringBuilder bf = new StringBuilder();
  9329.             StringBuilder bfToolTip = new StringBuilder();
  9330.             bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  9331.             bfToolTip.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  9332.             bfToolTip.append(": ").append(attributeAuthority.toString());
  9333.             de.addStatus(bfToolTip.toString(), bf.toString(), CheckboxStatusType.CONFIG_ENABLE);
  9334.         }
  9335.        
  9336.         // backward compatibility
  9337.         if(AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione) && modipa && !portaDelegata && sizeApplicativi>0) {
  9338.             // autorizzazione sicurezza messaggio
  9339.             autorizzazione = AutorizzazioneUtilities.STATO_ABILITATO;
  9340.         }
  9341.            
  9342.        
  9343.         // autorizzazione
  9344.         if(!AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione)) {
  9345.            
  9346.             StringBuilder bf = new StringBuilder();
  9347.             StringBuilder bfToolTip = new StringBuilder();
  9348.             StringBuilder bfToolTipNotValid = new StringBuilder();
  9349.             int rowsToolTip = 0;
  9350.            
  9351.             if(TipoAutorizzazione.isSignalHubPush(autorizzazione)) {
  9352.                 String tooltip = CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_SIGNAL_HUB;
  9353.                 de.addStatus(tooltip, tooltip, CheckboxStatusType.CONFIG_ENABLE);
  9354.             }
  9355.            
  9356.             Boolean validPuntuale = null;
  9357.             if(TipoAutorizzazione.isAuthenticationRequired(autorizzazione)) {
  9358.                 if(bf.length()>0) {
  9359.                     bf.append(",");
  9360.                 }
  9361.                 if(bf.length()<=0) {
  9362.                     if(modipa && !portaDelegata) {
  9363.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CANALE);
  9364.                     }
  9365.                     else {
  9366.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TRASPORTO);
  9367.                     }
  9368.                     bf.append(" [ ");
  9369.                 }
  9370.                 bf.append(" ");
  9371.                 bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_SERVIZI_APPLICATIVI_SUFFIX);
  9372.            
  9373.                 if(modipa && !portaDelegata) {
  9374.                     validPuntuale = sizeSoggetti>0;
  9375.                 }
  9376.                 else {
  9377.                     validPuntuale = sizeApplicativi>0 || sizeSoggetti>0;
  9378.                 }
  9379.                
  9380.                 if(validPuntuale) {
  9381.                     rowsToolTip++;
  9382.                     if(bfToolTip.length()>0) {
  9383.                         bfToolTip.append("\n");
  9384.                     }
  9385.                     bfToolTip.append("- ").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_SERVIZI_APPLICATIVI_SUFFIX);
  9386.                     if(!portaDelegata) {
  9387.                         bfToolTip.append(" ").append(CostantiControlStation.LABEL_SOGGETTI).append(" (").append(sizeSoggetti).append(")");
  9388.                     }
  9389.                     if(!modipa || portaDelegata) {
  9390.                         if(!portaDelegata) {
  9391.                             bfToolTip.append(",");
  9392.                         }
  9393.                         bfToolTip.append(" ").append(CostantiControlStation.LABEL_APPLICATIVI).append(" (").append(sizeApplicativi).append(")");
  9394.                     }
  9395.                 }
  9396.                 else {
  9397.                     if(bfToolTipNotValid.length()>0) {
  9398.                         bfToolTipNotValid.append("\n");
  9399.                     }
  9400.                     if(!modipa || portaDelegata) {
  9401.                         bfToolTipNotValid.append(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_STATO_CONFIGURAZIONI_CONTROLLO_ACCESSO_AUTORIZZAZIONE_TRASPORTO_NO_FRUITORI);
  9402.                     }
  9403.                     else {
  9404.                         bfToolTipNotValid.append(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_STATO_CONFIGURAZIONI_CONTROLLO_ACCESSO_AUTORIZZAZIONE_CANALE_NO_FRUITORI);
  9405.                     }
  9406.                 }
  9407.             }
  9408.            
  9409.             Boolean validRuoli = null;
  9410.             if(TipoAutorizzazione.isRolesRequired(autorizzazione)) {
  9411.                 if(bf.length()>0) {
  9412.                     bf.append(",");
  9413.                 }
  9414.                 if(bf.length()<=0) {
  9415.                     if(modipa && !portaDelegata) {
  9416.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CANALE);
  9417.                     }
  9418.                     else {
  9419.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TRASPORTO);
  9420.                     }
  9421.                     bf.append(" [ ");
  9422.                 }
  9423.                 bf.append(" ");
  9424.                 bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_SUFFIX);
  9425.                
  9426.                 validRuoli = sizeRuoli>0;
  9427.                
  9428.                 if(validRuoli) {
  9429.                     rowsToolTip++;
  9430.                     if(bfToolTip.length()>0) {
  9431.                         bfToolTip.append("\n");
  9432.                     }
  9433.                     bfToolTip.append("- ").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_SUFFIX);
  9434.                     bfToolTip.append(" (").append(sizeRuoli).append(")");
  9435.                 }
  9436.                 else {
  9437.                     if(bfToolTipNotValid.length()>0) {
  9438.                         bfToolTipNotValid.append("\n");
  9439.                     }
  9440.                     if(!modipa || portaDelegata) {
  9441.                         bfToolTipNotValid.append(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_STATO_CONFIGURAZIONI_CONTROLLO_ACCESSO_AUTORIZZAZIONE_TRASPORTO_NO_RUOLI);
  9442.                     }
  9443.                     else {
  9444.                         bfToolTipNotValid.append(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_STATO_CONFIGURAZIONI_CONTROLLO_ACCESSO_AUTORIZZAZIONE_CANALE_NO_RUOLI);
  9445.                     }
  9446.                 }
  9447.             }
  9448.            
  9449.             if(bf.length()>0) {
  9450.                
  9451.                 bf.append(" ]");
  9452.                
  9453.                 CheckboxStatusType statusAutorizzazione = null;
  9454.                 String tooltip = null;
  9455.                
  9456.                 if(bfToolTipNotValid.length()>0) {
  9457.                     statusAutorizzazione = CheckboxStatusType.CONFIG_ERROR;
  9458.                     tooltip = bfToolTipNotValid.toString();
  9459.                 }
  9460.                 else {
  9461.                     if(bfToolTip.length()>0) {
  9462.                         if(modipa && !portaDelegata) {
  9463.                             tooltip = CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CANALE;
  9464.                         }
  9465.                         else {
  9466.                             tooltip = CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TRASPORTO;
  9467.                         }
  9468.                         if(rowsToolTip>0) {
  9469.                             tooltip+="\n";
  9470.                         }
  9471.                         tooltip+=bfToolTip.toString();
  9472.                     }
  9473.                    
  9474.                     statusAutorizzazione = CheckboxStatusType.CONFIG_ENABLE;
  9475.                 }
  9476.                
  9477.                 de.addStatus(tooltip, bf.toString(), statusAutorizzazione);
  9478.             }
  9479.            
  9480.            
  9481.             bf = new StringBuilder();
  9482.             bfToolTip = new StringBuilder();
  9483.             bfToolTipNotValid = new StringBuilder();
  9484.             rowsToolTip = 0;
  9485.            
  9486.             validPuntuale = null;
  9487.             boolean richiedenteToken = false;
  9488.             if(modipa && !portaDelegata) {
  9489.                 richiedenteToken = (autorizzazioneTokenPortaApplicativa!=null && StatoFunzionalita.ABILITATO.equals(autorizzazioneTokenPortaApplicativa.getAutorizzazioneApplicativi()));
  9490.             }
  9491.             else if(gestioneToken!=null && StatoFunzionalita.ABILITATO.getValue().equals(gestioneToken)) {
  9492.                 richiedenteToken = portaDelegata ?
  9493.                         (autorizzazioneTokenPortaDelegata!=null && StatoFunzionalita.ABILITATO.equals(autorizzazioneTokenPortaDelegata.getAutorizzazioneApplicativi()))
  9494.                         :
  9495.                             (autorizzazioneTokenPortaApplicativa!=null && StatoFunzionalita.ABILITATO.equals(autorizzazioneTokenPortaApplicativa.getAutorizzazioneApplicativi()));
  9496.             }
  9497.             // backward compatibility
  9498.             if(!richiedenteToken && modipa && !portaDelegata && sizeApplicativi>0) {
  9499.                 richiedenteToken = true;
  9500.             }
  9501.             if(richiedenteToken) {
  9502.                 if(bf.length()>0) {
  9503.                     bf.append(",");
  9504.                 }
  9505.                 if(bf.length()<=0) {
  9506.                     if(modipa && !portaDelegata) {
  9507.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_MESSAGGIO);
  9508.                     }
  9509.                     else {
  9510.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TOKEN);
  9511.                     }
  9512.                     bf.append(" [ ");
  9513.                 }
  9514.                 bf.append(" ");
  9515.                 bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_SERVIZI_APPLICATIVI_SUFFIX);
  9516.            
  9517.                 if(modipa && !portaDelegata) {
  9518.                     validPuntuale = sizeApplicativi>0;
  9519.                 }
  9520.                 else {
  9521.                     if(portaDelegata) {
  9522.                         validPuntuale = autorizzazioneTokenPortaDelegata.getServiziApplicativi()!=null && autorizzazioneTokenPortaDelegata.getServiziApplicativi().sizeServizioApplicativoList()>0;
  9523.                     }
  9524.                     else {
  9525.                         validPuntuale = autorizzazioneTokenPortaApplicativa.getServiziApplicativi()!=null && autorizzazioneTokenPortaApplicativa.getServiziApplicativi().sizeServizioApplicativoList()>0;
  9526.                     }
  9527.                 }
  9528.                 if(validPuntuale) {
  9529.                     rowsToolTip++;
  9530.                     if(bfToolTip.length()>0) {
  9531.                         bfToolTip.append("\n");
  9532.                     }
  9533.                     bfToolTip.append("- ").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_SERVIZI_APPLICATIVI_SUFFIX);
  9534.                     int size = 0;
  9535.                     if(modipa && !portaDelegata) {
  9536.                         size = sizeApplicativi;
  9537.                     }
  9538.                     else {
  9539.                         if(portaDelegata) {
  9540.                             size = autorizzazioneTokenPortaDelegata.getServiziApplicativi().sizeServizioApplicativoList();
  9541.                         }
  9542.                         else {
  9543.                             size = autorizzazioneTokenPortaApplicativa.getServiziApplicativi().sizeServizioApplicativoList();
  9544.                         }
  9545.                     }
  9546.                     bfToolTip.append(" ").append(CostantiControlStation.LABEL_APPLICATIVI).append(" (").append(size).append(")");
  9547.                 }
  9548.                 else {
  9549.                     if(bfToolTipNotValid.length()>0) {
  9550.                         bfToolTipNotValid.append("\n");
  9551.                     }
  9552.                     if(!modipa || portaDelegata) {
  9553.                         bfToolTipNotValid.append(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_STATO_CONFIGURAZIONI_CONTROLLO_ACCESSO_AUTORIZZAZIONE_TOKEN_NO_FRUITORI);
  9554.                     }
  9555.                     else {
  9556.                         bfToolTipNotValid.append(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_STATO_CONFIGURAZIONI_CONTROLLO_ACCESSO_AUTORIZZAZIONE_MESSAGGIO_NO_FRUITORI);
  9557.                     }
  9558.                 }
  9559.             }
  9560.            
  9561.             validRuoli = null;
  9562.             boolean ruoliToken = false;
  9563.             if(modipa && !portaDelegata) {
  9564.                 ruoliToken = (autorizzazioneTokenPortaApplicativa!=null && StatoFunzionalita.ABILITATO.equals(autorizzazioneTokenPortaApplicativa.getAutorizzazioneRuoli()));
  9565.             }
  9566.             else if(gestioneToken!=null && StatoFunzionalita.ABILITATO.getValue().equals(gestioneToken)) {
  9567.                 ruoliToken = portaDelegata ?
  9568.                         (autorizzazioneTokenPortaDelegata!=null && StatoFunzionalita.ABILITATO.equals(autorizzazioneTokenPortaDelegata.getAutorizzazioneRuoli()))
  9569.                         :
  9570.                         (autorizzazioneTokenPortaApplicativa!=null && StatoFunzionalita.ABILITATO.equals(autorizzazioneTokenPortaApplicativa.getAutorizzazioneRuoli()));
  9571.             }
  9572.             if(ruoliToken) {
  9573.                 if(bf.length()>0) {
  9574.                     bf.append(",");
  9575.                 }
  9576.                 if(bf.length()<=0) {
  9577.                     if(modipa && !portaDelegata) {
  9578.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_MESSAGGIO);
  9579.                     }
  9580.                     else {
  9581.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TOKEN);
  9582.                     }
  9583.                     bf.append(" [ ");
  9584.                 }
  9585.                 bf.append(" ");
  9586.                 bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_SUFFIX);
  9587.                
  9588.                 if(portaDelegata) {
  9589.                     validRuoli = autorizzazioneTokenPortaDelegata.getRuoli()!=null && autorizzazioneTokenPortaDelegata.getRuoli().sizeRuoloList()>0;
  9590.                 }
  9591.                 else {
  9592.                     validRuoli = autorizzazioneTokenPortaApplicativa.getRuoli()!=null && autorizzazioneTokenPortaApplicativa.getRuoli().sizeRuoloList()>0;
  9593.                 }
  9594.                
  9595.                 if(validRuoli) {
  9596.                     rowsToolTip++;
  9597.                     if(bfToolTip.length()>0) {
  9598.                         bfToolTip.append("\n");
  9599.                     }
  9600.                     bfToolTip.append("- ").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_SUFFIX);
  9601.                     int size = 0;
  9602.                     if(portaDelegata) {
  9603.                         size = autorizzazioneTokenPortaDelegata.getRuoli().sizeRuoloList();
  9604.                     }
  9605.                     else {
  9606.                         size = autorizzazioneTokenPortaApplicativa.getRuoli().sizeRuoloList();
  9607.                     }
  9608.                     bfToolTip.append(" (").append(size).append(")");
  9609.                 }
  9610.                 else {
  9611.                     if(bfToolTipNotValid.length()>0) {
  9612.                         bfToolTipNotValid.append("\n");
  9613.                     }
  9614.                     if(!modipa || portaDelegata) {
  9615.                         bfToolTipNotValid.append(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_STATO_CONFIGURAZIONI_CONTROLLO_ACCESSO_AUTORIZZAZIONE_TOKEN_NO_RUOLI);
  9616.                     }
  9617.                     else {
  9618.                         bfToolTipNotValid.append(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_STATO_CONFIGURAZIONI_CONTROLLO_ACCESSO_AUTORIZZAZIONE_MESSAGGIO_NO_RUOLI);
  9619.                     }
  9620.                 }
  9621.             }
  9622.            
  9623.             Boolean validScopes = null;
  9624.             if(gestioneToken!=null && StatoFunzionalita.ABILITATO.getValue().equals(gestioneToken)) {
  9625.                 if(autorizzazioneScope!=null && StatoFunzionalita.ABILITATO.equals(autorizzazioneScope.getStato())) {
  9626.                     if(bf.length()>0) {
  9627.                         bf.append(",");
  9628.                     }
  9629.                     if(bf.length()<=0) {
  9630.                         if(modipa && !portaDelegata) {
  9631.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_MESSAGGIO);
  9632.                         }
  9633.                         else {
  9634.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TOKEN);
  9635.                         }
  9636.                         bf.append(" [ ");
  9637.                     }
  9638.                     bf.append(" ");
  9639.                     bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE_SUFFIX);
  9640.                    
  9641.                     validScopes = autorizzazioneScope.sizeScopeList()>0;
  9642.                    
  9643.                     if(validScopes) {
  9644.                         rowsToolTip++;
  9645.                         if(bfToolTip.length()>0) {
  9646.                             bfToolTip.append("\n");
  9647.                         }
  9648.                         bfToolTip.append("- ").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE_SUFFIX);
  9649.                         bfToolTip.append(" (").append(autorizzazioneScope.sizeScopeList()).append(")");
  9650.                     }
  9651.                     else {
  9652.                         if(bfToolTipNotValid.length()>0) {
  9653.                             bfToolTipNotValid.append("\n");
  9654.                         }
  9655.                         bfToolTipNotValid.append(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_STATO_CONFIGURAZIONI_CONTROLLO_ACCESSO_AUTORIZZAZIONE_TOKEN_NO_SCOPE);
  9656.                     }
  9657.                 }
  9658.                 if(gestioneTokenConfig!=null && gestioneTokenConfig.getOptions()!=null && !"".equals(gestioneTokenConfig.getOptions())) {
  9659.                     if(bf.length()>0) {
  9660.                         bf.append(",");
  9661.                     }
  9662.                     if(bf.length()<=0) {
  9663.                         if(modipa && !portaDelegata) {
  9664.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CANALE);
  9665.                         }
  9666.                         else {
  9667.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TOKEN);
  9668.                         }
  9669.                         bf.append(" [ ");
  9670.                     }
  9671.                     bf.append(" ");
  9672.                     bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_CLAIMS_SUBTITLE_SUFFIX);
  9673.                    
  9674.                     rowsToolTip++;
  9675.                     if(bfToolTip.length()>0) {
  9676.                         bfToolTip.append("\n");
  9677.                     }
  9678.                     String [] tmp = gestioneTokenConfig.getOptions().split("\n");
  9679.                     bfToolTip.append("- ").append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_CLAIMS_SUBTITLE_SUFFIX);
  9680.                     bfToolTip.append(" (").append(tmp!=null ? tmp.length : 0).append(")");
  9681.                 }
  9682.             }
  9683.            
  9684.             if(bf.length()>0) {
  9685.                
  9686.                 bf.append(" ]");
  9687.                
  9688.                 CheckboxStatusType statusAutorizzazione = null;
  9689.                 String tooltip = null;
  9690.                
  9691.                 if(bfToolTipNotValid.length()>0) {
  9692.                     statusAutorizzazione = CheckboxStatusType.CONFIG_ERROR;
  9693.                     tooltip = bfToolTipNotValid.toString();
  9694.                 }
  9695.                 else {
  9696.                     if(bfToolTip.length()>0) {
  9697.                         if(modipa && !portaDelegata) {
  9698.                             tooltip = CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_MESSAGGIO;
  9699.                         }
  9700.                         else {
  9701.                             tooltip = CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_TOKEN;
  9702.                         }
  9703.                         if(rowsToolTip>0) {
  9704.                             tooltip+="\n";
  9705.                         }
  9706.                         tooltip+=bfToolTip.toString();
  9707.                     }
  9708.                    
  9709.                     statusAutorizzazione = CheckboxStatusType.CONFIG_ENABLE;
  9710.                 }
  9711.                
  9712.                 de.addStatus(tooltip, bf.toString(), statusAutorizzazione);
  9713.             }
  9714.            
  9715.            
  9716.             bf = new StringBuilder();
  9717.             bfToolTip = new StringBuilder();
  9718.             bfToolTipNotValid = new StringBuilder();
  9719.             rowsToolTip = 0;
  9720.            
  9721.             if(TipoAutorizzazione.isXacmlPolicyRequired(autorizzazione)) {
  9722.                 if(bf.length()>0) {
  9723.                     bf.append(",");
  9724.                 }
  9725.                 if(bf.length()<=0) {
  9726.                     if(modipa && !portaDelegata) {
  9727.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CANALE);
  9728.                     }
  9729.                     else {
  9730.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_DIFFERENTE_DA_TRASPORTO_E_TOKEN);
  9731.                     }
  9732.                     bf.append(" [ ");
  9733.                 }
  9734.                 bf.append(" ");
  9735.                 bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_XACML_SUFFIX);
  9736.             }
  9737.            
  9738.             if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM.equals(autorizzazione)) {
  9739.                 if(bf.length()>0) {
  9740.                     bf.append(",");
  9741.                 }
  9742.                 if(bf.length()<=0) {
  9743.                     if(modipa && !portaDelegata) {
  9744.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CANALE);
  9745.                     }
  9746.                     else {
  9747.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_DIFFERENTE_DA_TRASPORTO_E_TOKEN);
  9748.                     }
  9749.                     bf.append(" [ ");
  9750.                 }
  9751.                 bf.append(" ");
  9752.                 bf.append(CostantiControlStation.DEFAULT_LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM).append(" '").append(autorizzazioneCustom).append("'");
  9753.                 //bf.append(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM);
  9754.                 bfToolTip.append(": ").append(autorizzazioneCustom);
  9755.             }
  9756.            
  9757.             if(bf.length()>0) {
  9758.                                
  9759.                 bf.append(" ]");
  9760.                
  9761.                 CheckboxStatusType statusAutorizzazione = null;
  9762.                 String tooltip = null;
  9763.                
  9764.                 if(bfToolTipNotValid.length()>0) {
  9765.                     statusAutorizzazione = CheckboxStatusType.CONFIG_ERROR;
  9766.                     tooltip = bfToolTipNotValid.toString();
  9767.                 }
  9768.                 else {
  9769.                     if(bfToolTip.length()>0) {
  9770.                         if(modipa && !portaDelegata) {
  9771.                             tooltip = CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CANALE;
  9772.                         }
  9773.                         else {
  9774.                             tooltip = CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_DIFFERENTE_DA_TRASPORTO_E_TOKEN;
  9775.                         }
  9776.                         if(rowsToolTip>0) {
  9777.                             tooltip+="\n";
  9778.                         }
  9779.                         tooltip+=bfToolTip.toString();
  9780.                     }
  9781.                    
  9782.                     statusAutorizzazione = CheckboxStatusType.CONFIG_ENABLE;
  9783.                 }
  9784.                
  9785.                 de.addStatus(tooltip, bf.toString(), statusAutorizzazione);
  9786.             }
  9787.         }
  9788.                
  9789.         // autorizzazione contenuti
  9790.         if(StringUtils.isNotEmpty(autorizzazioneContenuti)) {
  9791.             StringBuilder bf = new StringBuilder();
  9792.             StringBuilder bfToolTip = new StringBuilder();
  9793.             bf.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI);
  9794.             bfToolTip.append(CostantiControlStation.LABEL_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI);
  9795.             if(!CostantiAutorizzazione.AUTORIZZAZIONE_CONTENUTO_BUILT_IN.equals(autorizzazioneContenuti)) {
  9796.                 //bf.append(" [ ").append(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM).append(" ]");
  9797.                 bf.append(" [ ").append(CostantiControlStation.DEFAULT_LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM).append(" '").append(autorizzazioneContenuti).append("'").append(" ]");
  9798.                 bfToolTip.append(": ").append(autorizzazioneContenuti);
  9799.             }
  9800.             de.addStatus(bfToolTip.toString(), bf.toString(), CheckboxStatusType.CONFIG_ENABLE);
  9801.         }
  9802.        
  9803.         if(de.getStatusValuesAsList()==null || de.getStatusValuesAsList().size()<=0) {
  9804.             de.addStatus(this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO),CheckboxStatusType.CONFIG_DISABLE);
  9805.         }
  9806.        
  9807.     }
  9808.    
  9809.     public void setStatoRateLimiting(DataElement de, List<AttivazionePolicy> listaPolicy) throws DriverControlStationException, DriverControlStationNotFound {
  9810.         setStatoRateLimiting(de, listaPolicy, true);
  9811.     }
  9812.     public void setStatoRateLimiting(DataElement de, List<AttivazionePolicy> listaPolicy, boolean upperFirstChar) throws DriverControlStationException, DriverControlStationNotFound {
  9813.         de.setType(DataElementType.CHECKBOX);
  9814.         if(listaPolicy!=null && listaPolicy.size()>0) {
  9815.             Map<String, Integer> mapActive = new HashMap<>();
  9816.             Map<String, Integer> mapWarningOnly = new HashMap<>();
  9817.             for (AttivazionePolicy attivazionePolicy : listaPolicy) {
  9818.                 if(attivazionePolicy.getEnabled()==false) {
  9819.                     continue;
  9820.                 }
  9821.                 ConfigurazionePolicy policy = this.confCore.getConfigurazionePolicy(attivazionePolicy.getIdPolicy());
  9822.                 String risorsa = policy.getRisorsa();
  9823.                 boolean richiesteSimultanee = policy.isSimultanee();
  9824.                 if(richiesteSimultanee) {
  9825.                     risorsa = risorsa + "Simultanee";
  9826.                 }
  9827.                
  9828.                 Integer count = null;
  9829.                 if(attivazionePolicy.isWarningOnly()) {
  9830.                     if(mapWarningOnly.containsKey(risorsa)){
  9831.                         count = mapWarningOnly.remove(risorsa);
  9832.                     }
  9833.                     else {
  9834.                         count = 0;
  9835.                     }
  9836.                 }
  9837.                 else {
  9838.                     if(mapActive.containsKey(risorsa)){
  9839.                         count = mapActive.remove(risorsa);
  9840.                     }
  9841.                     else {
  9842.                         count = 0;
  9843.                     }
  9844.                 }
  9845.                 count ++;
  9846.                 if(attivazionePolicy.isWarningOnly()) {
  9847.                     mapWarningOnly.put(risorsa, count);
  9848.                 }
  9849.                 else {
  9850.                     mapActive.put(risorsa, count);  
  9851.                 }
  9852.             }
  9853.            
  9854.             if(mapActive.size()>0 && mapWarningOnly.size()>0) {
  9855.                 de.setType(DataElementType.MULTI_SELECT);
  9856.             }
  9857.            
  9858.             if(mapActive.size()>0 || mapWarningOnly.size()>0) {
  9859.                
  9860.                 if(mapActive.size()>0) {
  9861.                     StringBuilder bf = new StringBuilder();
  9862.                     for (String risorsa : mapActive.keySet()) {
  9863.                         Integer count = mapActive.get(risorsa);
  9864.                         if(bf.length()>0) {
  9865.                             bf.append(", ");
  9866.                         }
  9867.                         bf.append(risorsa);
  9868.                         if(count>1) {
  9869.                             bf.append("(").append(count).append(")");
  9870.                         }
  9871.                     }
  9872.                     String vAbilitato = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO) : CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  9873.                     if(bf.length()>0 && bf.length()<CostantiControlStation.MAX_LENGTH_VALORE_STATO_RATE_LIMITING) {
  9874.                         String value = vAbilitato+" [ "+bf.toString()+" ]";
  9875.                         de.addStatus(value, CheckboxStatusType.CONFIG_ENABLE);
  9876.                     }
  9877.                     else {
  9878.                         String value = vAbilitato;
  9879.                         de.addStatus(bf.toString(), value, CheckboxStatusType.CONFIG_ENABLE);
  9880.                     }
  9881.                 }
  9882.                
  9883.                 if(mapWarningOnly.size()>0) {
  9884.                     StringBuilder bf = new StringBuilder();
  9885.                     for (String risorsa : mapWarningOnly.keySet()) {
  9886.                         Integer count = mapWarningOnly.get(risorsa);
  9887.                         if(bf.length()>0) {
  9888.                             bf.append(", ");
  9889.                         }
  9890.                         bf.append(risorsa);
  9891.                         if(count>1) {
  9892.                             bf.append("(").append(count).append(")");
  9893.                         }
  9894.                     }
  9895.                     String vWarningOnly = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_WARNING_ONLY) : CostantiControlStation.DEFAULT_VALUE_WARNING_ONLY;
  9896.                     if(bf.length()>0 && bf.length()<CostantiControlStation.MAX_LENGTH_VALORE_STATO_RATE_LIMITING) {
  9897.                         String value = vWarningOnly+" [ "+bf.toString()+" ]";
  9898.                         de.addStatus(value, CheckboxStatusType.CONFIG_WARNING);
  9899.                     }
  9900.                     else {
  9901.                         String value = vWarningOnly;
  9902.                         de.addStatus(bf.toString(), value, CheckboxStatusType.CONFIG_WARNING);
  9903.                     }
  9904.                 }
  9905.                
  9906.             }
  9907.             else {
  9908.                 de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  9909.                 String vDisable = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO) :  CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  9910.                 de.setStatusValue(vDisable);
  9911.                 de.setStatusToolTip("Sull'API sono registrate "+listaPolicy.size()+" politiche di Rate Limiting tutte con stato disabilitato");
  9912.             }
  9913.            
  9914.         }
  9915.         else {
  9916.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  9917.             String vDisable = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO) :  CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  9918.             de.setStatusValue(vDisable);
  9919.         }
  9920.     }
  9921.    
  9922.     public void setStatoValidazioneContenuti(DataElement de, ValidazioneContenutiApplicativi val, FormatoSpecifica formatoSpecifica) throws DriverControlStationException, DriverControlStationNotFound {
  9923.         de.setType(DataElementType.CHECKBOX);
  9924.         if(val!=null && !StatoFunzionalitaConWarning.DISABILITATO.equals(val.getStato())) {
  9925.             String valore = null;
  9926.             if(StatoFunzionalitaConWarning.ABILITATO.equals(val.getStato())) {
  9927.                 de.setStatusType(CheckboxStatusType.CONFIG_ENABLE);
  9928.                 valore = CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  9929.             }
  9930.             else {
  9931.                 de.setStatusType(CheckboxStatusType.CONFIG_WARNING);
  9932.                 valore = CostantiControlStation.DEFAULT_VALUE_WARNING_ONLY;
  9933.             }
  9934.             String label = null;
  9935.             switch (val.getTipo()) {
  9936.             case INTERFACE:
  9937.                 switch (formatoSpecifica) {
  9938.                 case OPEN_API_3:
  9939.                     label=CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_OPEN_API_3;
  9940.                     break;
  9941.                 case SWAGGER_2:
  9942.                     label=CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_SWAGGER_2;
  9943.                     break;
  9944.                 case WADL:
  9945.                     label=CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_WADL;
  9946.                     break;
  9947.                 case WSDL_11:
  9948.                     label=CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_WSDL_11;
  9949.                     break;
  9950.                 }
  9951.                 break;
  9952.             case XSD:
  9953.                 label=CostantiControlStation.LABEL_PARAMETRO_SCHEMI_XSD;
  9954.                 break;
  9955.             case OPENSPCOOP:
  9956.                 label=CostantiControlStation.LABEL_PARAMETRO_REGISTRO_OPENSPCOOP;
  9957.                 break;
  9958.             }
  9959.             de.setStatusValue(this.getUpperFirstChar(valore)+" [ "+label+" ]");
  9960.         }
  9961.         else {
  9962.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  9963.             de.setStatusValue(this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO));
  9964.         }
  9965.     }
  9966.    
  9967.     public void setStatoGestioneCORS(DataElement de, CorsConfigurazione ccPorta, Configurazione configurazioneGenerale) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  9968.        
  9969.         de.setType(DataElementType.CHECKBOX);
  9970.        
  9971.         CheckboxStatusType statusType = null;
  9972.         String statusValue = null;
  9973.         String statusTooltip = null;
  9974.        
  9975.         if (ccPorta == null) {
  9976.            
  9977.             CorsConfigurazione cc = configurazioneGenerale.getGestioneCors();
  9978.             if(cc==null || cc.getStato()==null || StatoFunzionalita.DISABILITATO.equals(cc.getStato())) {
  9979.                 statusType = CheckboxStatusType.CONFIG_DISABLE;
  9980.                 statusValue = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO);
  9981.             }
  9982.             else {
  9983.                 statusType = CheckboxStatusType.CONFIG_ENABLE;
  9984.                 if(TipoGestioneCORS.GATEWAY.equals(cc.getTipo())) {
  9985.                     statusValue = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO);
  9986.                 }
  9987.                 else {
  9988.                     statusValue = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO)+" [ "+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_TIPO_GESTITO_APPLICATIVO_DEMANDATO+" ]";
  9989.                 }
  9990.             }
  9991.            
  9992.             statusTooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_DEFAULT;
  9993.            
  9994.         } else {
  9995.            
  9996.             if(ccPorta.getStato()==null || StatoFunzionalita.DISABILITATO.equals(ccPorta.getStato())) {
  9997.                 statusType = CheckboxStatusType.CONFIG_DISABLE;
  9998.                 statusValue = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO);
  9999.             }
  10000.             else {
  10001.                 statusType = CheckboxStatusType.CONFIG_ENABLE;
  10002.                 if(TipoGestioneCORS.GATEWAY.equals(ccPorta.getTipo())) {
  10003.                     statusValue = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO);
  10004.                 }
  10005.                 else {
  10006.                     statusValue = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO)+" [ "+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_TIPO_GESTITO_APPLICATIVO_DEMANDATO+" ]";
  10007.                 }
  10008.             }
  10009.            
  10010.             statusTooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_RIDEFINITA;
  10011.         }
  10012.        
  10013.         de.setStatusType(statusType);
  10014.         de.setStatusValue(statusValue);
  10015.         de.setStatusToolTip(statusTooltip);
  10016.     }

  10017.     public CanaleConfigurazione getCanaleDefault(List<CanaleConfigurazione> canaleList) throws DriverConfigurazioneNotFound {
  10018.         CanaleConfigurazione canaleConfigurazioneDefault = null;
  10019.         if(canaleList!=null && !canaleList.isEmpty()) {
  10020.             for (CanaleConfigurazione c : canaleList) {
  10021.                 if(c.isCanaleDefault()) {
  10022.                     canaleConfigurazioneDefault = c;
  10023.                     break;
  10024.                 }
  10025.             }
  10026.         }
  10027.         if(canaleConfigurazioneDefault==null) {
  10028.             throw new DriverConfigurazioneNotFound("Canale di default non trovato nella lista fornita '"+canaleList+"'");
  10029.         }
  10030.         return canaleConfigurazioneDefault;
  10031.     }
  10032.    
  10033.     public void setStatoCanale(DataElement de, String canaleNome, List<CanaleConfigurazione> canaleList) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  10034.         de.setType(DataElementType.TEXT);
  10035.        
  10036.         String canaleTooltip;
  10037.         if(canaleNome == null) { // default
  10038.             CanaleConfigurazione canaleConfigurazioneDefault = getCanaleDefault(canaleList);
  10039.             canaleNome =  canaleConfigurazioneDefault.getNome();
  10040.             canaleTooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_CANALE_DEFAULT;
  10041.         } else {
  10042.             canaleTooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_CANALE_RIDEFINITO_API;
  10043.         }
  10044.        
  10045.         de.setValue(canaleNome);
  10046.         de.setToolTip(canaleTooltip);
  10047.     }
  10048.     public void setStatoCanalePorta(DataElement de, String canaleNome, String canaleAPINome,  List<CanaleConfigurazione> canaleList, boolean erogazione) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  10049.        
  10050.         de.setType(DataElementType.TEXT);
  10051.        
  10052.         String canaleTooltip;
  10053.         if(canaleNome == null) { // default
  10054.             if(canaleAPINome == null) { // default sistema
  10055.                 CanaleConfigurazione canaleConfigurazioneDefault = getCanaleDefault(canaleList);
  10056.                 canaleNome =  canaleConfigurazioneDefault.getNome();
  10057.                 canaleTooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_CANALE_DEFAULT;
  10058.             } else { // default API
  10059.                 canaleNome = canaleAPINome;
  10060.                 canaleTooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_CANALE_DEFAULT_API;
  10061.             }
  10062.         } else {
  10063.             if(erogazione) {
  10064.                 canaleTooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_CANALE_RIDEFINITO_EROGAZIONE;
  10065.             }
  10066.             else {
  10067.                 canaleTooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_CANALE_RIDEFINITO_FRUIZIONE;
  10068.             }
  10069.         }
  10070.        
  10071.         de.setValue(canaleNome);
  10072.         de.setToolTip(canaleTooltip);
  10073.     }
  10074.    
  10075.     public void setStatoAllarmi(DataElement de, List<ConfigurazioneAllarmeBean> listaAllarmi) throws DriverControlStationException, DriverControlStationNotFound, UtilsException {
  10076.         if(this.confCore.isShowAllarmiElenchiStatiAllarmi()) {
  10077.             setStatoAllarmi_showStati(de, listaAllarmi);
  10078.         }
  10079.         else {
  10080.             setStatoAllarmi_showTipi(de, listaAllarmi);
  10081.         }
  10082.     }
  10083.     public void setStatoAllarmi_showStati(DataElement de, List<ConfigurazioneAllarmeBean> listaAllarmi) throws DriverControlStationException, DriverControlStationNotFound {
  10084.        
  10085.         de.setType(DataElementType.CHECKBOX);
  10086.         if(listaAllarmi!=null && listaAllarmi.size()>0) {
  10087.             Integer countOk = 0;
  10088.             Integer countError = 0;
  10089.             Integer countWarn = 0;
  10090.            
  10091.             for (ConfigurazioneAllarmeBean allarme : listaAllarmi) {
  10092.                 if(allarme.getEnabled() == 0) {// skip dei disabilitati
  10093.                     continue;
  10094.                 }
  10095.                
  10096.                 StatoAllarme statoAllarme = AllarmiConverterUtils.toStatoAllarme(allarme.getStato());
  10097.                 switch (statoAllarme) {
  10098.                 case OK:
  10099.                     countOk ++;
  10100.                     break;
  10101.                 case WARNING:
  10102.                     countWarn ++;
  10103.                     break;
  10104.                 case ERROR:
  10105.                     countError ++;
  10106.                     break;
  10107.                 }
  10108.             }
  10109.            
  10110.             int multi = 0;
  10111.            
  10112.             if(countOk > 0)
  10113.                 multi++;
  10114.            
  10115.             if(countError > 0)
  10116.                 multi++;
  10117.            
  10118.             if(countWarn > 0)
  10119.                 multi++;
  10120.            
  10121.             if(multi > 1) {
  10122.                 de.setType(DataElementType.MULTI_SELECT);
  10123.             }
  10124.            
  10125.             if(countOk > 0 || countError > 0 || countWarn > 0) {
  10126.                
  10127.                 if(countOk > 0) {
  10128.                     StringBuilder bf = new StringBuilder();
  10129.                     bf.append(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_OK);
  10130.                     bf.append(" (").append(countOk).append(")");
  10131.                     de.addStatus(bf.toString(), CheckboxStatusType.CONFIG_ENABLE);
  10132.                 }
  10133.                
  10134.                 if(countWarn > 0) {
  10135.                     StringBuilder bf = new StringBuilder();
  10136.                     bf.append(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_WARNING);
  10137.                     bf.append(" (").append(countWarn).append(")");
  10138.                     de.addStatus(bf.toString(), CheckboxStatusType.CONFIG_WARNING);
  10139.                 }
  10140.                
  10141.                 if(countError > 0) {
  10142.                     StringBuilder bf = new StringBuilder();
  10143.                     bf.append(ConfigurazioneCostanti.CONFIGURAZIONE_ALLARME_LABEL_STATO_ERROR);
  10144.                     bf.append(" (").append(countError).append(")");
  10145.                     de.addStatus(bf.toString(), CheckboxStatusType.CONFIG_ERROR);
  10146.                 }
  10147.             }
  10148.             else {
  10149.                 de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  10150.                 de.setStatusValue(this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO));
  10151.                 de.setStatusToolTip("Sull'API sono registrati "+listaAllarmi.size()+" allarmi tutti con stato disabilitato");
  10152.             }
  10153.            
  10154.         }
  10155.         else {
  10156.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  10157.             de.setStatusValue(this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO));
  10158.         }
  10159.     }
  10160.     public void setStatoAllarmi_showTipi(DataElement de, List<ConfigurazioneAllarmeBean> listaAllarmi) throws DriverControlStationException, DriverControlStationNotFound {
  10161.         de.setType(DataElementType.CHECKBOX);
  10162.         if(listaAllarmi!=null && listaAllarmi.size()>0) {
  10163.             Map<String, Integer> mapActive = new HashMap<>();
  10164.             for (ConfigurazioneAllarmeBean allarme : listaAllarmi) {
  10165.                 if(allarme.getEnabled().intValue()==0) {
  10166.                     continue;
  10167.                 }
  10168.                 //String tipoPlugin = allarme.getPlugin().getLabel();
  10169.                 String tipoPlugin = allarme.getPlugin().getTipo(); // più compatto
  10170.                
  10171.                 Integer count = null;
  10172.                 if(mapActive.containsKey(tipoPlugin)){
  10173.                     count = mapActive.remove(tipoPlugin);
  10174.                 }
  10175.                 else {
  10176.                     count = 0;
  10177.                 }
  10178.                 count ++;
  10179.                 mapActive.put(tipoPlugin, count);  
  10180.             }
  10181.            
  10182.             if(mapActive.size()>0) {
  10183.                
  10184.                 if(mapActive.size()>0) {
  10185.                     StringBuilder bf = new StringBuilder();
  10186.                     for (String risorsa : mapActive.keySet()) {
  10187.                         Integer count = mapActive.get(risorsa);
  10188.                         if(bf.length()>0) {
  10189.                             bf.append(", ");
  10190.                         }
  10191.                         bf.append(risorsa);
  10192.                         if(count>1) {
  10193.                             bf.append("(").append(count).append(")");
  10194.                         }
  10195.                     }
  10196.                     if(bf.length()>0 && bf.length()<CostantiControlStation.MAX_LENGTH_VALORE_STATO_ALLARMI) {
  10197.                         String value = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO)+" [ "+bf.toString()+" ]";
  10198.                         de.addStatus(value, CheckboxStatusType.CONFIG_ENABLE);
  10199.                     }
  10200.                     else {
  10201.                         String value = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO);
  10202.                         de.addStatus(bf.toString(), value, CheckboxStatusType.CONFIG_ENABLE);
  10203.                     }
  10204.                 }
  10205.                
  10206.             }
  10207.             else {
  10208.                 de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  10209.                 de.setStatusValue(this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO));
  10210.                 de.setStatusToolTip("Sull'API sono registrati "+listaAllarmi.size()+" allarmi tutti con stato disabilitato");
  10211.             }
  10212.            
  10213.         }
  10214.         else {
  10215.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  10216.             de.setStatusValue(this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO));
  10217.         }
  10218.     }
  10219.    
  10220.    
  10221.     public void setStatoOpzioniAvanzatePortaDelegataDefault(DataElement de, String options) throws DriverControlStationException {
  10222.         this._setStatoOpzioniAvanzatePortaDefault(de, options);
  10223.     }
  10224.     public void setStatoOpzioniAvanzatePortaApplicativaDefault(DataElement de, String options) throws DriverControlStationException {
  10225.         this._setStatoOpzioniAvanzatePortaDefault(de, options);
  10226.     }
  10227.     private void _setStatoOpzioniAvanzatePortaDefault(DataElement de, String options) throws DriverControlStationException {
  10228.        
  10229.         de.setType(DataElementType.CHECKBOX);
  10230.        
  10231.         Map<String, List<String>> props = null;
  10232.         try {
  10233.             props = PropertiesSerializator.convertoFromDBColumnValue(options);
  10234.         }catch(Exception e) {
  10235.             throw new DriverControlStationException(e.getMessage(),e);
  10236.         }
  10237.         StringBuilder bf = new StringBuilder();
  10238.         StringBuilder bfTooltip = new StringBuilder();
  10239.         if(props!=null && props.size()>0) {
  10240.             for (String key : props.keySet()) {
  10241.                 List<String> values = props.get(key);
  10242.                 if(values!=null && !values.isEmpty()) {
  10243.                     for (String value : values) {
  10244.                         if(bf.length()>0) {
  10245.                             bf.append(", ");
  10246.                         }
  10247.                         bf.append(key);
  10248.                        
  10249.                         if(bfTooltip.length()>0) {
  10250.                             bfTooltip.append(", ");
  10251.                         }
  10252.                         bfTooltip.append(key);
  10253.                         bfTooltip.append(" '");
  10254.                         bfTooltip.append(value);
  10255.                         bfTooltip.append("'");      
  10256.                     }
  10257.                 }
  10258.             }
  10259.         }
  10260.        
  10261.        
  10262.         if(bf.length()>0) {
  10263.             de.setStatusType(CheckboxStatusType.CONFIG_ENABLE);
  10264.             de.setStatusValue(this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO)+" [ "+bf.toString()+" ]");
  10265.             de.setStatusToolTip(bfTooltip.toString());
  10266.         }
  10267.         else {
  10268.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  10269.             de.setStatusValue(this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO));
  10270.         }
  10271.     }
  10272.    
  10273.     public void setStatoCachingRisposta(DataElement de, ResponseCachingConfigurazione rcPorta, Configurazione configurazioneGenerale) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  10274.        
  10275.         de.setType(DataElementType.CHECKBOX);
  10276.        
  10277.         CheckboxStatusType statusType = null;
  10278.         String statusValue = null;
  10279.         String statusTooltip = null;
  10280.        
  10281.         if (rcPorta == null) {
  10282.            
  10283.             ResponseCachingConfigurazioneGenerale rg = configurazioneGenerale.getResponseCaching();
  10284.             if(rg==null || rg.getConfigurazione()==null || rg.getConfigurazione().getStato()==null ||
  10285.                     StatoFunzionalita.DISABILITATO.equals(rg.getConfigurazione().getStato())) {
  10286.                 statusType = CheckboxStatusType.CONFIG_DISABLE;
  10287.                 statusValue = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO);
  10288.             }
  10289.             else {
  10290.                 statusType = CheckboxStatusType.CONFIG_ENABLE;
  10291.                 statusValue = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO);
  10292.             }
  10293.            
  10294.             statusTooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_DEFAULT;
  10295.            
  10296.         } else {
  10297.            
  10298.             if(rcPorta.getStato()==null || StatoFunzionalita.DISABILITATO.equals(rcPorta.getStato()) ) {
  10299.                 statusType = CheckboxStatusType.CONFIG_DISABLE;
  10300.                 statusValue = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO);
  10301.             }
  10302.             else {
  10303.                 statusType = CheckboxStatusType.CONFIG_ENABLE;
  10304.                 statusValue = this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO);
  10305.             }
  10306.            
  10307.             statusTooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_RIDEFINITA;
  10308.         }
  10309.        
  10310.         de.setStatusType(statusType);
  10311.         de.setStatusValue(statusValue);
  10312.         de.setStatusToolTip(statusTooltip);
  10313.     }
  10314.    
  10315.     public void setStatoSicurezzaMessaggio(DataElement de, MessageSecurity securityPorta,
  10316.             ConfigManager configManager, PropertiesSourceConfiguration propertiesSourceConfiguration) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  10317.         setStatoSicurezzaMessaggio(de, securityPorta,
  10318.                 configManager, propertiesSourceConfiguration, true);
  10319.     }
  10320.     public void setStatoSicurezzaMessaggio(DataElement de, MessageSecurity securityPorta,
  10321.             ConfigManager configManager, PropertiesSourceConfiguration propertiesSourceConfiguration, boolean upperFirstChar) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  10322.        
  10323.         boolean request = (
  10324.                 securityPorta!=null &&
  10325.                 securityPorta.getRequestFlow()!=null &&
  10326.                 securityPorta.getRequestFlow().getMode()!=null &&
  10327.                 !"".equals(securityPorta.getRequestFlow().getMode()) &&
  10328.                 !CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals( securityPorta.getRequestFlow().getMode())
  10329.                 );
  10330.        
  10331.         boolean response = (
  10332.                 securityPorta!=null &&
  10333.                 securityPorta.getResponseFlow()!=null &&
  10334.                 securityPorta.getResponseFlow().getMode()!=null &&
  10335.                 !"".equals(securityPorta.getResponseFlow().getMode()) &&
  10336.                 !CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals( securityPorta.getResponseFlow().getMode())
  10337.                 );
  10338.        
  10339.         if (securityPorta == null || (!request && !response) ) {
  10340.             de.setType(DataElementType.CHECKBOX);
  10341.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  10342.             String value = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO) : CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  10343.             de.setStatusValue(value);      
  10344.         } else {
  10345.            
  10346.             de.setType(DataElementType.MULTI_SELECT);
  10347.            
  10348.             if(request) {
  10349.                 CheckboxStatusType type = securityPorta.getRequestFlow().sizeParameterList()>0 ? CheckboxStatusType.CONFIG_ENABLE : CheckboxStatusType.CONFIG_ERROR;
  10350.                 String tooltip = securityPorta.getRequestFlow().sizeParameterList()>0 ? null : CostantiControlStation.LABEL_CONFIGURAZIONE_INCOMPLETA;
  10351.                 String label = null;
  10352.                 if(CostantiControlStation.VALUE_PARAMETRO_PROPERTIES_MODE_DEFAULT.equals( securityPorta.getRequestFlow().getMode())) {
  10353.                     label = CostantiControlStation.LABEL_CONFIGURAZIONE_PROPERTIES_CONFIGURAZIONE_MANUALE;
  10354.                 }
  10355.                 else {
  10356.                     List<String> nome =new ArrayList<>();
  10357.                     nome.add(securityPorta.getRequestFlow().getMode());
  10358.                     List<String> labelConfigurazione = configManager.convertToLabel(propertiesSourceConfiguration, nome);
  10359.                     label = labelConfigurazione.get(0);
  10360.                 }
  10361.                 String value = (upperFirstChar ? CostantiControlStation.LABEL_PARAMETRO_RICHIESTA : CostantiControlStation.LABEL_PARAMETRO_RICHIESTA.toLowerCase())+" [ "+label+" ]";
  10362.                 de.addStatus(tooltip, value, type);
  10363.             }
  10364.            
  10365.             if(response) {
  10366.                 CheckboxStatusType type = securityPorta.getResponseFlow().sizeParameterList()>0 ? CheckboxStatusType.CONFIG_ENABLE : CheckboxStatusType.CONFIG_ERROR;
  10367.                 String tooltip = securityPorta.getResponseFlow().sizeParameterList()>0 ? null : CostantiControlStation.LABEL_CONFIGURAZIONE_INCOMPLETA;
  10368.                 String label = null;
  10369.                 if(CostantiControlStation.VALUE_PARAMETRO_PROPERTIES_MODE_DEFAULT.equals( securityPorta.getResponseFlow().getMode())) {
  10370.                     label = CostantiControlStation.LABEL_CONFIGURAZIONE_PROPERTIES_CONFIGURAZIONE_MANUALE;
  10371.                 }
  10372.                 else {
  10373.                     List<String> nome =new ArrayList<>();
  10374.                     nome.add(securityPorta.getResponseFlow().getMode());
  10375.                     List<String> labelConfigurazione = configManager.convertToLabel(propertiesSourceConfiguration, nome);
  10376.                     label = labelConfigurazione.get(0);
  10377.                 }
  10378.                 String value = (upperFirstChar ? CostantiControlStation.LABEL_PARAMETRO_RISPOSTA : CostantiControlStation.LABEL_PARAMETRO_RISPOSTA.toLowerCase())+" [ "+label+" ]";
  10379.                 de.addStatus(tooltip, value, type);
  10380.             }
  10381.         }

  10382.     }
  10383.    
  10384.     public void setStatoMTOM(DataElement de, MtomProcessor mtomPorta) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  10385.         setStatoMTOM(de, mtomPorta, true);
  10386.     }
  10387.     public void setStatoMTOM(DataElement de, MtomProcessor mtomPorta, boolean upperFirstChar) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  10388.        
  10389.         boolean request = false;
  10390.         boolean response= false;
  10391.         if(mtomPorta!= null){
  10392.             if(mtomPorta.getRequestFlow() != null){
  10393.                 if(mtomPorta.getRequestFlow().getMode() != null){
  10394.                     MTOMProcessorType mode = mtomPorta.getRequestFlow().getMode();
  10395.                     if(!mode.equals(MTOMProcessorType.DISABLE))
  10396.                         request = true;
  10397.                 }
  10398.             }

  10399.             if(mtomPorta.getResponseFlow() != null){
  10400.                 if(mtomPorta.getResponseFlow().getMode() != null){
  10401.                     MTOMProcessorType mode = mtomPorta.getResponseFlow().getMode();
  10402.                     if(!mode.equals(MTOMProcessorType.DISABLE))
  10403.                         response = true;
  10404.                 }
  10405.             }
  10406.         }
  10407.        
  10408.         if (mtomPorta == null || (!request && !response) ) {
  10409.             de.setType(DataElementType.CHECKBOX);
  10410.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  10411.             String vUpper = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO) :  CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  10412.             de.setStatusValue(vUpper);      
  10413.         } else {
  10414.            
  10415.             de.setType(DataElementType.MULTI_SELECT);
  10416.            
  10417.             if(request) {
  10418.                
  10419.                 CheckboxStatusType type = null;
  10420.                 String tooltip =  null;
  10421.                 switch (mtomPorta.getRequestFlow().getMode()) {
  10422.                 case PACKAGING:
  10423.                 case VERIFY:    
  10424.                     type = mtomPorta.getRequestFlow().sizeParameterList()>0 ? CheckboxStatusType.CONFIG_ENABLE : CheckboxStatusType.CONFIG_ERROR;
  10425.                     tooltip = mtomPorta.getRequestFlow().sizeParameterList()>0 ? null : CostantiControlStation.LABEL_CONFIGURAZIONE_MTOM_INCOMPLETA;
  10426.                     break;
  10427.                 default:
  10428.                     type = CheckboxStatusType.CONFIG_ENABLE;
  10429.                     break;
  10430.                 }
  10431.                 String v = mtomPorta.getRequestFlow().getMode().getValue();
  10432.                 String value = (upperFirstChar ? CostantiControlStation.LABEL_PARAMETRO_RICHIESTA : CostantiControlStation.LABEL_PARAMETRO_RICHIESTA.toLowerCase())+" [ "+this.getUpperFirstChar(v)+" ]";
  10433.                 de.addStatus(tooltip, value, type);
  10434.             }
  10435.            
  10436.             if(response) {
  10437.                
  10438.                 CheckboxStatusType type = null;
  10439.                 String tooltip =  null;
  10440.                 switch (mtomPorta.getResponseFlow().getMode()) {
  10441.                 case PACKAGING:
  10442.                 case VERIFY:    
  10443.                     type = mtomPorta.getResponseFlow().sizeParameterList()>0 ? CheckboxStatusType.CONFIG_ENABLE : CheckboxStatusType.CONFIG_ERROR;
  10444.                     tooltip = mtomPorta.getResponseFlow().sizeParameterList()>0 ? null : CostantiControlStation.LABEL_CONFIGURAZIONE_MTOM_INCOMPLETA;
  10445.                     break;
  10446.                 default:
  10447.                     type = CheckboxStatusType.CONFIG_ENABLE;
  10448.                     break;
  10449.                 }
  10450.                 String v = mtomPorta.getResponseFlow().getMode().getValue();
  10451.                 String value = (upperFirstChar ? CostantiControlStation.LABEL_PARAMETRO_RISPOSTA : CostantiControlStation.LABEL_PARAMETRO_RISPOSTA.toLowerCase())+" [ "+this.getUpperFirstChar(v)+" ]";
  10452.                 de.addStatus(tooltip, value, type);
  10453.             }
  10454.            
  10455.         }
  10456.        
  10457.     }
  10458.    
  10459.     public void setStatoTrasformazioni(DataElement de, Trasformazioni trasformazioni, ServiceBinding serviceBindingMessage) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  10460.         setStatoTrasformazioni(de, trasformazioni, serviceBindingMessage, true);
  10461.     }
  10462.     public void setStatoTrasformazioni(DataElement de, Trasformazioni trasformazioni, ServiceBinding serviceBindingMessage, boolean upperFirstChar) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  10463.        
  10464.         de.setType(DataElementType.CHECKBOX);
  10465.        
  10466.         List<TrasformazioneRegola> listaTrasformazioni = null;
  10467.         if(trasformazioni!=null) {
  10468.             listaTrasformazioni = trasformazioni.getRegolaList();
  10469.         }
  10470.         if(listaTrasformazioni==null || listaTrasformazioni.size()<=0) {
  10471.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  10472.             String vDisabilitato = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO) :  CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  10473.             de.setStatusValue(vDisabilitato);      
  10474.         }
  10475.         else {
  10476.             StringBuilder bfToolTip = new StringBuilder();
  10477.             CheckboxStatusType type = null;
  10478.            
  10479.             int regoleAbilitate = 0;
  10480.             int regoleDisabilitate = 0;
  10481.            
  10482.             for (TrasformazioneRegola trasformazioneRegola : listaTrasformazioni) {
  10483.                                
  10484.                 if(trasformazioneRegola.getStato()!=null // backward compatibility
  10485.                         &&
  10486.                         StatoFunzionalita.DISABILITATO.equals(trasformazioneRegola.getStato())){
  10487.                     regoleDisabilitate++;
  10488.                     continue;
  10489.                 }
  10490.                 else {
  10491.                     regoleAbilitate++;
  10492.                 }
  10493.                
  10494.                 boolean richiestaDefinita = false;
  10495.                 if(trasformazioneRegola.getRichiesta()!=null) {
  10496.                     richiestaDefinita = trasformazioneRegola.getRichiesta().isConversione() ||
  10497.                             trasformazioneRegola.getRichiesta().sizeHeaderList()>0 ||
  10498.                             trasformazioneRegola.getRichiesta().sizeParametroUrlList()>0 ||
  10499.                             (
  10500.                                     ServiceBinding.REST.equals(serviceBindingMessage) &&
  10501.                                     trasformazioneRegola.getRichiesta().getTrasformazioneRest()!=null &&
  10502.                                     (
  10503.                                         StringUtils.isNotEmpty(trasformazioneRegola.getRichiesta().getTrasformazioneRest().getMetodo())
  10504.                                         ||
  10505.                                         StringUtils.isNotEmpty(trasformazioneRegola.getRichiesta().getTrasformazioneRest().getPath())
  10506.                                     )
  10507.                             )
  10508.                         ;
  10509.                 }
  10510.                
  10511.                 if(trasformazioneRegola.sizeRispostaList()>0) {
  10512.                     for (TrasformazioneRegolaRisposta trasformazioneRegolaRisposta : trasformazioneRegola.getRispostaList()) {
  10513.                         boolean rispostaDefinita = false;
  10514.                         if(trasformazioneRegolaRisposta!=null) {
  10515.                             rispostaDefinita = trasformazioneRegolaRisposta.isConversione() ||
  10516.                                     trasformazioneRegolaRisposta.sizeHeaderList()>0 ||
  10517.                                     (trasformazioneRegolaRisposta.getReturnCode()!=null && StringUtils.isNotEmpty(trasformazioneRegolaRisposta.getReturnCode()));
  10518.                         }
  10519.                         if(!rispostaDefinita) {
  10520.                             type = CheckboxStatusType.CONFIG_ERROR;
  10521.                             if(bfToolTip.length()>0) {
  10522.                                 bfToolTip.append("\n");
  10523.                             }
  10524.                             if(trasformazioneRegolaRisposta!=null) {
  10525.                                 bfToolTip.append("La regola '"+trasformazioneRegola.getNome()+"' possiede una configurazione per la risposta ('"+trasformazioneRegolaRisposta.getNome()+"') senza alcuna trasformazione attiva");
  10526.                             }
  10527.                             else {
  10528.                                 bfToolTip.append("La regola '"+trasformazioneRegola.getNome()+"' non possiede una configurazione per la risposta");
  10529.                             }
  10530.                             break;
  10531.                         }
  10532.                     }              
  10533.                 }
  10534.                 else if(!richiestaDefinita) {
  10535.                     type = CheckboxStatusType.CONFIG_ERROR;
  10536.                     if(bfToolTip.length()>0) {
  10537.                         bfToolTip.append("\n");
  10538.                     }  
  10539.                     bfToolTip.append("La regola '"+trasformazioneRegola.getNome()+"' non effettua trasformazioni nè della richiesta nè della risposta");
  10540.                 }
  10541.                
  10542.             }
  10543.            
  10544.             if(regoleAbilitate==0) {
  10545.                 de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  10546.                 String vDisabilitato = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO) :  CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  10547.                 de.setStatusValue(vDisabilitato);  
  10548.                 if(regoleDisabilitate>0) {
  10549.                     de.setStatusToolTip("Sono registrate, con stato disabilitato, "+regoleDisabilitate+" regole di trasformazione dei messaggi");
  10550.                 }
  10551.             }
  10552.             else {
  10553.            
  10554.                 if(type==null) {
  10555.                     type = CheckboxStatusType.CONFIG_ENABLE;
  10556.                 }
  10557.                 de.setStatusType(type);
  10558.                 String vAbilitato = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO) :  CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  10559.                 de.setStatusValue(vAbilitato);
  10560.                 if(bfToolTip.length()>0) {
  10561.                     de.setStatusToolTip(bfToolTip.toString());
  10562.                 }
  10563.                 else {
  10564.                     if(listaTrasformazioni.size()>1) {
  10565.                         de.setStatusToolTip("Sono attive "+regoleAbilitate+" regole di trasformazione dei messaggi");
  10566.                     }
  10567.                 }
  10568.                
  10569.             }
  10570.         }
  10571.     }
  10572.    
  10573.     public void setStatoTracciamento(DataElement de,
  10574.             CorrelazioneApplicativa correlazioneApplicativa,
  10575.             CorrelazioneApplicativaRisposta correlazioneApplicativaRisposta,
  10576.             PortaTracciamento tracciamentoConfig, ConfigurazioneTracciamentoPorta configurazioneTracciamento,
  10577.             List<Proprieta> proprietaPorta,
  10578.             Configurazione configurazioneGenerale) throws DriverControlStationException {
  10579.        
  10580.         de.setType(DataElementType.MULTI_SELECT);
  10581.                
  10582.         String tooltipTransazioni = null;
  10583.         boolean transazioniDB = false;
  10584.         boolean transazioniFiletrace = false;
  10585.         if(tracciamentoConfig!=null && tracciamentoConfig.getStato()!=null && org.openspcoop2.core.config.constants.StatoFunzionalita.ABILITATO.equals(tracciamentoConfig.getStato())) {
  10586.            
  10587.             tooltipTransazioni = CostantiControlStation.LABEL_CONFIGURAZIONE_RIDEFINITA;
  10588.            
  10589.             transazioniDB = tracciamentoConfig.getDatabase()==null || tracciamentoConfig.getDatabase().getStato()==null ||
  10590.                     !org.openspcoop2.core.config.constants.StatoFunzionalitaConPersonalizzazione.DISABILITATO.equals(tracciamentoConfig.getDatabase().getStato());
  10591.             if(transazioniDB &&
  10592.                     (tracciamentoConfig.getDatabase()==null || tracciamentoConfig.getDatabase().getFiltroEsiti()==null ||
  10593.                             org.openspcoop2.core.config.constants.StatoFunzionalita.ABILITATO.equals(tracciamentoConfig.getDatabase().getFiltroEsiti()))
  10594.                     ) {
  10595.                 transazioniDB = tracciamentoConfig.getEsiti()!=null
  10596.                         &&!(EsitiConfigUtils.TUTTI_ESITI_DISABILITATI+"").equals(tracciamentoConfig.getEsiti());
  10597.             }
  10598.            
  10599.             transazioniFiletrace = tracciamentoConfig.getFiletrace()!=null && tracciamentoConfig.getFiletrace().getStato()!=null &&
  10600.                     !org.openspcoop2.core.config.constants.StatoFunzionalitaConPersonalizzazione.DISABILITATO.equals(tracciamentoConfig.getFiletrace().getStato());
  10601.             if(transazioniFiletrace &&
  10602.                     (tracciamentoConfig.getDatabase()!=null && tracciamentoConfig.getDatabase().getFiltroEsiti()!=null &&
  10603.                             org.openspcoop2.core.config.constants.StatoFunzionalita.ABILITATO.equals(tracciamentoConfig.getDatabase().getFiltroEsiti()))
  10604.                     ) {
  10605.                 transazioniFiletrace = tracciamentoConfig.getEsiti()!=null
  10606.                         &&!(EsitiConfigUtils.TUTTI_ESITI_DISABILITATI+"").equals(tracciamentoConfig.getEsiti());
  10607.             }
  10608.         }
  10609.         else {
  10610.             tooltipTransazioni = CostantiControlStation.LABEL_CONFIGURAZIONE_DEFAULT;
  10611.             String esitiTransazioni = this.readConfigurazioneRegistrazioneEsitiFromHttpParameters((configurazioneTracciamento!=null) ? configurazioneTracciamento.getEsiti() : null , true);
  10612.            
  10613.             transazioniDB = configurazioneTracciamento==null || configurazioneTracciamento.getDatabase()==null || configurazioneTracciamento.getDatabase().getStato()==null ||
  10614.                     !org.openspcoop2.core.config.constants.StatoFunzionalitaConPersonalizzazione.DISABILITATO.equals(configurazioneTracciamento.getDatabase().getStato());
  10615.             if(transazioniDB &&  
  10616.                     (configurazioneTracciamento==null || configurazioneTracciamento.getDatabase()==null || configurazioneTracciamento.getDatabase().getFiltroEsiti()==null ||
  10617.                             org.openspcoop2.core.config.constants.StatoFunzionalita.ABILITATO.equals(configurazioneTracciamento.getDatabase().getFiltroEsiti()))
  10618.                     ) {
  10619.                 transazioniDB = esitiTransazioni!=null
  10620.                         && !(EsitiConfigUtils.TUTTI_ESITI_DISABILITATI+"").equals(esitiTransazioni);
  10621.             }  
  10622.            
  10623.             transazioniFiletrace = configurazioneTracciamento!=null && configurazioneTracciamento.getFiletrace()!=null && configurazioneTracciamento.getFiletrace().getStato()!=null &&
  10624.                     !org.openspcoop2.core.config.constants.StatoFunzionalitaConPersonalizzazione.DISABILITATO.equals(configurazioneTracciamento.getFiletrace().getStato());
  10625.             if(configurazioneTracciamento!=null && configurazioneTracciamento.getFiletrace()!=null && org.openspcoop2.core.config.constants.StatoFunzionalitaConPersonalizzazione.CONFIGURAZIONE_ESTERNA.equals(configurazioneTracciamento.getFiletrace().getStato())) {
  10626.                 transazioniFiletrace = (InitListener.getFileTraceGovWayState()!=null) ? InitListener.getFileTraceGovWayState().isEnabled() : transazioniFiletrace;
  10627.             }
  10628.             if(transazioniFiletrace && configurazioneTracciamento!=null && configurazioneTracciamento.getFiletrace()!=null && org.openspcoop2.core.config.constants.StatoFunzionalitaConPersonalizzazione.CONFIGURAZIONE_ESTERNA.equals(configurazioneTracciamento.getFiletrace().getStato())) {
  10629.                 transazioniFiletrace = CostantiProprieta.isFileTraceEnabled(proprietaPorta, transazioniFiletrace);
  10630.             }
  10631.             if(transazioniFiletrace &&
  10632.                     (configurazioneTracciamento!=null && configurazioneTracciamento.getFiletrace()!=null && configurazioneTracciamento.getFiletrace().getFiltroEsiti()!=null &&
  10633.                             org.openspcoop2.core.config.constants.StatoFunzionalita.ABILITATO.equals(configurazioneTracciamento.getFiletrace().getFiltroEsiti()))
  10634.                     ) {
  10635.                 transazioniFiletrace = esitiTransazioni!=null
  10636.                         && !(EsitiConfigUtils.TUTTI_ESITI_DISABILITATI+"").equals(esitiTransazioni);
  10637.             }  
  10638.         }
  10639.         StringBuilder sbTransazioni = new StringBuilder();
  10640.         if(
  10641.                 //transazioniDB se solo transazioni DB non aggiungo l'informazione
  10642.                 //||
  10643.                 transazioniFiletrace) {
  10644.             sbTransazioni.append(" [ ");
  10645.             if(transazioniDB) {
  10646.                 sbTransazioni.append("DB");
  10647.                 if(transazioniFiletrace) {
  10648.                     sbTransazioni.append(",");
  10649.                 }
  10650.             }
  10651.             if(transazioniFiletrace) {
  10652.                 sbTransazioni.append("FileTrace");
  10653.             }
  10654.             sbTransazioni.append(" ]");
  10655.         }
  10656.         String suffixTooltipTransazioni = sbTransazioni.length()>0 ? sbTransazioni.toString() : "";
  10657.         de.addStatus(tooltipTransazioni,
  10658.                 ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_TRANSAZIONI+suffixTooltipTransazioni,
  10659.                 transazioniDB || transazioniFiletrace? CheckboxStatusType.CONFIG_ENABLE :CheckboxStatusType.CONFIG_DISABLE);
  10660.        
  10661.        
  10662.         String tooltipSeverita = null;
  10663.         boolean tracciamentoSeverita = false;
  10664.         if(tracciamentoConfig!=null && tracciamentoConfig.getSeverita()!=null) {
  10665.             tooltipSeverita = CostantiControlStation.LABEL_CONFIGURAZIONE_RIDEFINITA+"\nLivello Severità: "+tracciamentoConfig.getSeverita().getValue();
  10666.             tracciamentoSeverita = (!LogLevels.LIVELLO_OFF.equals(tracciamentoConfig.getSeverita().getValue()));
  10667.         }
  10668.         else {
  10669.             tooltipSeverita = CostantiControlStation.LABEL_CONFIGURAZIONE_DEFAULT;
  10670.             if(configurazioneGenerale!=null && configurazioneGenerale.getMessaggiDiagnostici()!=null && configurazioneGenerale.getMessaggiDiagnostici().getSeverita()!=null) {
  10671.                 tooltipSeverita = tooltipSeverita+"\nLivello Severità: "+configurazioneGenerale.getMessaggiDiagnostici().getSeverita().getValue();
  10672.             }
  10673.             tracciamentoSeverita = (
  10674.                     configurazioneGenerale!=null && configurazioneGenerale.getMessaggiDiagnostici()!=null &&
  10675.                             configurazioneGenerale.getMessaggiDiagnostici().getSeverita()!=null
  10676.                     &&
  10677.                     !(LogLevels.LIVELLO_OFF.equals(configurazioneGenerale.getMessaggiDiagnostici().getSeverita().getValue()))
  10678.                     );
  10679.         }
  10680.         de.addStatus(tooltipSeverita,
  10681.                 ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_DIAGNOSTICI,
  10682.                 tracciamentoSeverita? CheckboxStatusType.CONFIG_ENABLE :CheckboxStatusType.CONFIG_DISABLE);
  10683.            
  10684.         boolean isCorrelazioneApplicativaAbilitataReq = false;
  10685.         if (correlazioneApplicativa != null)
  10686.             isCorrelazioneApplicativaAbilitataReq = correlazioneApplicativa.sizeElementoList() > 0;
  10687.         if(isCorrelazioneApplicativaAbilitataReq) {
  10688.             de.addStatus(correlazioneApplicativa.sizeElementoList() > 1 ? "Sono attive "+correlazioneApplicativa.sizeElementoList()+" regole" : null,
  10689.                     CostantiControlStation.LABEL_PARAMETRO_RICHIESTA+" [ "+CostantiControlStation.LABEL_PARAMETRO_CORRELAZIONE_APPLICATIVA+" ]",
  10690.                     CheckboxStatusType.CONFIG_ENABLE);
  10691.         }
  10692.            
  10693.         boolean isCorrelazioneApplicativaAbilitataRes = false;
  10694.         if (correlazioneApplicativaRisposta != null)
  10695.             isCorrelazioneApplicativaAbilitataRes = correlazioneApplicativaRisposta.sizeElementoList() > 0;
  10696.         if(isCorrelazioneApplicativaAbilitataRes) {
  10697.             de.addStatus(correlazioneApplicativaRisposta.sizeElementoList() > 1 ? "Sono attive "+correlazioneApplicativaRisposta.sizeElementoList()+" regole" : null,
  10698.                     CostantiControlStation.LABEL_PARAMETRO_RISPOSTA+" [ "+CostantiControlStation.LABEL_PARAMETRO_CORRELAZIONE_APPLICATIVA+" ]",
  10699.                     CheckboxStatusType.CONFIG_ENABLE);
  10700.         }
  10701.        
  10702.     }
  10703.    
  10704.     public void setStatoDump(DataElement de, DumpConfigurazione dumpConfigurazionePorta, Configurazione configurazioneGenerale, boolean portaApplicativa) {
  10705.         setStatoDump(de, dumpConfigurazionePorta, configurazioneGenerale, portaApplicativa, true);
  10706.     }
  10707.     public void setStatoDump(DataElement de, DumpConfigurazione dumpConfigurazionePorta, Configurazione configurazioneGenerale, boolean portaApplicativa, boolean upperFirstChar) {
  10708.        
  10709.         de.setType(DataElementType.MULTI_SELECT);
  10710.        
  10711.         DumpConfigurazione dumpConfigurazione = null;
  10712.        
  10713.         String tooltip = null;
  10714.         if(dumpConfigurazionePorta!=null) {
  10715.             tooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_RIDEFINITA;
  10716.             dumpConfigurazione = dumpConfigurazionePorta;
  10717.         }
  10718.         else {
  10719.             tooltip = CostantiControlStation.LABEL_CONFIGURAZIONE_DEFAULT;
  10720.             if(configurazioneGenerale!=null && configurazioneGenerale.getDump()!=null) {
  10721.                 if(portaApplicativa) {
  10722.                     dumpConfigurazione = configurazioneGenerale.getDump().getConfigurazionePortaApplicativa();
  10723.                 }
  10724.                 else {
  10725.                     dumpConfigurazione = configurazioneGenerale.getDump().getConfigurazionePortaDelegata();
  10726.                 }
  10727.             }
  10728.         }

  10729.         StringBuilder bfRichiesta = new StringBuilder();
  10730.         StringBuilder bfRichiestaOptions = new StringBuilder();
  10731.         StringBuilder bfRisposta = new StringBuilder();
  10732.         StringBuilder bfRispostaOptions = new StringBuilder();
  10733.        
  10734.         if(dumpConfigurazione!=null) {
  10735.                    
  10736.             if(dumpConfigurazione.getRichiestaIngresso()!=null) {
  10737.                 StringBuilder bf = new StringBuilder();
  10738.                 if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaIngresso().getHeaders())) {
  10739.                     if(bf.length()>0) {
  10740.                         bf.append(", ");
  10741.                     }
  10742.                     bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_HEADERS);
  10743.                 }
  10744.                 if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaIngresso().getPayload())) {
  10745.                     if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaIngresso().getPayloadParsing())) {
  10746.                         if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaIngresso().getBody())) {
  10747.                             if(bf.length()>0) {
  10748.                                 bf.append(", ");
  10749.                             }
  10750.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_BODY);
  10751.                         }
  10752.                         if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaIngresso().getAttachments())) {
  10753.                             if(bf.length()>0) {
  10754.                                 bf.append(", ");
  10755.                             }
  10756.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_ATTACHMENTS);
  10757.                         }      
  10758.                     }
  10759.                     else {
  10760.                         if(bf.length()>0) {
  10761.                             bf.append(", ");
  10762.                         }
  10763.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD);
  10764.                     }
  10765.                 }
  10766.                 if(bf.length()>0) {
  10767.                     if(bfRichiesta.length()>0) {
  10768.                         bfRichiesta.append("\n");
  10769.                     }
  10770.                     bfRichiesta.append(CostantiControlStation.LABEL_PARAMETRO_RICHIESTA+" "+CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO).append(": ").append(bf.toString());
  10771.                    
  10772.                     if(bfRichiestaOptions.length()>0) {
  10773.                         bfRichiestaOptions.append(", ");
  10774.                     }
  10775.                     bfRichiestaOptions.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO);
  10776.                 }
  10777.             }
  10778.            
  10779.             if(dumpConfigurazione.getRichiestaUscita()!=null) {
  10780.                 StringBuilder bf = new StringBuilder();
  10781.                 if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaUscita().getHeaders())) {
  10782.                     if(bf.length()>0) {
  10783.                         bf.append(", ");
  10784.                     }
  10785.                     bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_HEADERS);
  10786.                 }
  10787.                 if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaUscita().getPayload())) {
  10788.                     if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaUscita().getPayloadParsing())) {
  10789.                         if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaUscita().getBody())) {
  10790.                             if(bf.length()>0) {
  10791.                                 bf.append(", ");
  10792.                             }
  10793.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_BODY);
  10794.                         }
  10795.                         if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaUscita().getAttachments())) {
  10796.                             if(bf.length()>0) {
  10797.                                 bf.append(", ");
  10798.                             }
  10799.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_ATTACHMENTS);
  10800.                         }      
  10801.                     }
  10802.                     else {
  10803.                         if(bf.length()>0) {
  10804.                             bf.append(", ");
  10805.                         }
  10806.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD);
  10807.                     }
  10808.                 }
  10809.                 if(bf.length()>0) {
  10810.                     if(bfRichiesta.length()>0) {
  10811.                         bfRichiesta.append("\n");
  10812.                     }
  10813.                     bfRichiesta.append(CostantiControlStation.LABEL_PARAMETRO_RICHIESTA+" "+CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA).append(": ").append(bf.toString());
  10814.                    
  10815.                     if(bfRichiestaOptions.length()>0) {
  10816.                         bfRichiestaOptions.append(", ");
  10817.                     }
  10818.                     bfRichiestaOptions.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA);
  10819.                 }
  10820.             }
  10821.            
  10822.             if(dumpConfigurazione.getRispostaIngresso()!=null) {
  10823.                 StringBuilder bf = new StringBuilder();
  10824.                 if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaIngresso().getHeaders())) {
  10825.                     if(bf.length()>0) {
  10826.                         bf.append(", ");
  10827.                     }
  10828.                     bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_HEADERS);
  10829.                 }
  10830.                 if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaIngresso().getPayload())) {
  10831.                     if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaIngresso().getPayloadParsing())) {
  10832.                         if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaIngresso().getBody())) {
  10833.                             if(bf.length()>0) {
  10834.                                 bf.append(", ");
  10835.                             }
  10836.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_BODY);
  10837.                         }
  10838.                         if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaIngresso().getAttachments())) {
  10839.                             if(bf.length()>0) {
  10840.                                 bf.append(", ");
  10841.                             }
  10842.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_ATTACHMENTS);
  10843.                         }      
  10844.                     }
  10845.                     else {
  10846.                         if(bf.length()>0) {
  10847.                             bf.append(", ");
  10848.                         }
  10849.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD);
  10850.                     }
  10851.                 }
  10852.                 if(bf.length()>0) {
  10853.                     if(bfRisposta.length()>0) {
  10854.                         bfRisposta.append("\n");
  10855.                     }
  10856.                     bfRisposta.append(CostantiControlStation.LABEL_PARAMETRO_RISPOSTA+" "+CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO).append(": ").append(bf.toString());
  10857.                    
  10858.                     if(bfRispostaOptions.length()>0) {
  10859.                         bfRispostaOptions.append(", ");
  10860.                     }
  10861.                     bfRispostaOptions.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO);
  10862.                 }
  10863.             }
  10864.            
  10865.             if(dumpConfigurazione.getRispostaUscita()!=null) {
  10866.                 StringBuilder bf = new StringBuilder();
  10867.                 if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaUscita().getHeaders())) {
  10868.                     if(bf.length()>0) {
  10869.                         bf.append(", ");
  10870.                     }
  10871.                     bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_HEADERS);
  10872.                 }
  10873.                 if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaUscita().getPayload())) {
  10874.                     if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaUscita().getPayloadParsing())) {
  10875.                         if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaUscita().getBody())) {
  10876.                             if(bf.length()>0) {
  10877.                                 bf.append(", ");
  10878.                             }
  10879.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_BODY);
  10880.                         }
  10881.                         if(StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaUscita().getAttachments())) {
  10882.                             if(bf.length()>0) {
  10883.                                 bf.append(", ");
  10884.                             }
  10885.                             bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_ATTACHMENTS);
  10886.                         }      
  10887.                     }
  10888.                     else {
  10889.                         if(bf.length()>0) {
  10890.                             bf.append(", ");
  10891.                         }
  10892.                         bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD);
  10893.                     }
  10894.                 }
  10895.                 if(bf.length()>0) {
  10896.                     if(bfRisposta.length()>0) {
  10897.                         bfRisposta.append("\n");
  10898.                     }
  10899.                     bfRisposta.append(CostantiControlStation.LABEL_PARAMETRO_RISPOSTA+" "+CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA).append(": ").append(bf.toString());
  10900.                    
  10901.                     if(bfRispostaOptions.length()>0) {
  10902.                         bfRispostaOptions.append(", ");
  10903.                     }
  10904.                     bfRispostaOptions.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA);
  10905.                 }
  10906.             }
  10907.         }
  10908.        
  10909.         if(bfRichiesta.length()>0 || bfRisposta.length()>0) {
  10910.            
  10911.             if(bfRichiesta.length()>0) {
  10912.                 de.addStatus(tooltip+"\n"+bfRichiesta.toString(),
  10913.                         (upperFirstChar ? CostantiControlStation.LABEL_PARAMETRO_RICHIESTA : CostantiControlStation.LABEL_PARAMETRO_RICHIESTA.toLowerCase())+" [ "+bfRichiestaOptions.toString()+" ]",
  10914.                         CheckboxStatusType.CONFIG_ENABLE);
  10915.             }
  10916.            
  10917.             if(bfRisposta.length()>0) {
  10918.                 de.addStatus(tooltip+"\n"+bfRisposta.toString(),
  10919.                         (upperFirstChar ? CostantiControlStation.LABEL_PARAMETRO_RISPOSTA : CostantiControlStation.LABEL_PARAMETRO_RISPOSTA.toLowerCase())+" [ "+bfRispostaOptions.toString()+" ]",
  10920.                         CheckboxStatusType.CONFIG_ENABLE);
  10921.             }
  10922.            
  10923.         }
  10924.         else {
  10925.             de.addStatus(tooltip,
  10926.                     (upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO) : CostantiControlStation.DEFAULT_VALUE_DISABILITATO),
  10927.                     CheckboxStatusType.CONFIG_DISABLE);
  10928.         }
  10929.     }
  10930.    
  10931.     public void setStatoProprieta(DataElement de, int size) {
  10932.        
  10933.         de.setType(DataElementType.CHECKBOX);
  10934.        
  10935.         if(size>0) {
  10936.             de.setStatusType(CheckboxStatusType.CONFIG_ENABLE);
  10937.             de.setStatusValue(this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO));
  10938.             de.setStatusToolTip("Sono registrate "+size+" proprietà");
  10939.         }
  10940.         else {
  10941.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  10942.             de.setStatusValue(this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO));
  10943.         }
  10944.        
  10945.     }
  10946.    
  10947.     public void setStatoOpzioniAvanzate(DataElement de,
  10948.             String protocollo, ServiceBinding serviceBinding,
  10949.             StatoFunzionalita allegaBody, StatoFunzionalita scartaBody,
  10950.             String integrazione, String behaviour,
  10951.             List<Proprieta> proprietaRateLimiting,
  10952.             StatoFunzionalita stateless, PortaDelegataLocalForward localForward,
  10953.             StatoFunzionalita ricevutaAsincronaSimmetrica, StatoFunzionalita ricevutaAsincronaAsimmetrica,
  10954.             StatoFunzionalita gestioneManifest, ConfigurazionePortaHandler configPortaHandler) throws DriverRegistroServiziNotFound, DriverRegistroServiziException, DriverConfigurazioneException {
  10955.         setStatoOpzioniAvanzate(de,
  10956.                 protocollo, serviceBinding,
  10957.                 allegaBody, scartaBody,
  10958.                 integrazione, behaviour,
  10959.                 proprietaRateLimiting,
  10960.                 stateless, localForward,
  10961.                 ricevutaAsincronaSimmetrica, ricevutaAsincronaAsimmetrica,
  10962.                 gestioneManifest, configPortaHandler, true);
  10963.     }
  10964.     public void setStatoOpzioniAvanzate(DataElement de,
  10965.             String protocollo, ServiceBinding serviceBinding,
  10966.             StatoFunzionalita allegaBody, StatoFunzionalita scartaBody,
  10967.             String integrazione, String behaviour,
  10968.             List<Proprieta> proprietaRateLimiting,
  10969.             StatoFunzionalita stateless, PortaDelegataLocalForward localForward,
  10970.             StatoFunzionalita ricevutaAsincronaSimmetrica, StatoFunzionalita ricevutaAsincronaAsimmetrica,
  10971.             StatoFunzionalita gestioneManifest, ConfigurazionePortaHandler configPortaHandler, boolean upperFirstChar) throws DriverRegistroServiziNotFound, DriverRegistroServiziException, DriverConfigurazioneException {
  10972.        
  10973.         boolean supportoAsincroni = this.core.isProfiloDiCollaborazioneAsincronoSupportatoDalProtocollo(protocollo,serviceBinding);
  10974.         boolean supportoGestioneManifest = isFunzionalitaProtocolloSupportataDalProtocollo(protocollo, serviceBinding, FunzionalitaProtocollo.MANIFEST_ATTACHMENTS);
  10975.        
  10976.         de.setType(DataElementType.CHECKBOX);
  10977.        
  10978.         StringBuilder bf = new StringBuilder();
  10979.         StringBuilder bfTooltips = new StringBuilder();
  10980.         if(allegaBody!=null && StatoFunzionalita.ABILITATO.equals(allegaBody)) {
  10981.             if(bf.length()>0) {
  10982.                 bf.append(", ");
  10983.             }
  10984.             bf.append("Allega SOAPBody");
  10985.             if(bfTooltips.length()>0) {
  10986.                 bfTooltips.append("\n");
  10987.             }
  10988.             bfTooltips.append("Allega SOAP Body come Attachment");
  10989.         }
  10990.         if(scartaBody!=null && StatoFunzionalita.ABILITATO.equals(scartaBody)) {
  10991.             if(bf.length()>0) {
  10992.                 bf.append(", ");
  10993.             }
  10994.             bf.append("Scarta SOAPBody");
  10995.             if(bfTooltips.length()>0) {
  10996.                 bfTooltips.append("\n");
  10997.             }
  10998.             bfTooltips.append("Scarta SOAP Body");
  10999.         }
  11000.         if(integrazione!=null && !"".equals(integrazione)) {
  11001.             String [] tmp = integrazione.split(",");
  11002.             if(bf.length()>0) {
  11003.                 bf.append(", ");
  11004.             }
  11005.             bf.append(CostantiControlStation.LABEL_METADATI_INTEGRAZIONE);
  11006.             if(tmp.length>1) {
  11007.                 bf.append(" (").append(tmp.length).append(")");
  11008.             }
  11009.             if(bfTooltips.length()>0) {
  11010.                 bfTooltips.append("\n");
  11011.             }
  11012.            
  11013.             List<String> listGruppi = new ArrayList<>();
  11014.             List<String> listPlugins = new ArrayList<>();
  11015.             if(tmp.length>0) {
  11016.                 for (String tmpIntegrazione : tmp) {
  11017.                     if(tmpIntegrazione!=null) {
  11018.                         tmpIntegrazione = tmpIntegrazione.trim();
  11019.                         TipoIntegrazione tipo = TipoIntegrazione.toEnumConstant(tmpIntegrazione);
  11020.                         if(tipo!=null) {
  11021.                             String label = null;
  11022.                             if(tipo.getGroup()!=null) {
  11023.                                 label = tipo.getGroup().getCompactLabel();
  11024.                             }
  11025.                             else {
  11026.                                 label = tipo.getLabel();
  11027.                             }
  11028.                             if(!listGruppi.contains(label)) {
  11029.                                 listGruppi.add(label);
  11030.                             }
  11031.                         }
  11032.                         else {
  11033.                             listPlugins.add(tmpIntegrazione);
  11034.                             String label = GruppoIntegrazione.PLUGIN.getCompactLabel();
  11035.                             if(!listGruppi.contains(label)) {
  11036.                                 listGruppi.add(label);
  11037.                             }
  11038.                         }
  11039.                     }
  11040.                     else {
  11041.                         listPlugins.add(tmpIntegrazione);
  11042.                         String label = GruppoIntegrazione.PLUGIN.getCompactLabel();
  11043.                         if(!listGruppi.contains(label)) {
  11044.                             listGruppi.add(label);
  11045.                         }
  11046.                     }
  11047.                 }
  11048.             }
  11049.             StringBuilder integrazioneString = new StringBuilder("");
  11050.             if(!listGruppi.isEmpty()) {
  11051.                 for (String gruppo : listGruppi) {
  11052.                     if(integrazioneString.length()>0) {
  11053.                         integrazioneString.append(", ");
  11054.                     }
  11055.                     integrazioneString.append(gruppo);
  11056.                     if(GruppoIntegrazione.PLUGIN.getCompactLabel().equals(gruppo)) {
  11057.                         if(!listPlugins.isEmpty()) {
  11058.                             integrazioneString.append(" (");
  11059.                             for (int i = 0; i < listPlugins.size(); i++) {
  11060.                                 String plug = listPlugins.get(i);
  11061.                                 if(i>0) {
  11062.                                     integrazioneString.append(",");
  11063.                                 }
  11064.                                 integrazioneString.append(plug);
  11065.                             }
  11066.                             integrazioneString.append(")");
  11067.                         }
  11068.                     }
  11069.                 }
  11070.             }
  11071.            
  11072.             bfTooltips.append(CostantiControlStation.LABEL_METADATI_INTEGRAZIONE).append(": ").append(integrazioneString.toString());
  11073.         }
  11074.         if(proprietaRateLimiting!=null && !proprietaRateLimiting.isEmpty()) {
  11075.             try {
  11076.                 PolicyConfiguration config = new PolicyConfiguration(proprietaRateLimiting, this.core.getControlloTrafficoPolicyRateLimitingTipiGestori(), false);
  11077.                 if(!org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_SINCRONIZZAZIONE_DEFAULT.equals(config.getSyncMode()) || !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_DEFAULT.equals(config.getHttpMode())) {
  11078.                    
  11079.                     if(bf.length()>0) {
  11080.                         bf.append(", ");
  11081.                     }
  11082.                     bf.append(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING);
  11083.                    
  11084.                     if(bfTooltips.length()>0) {
  11085.                         bfTooltips.append("\n");
  11086.                     }
  11087.                     bfTooltips.append(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING).append(": ");
  11088.                     if(!org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_SINCRONIZZAZIONE_DEFAULT.equals(config.getSyncMode())){
  11089.                         bfTooltips.append(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_SINCRONIZZAZIONE).append(" ");
  11090.                         if(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_SINCRONIZZAZIONE_LOCALE.equals(config.getSyncMode())){
  11091.                             bfTooltips.append(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_SINCRONIZZAZIONE_LOCALE);
  11092.                         }
  11093.                         else if(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_SINCRONIZZAZIONE_LOCALE_SUDDIVISA_TRA_NODI.equals(config.getSyncMode())){
  11094.                             bfTooltips.append(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_SINCRONIZZAZIONE_LOCALE_SUDDIVISA_TRA_NODI);
  11095.                         }
  11096.                         else if(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_SINCRONIZZAZIONE_DISTRIBUITA.equals(config.getSyncMode())){
  11097.                             if(config.getType()!=null) {
  11098.                                 bfTooltips.append(config.getType().toLabel());
  11099.                             }
  11100.                             else {
  11101.                                 bfTooltips.append(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_SINCRONIZZAZIONE_DISTRIBUITA);
  11102.                             }
  11103.                         }
  11104.                        
  11105.                         if(!org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_DEFAULT.equals(config.getHttpMode())){
  11106.                             bfTooltips.append(", ");
  11107.                         }
  11108.                     }
  11109.                     if(!org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_DEFAULT.equals(config.getHttpMode())){
  11110.                         bfTooltips.append(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_GENERAZIONE_HEADER_HTTP);
  11111.                         if(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_DISABILITATO.equals(config.getHttpMode())){
  11112.                             bfTooltips.append(" ").append("disabilitati");
  11113.                         }
  11114.                         else if(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_RIDEFINITO.equals(config.getHttpMode())){
  11115.                             bfTooltips.append(" ").append("gestione personalizzata");
  11116.                         }
  11117.                     }
  11118.                    
  11119.                 }
  11120.             }catch(Exception e) {
  11121.                 throw new DriverConfigurazioneException(e.getMessage(),e);
  11122.             }
  11123.         }
  11124.         if(behaviour!=null && !"".equals(behaviour)) {
  11125.             String [] tmp = behaviour.split(",");
  11126.             if(bf.length()>0) {
  11127.                 bf.append(", ");
  11128.             }
  11129.             bf.append(CostantiControlStation.LABEL_BEHAVIOUR);
  11130.             if(tmp.length>1) {
  11131.                 bf.append(" (").append(tmp.length).append(")");
  11132.             }
  11133.             if(bfTooltips.length()>0) {
  11134.                 bfTooltips.append("\n");
  11135.             }
  11136.             bfTooltips.append(CostantiControlStation.LABEL_BEHAVIOUR).append(": ").append(behaviour);
  11137.         }
  11138.         if(stateless!=null) {
  11139.             if(bf.length()>0) {
  11140.                 bf.append(", ");
  11141.             }
  11142.             if(bfTooltips.length()>0) {
  11143.                 bfTooltips.append("\n");
  11144.             }
  11145.             if(StatoFunzionalita.ABILITATO.equals(stateless)) {
  11146.                 bf.append(CostantiControlStation.LABEL_GESTIONE_STATELESS);
  11147.                 bfTooltips.append(CostantiControlStation.LABEL_GESTIONE_STATELESS);
  11148.             }
  11149.             else {
  11150.                 bf.append(CostantiControlStation.LABEL_GESTIONE_STATEFUL);
  11151.                 bfTooltips.append(CostantiControlStation.LABEL_GESTIONE_STATEFUL);
  11152.             }
  11153.         }
  11154.         if(localForward!=null && StatoFunzionalita.ABILITATO.equals(localForward.getStato())) {
  11155.             if(bf.length()>0) {
  11156.                 bf.append(", ");
  11157.             }
  11158.             bf.append(CostantiControlStation.LABEL_LOCAL_FORWARD);
  11159.             if(bfTooltips.length()>0) {
  11160.                 bfTooltips.append("\n");
  11161.             }
  11162.             bfTooltips.append(CostantiControlStation.LABEL_LOCAL_FORWARD);
  11163.             if(localForward.getPortaApplicativa()!=null) {
  11164.                 bfTooltips.append(", ").append(CostantiControlStation.LABEL_LOCAL_FORWARD_PA).append(": ").append(localForward.getPortaApplicativa());
  11165.             }
  11166.         }
  11167.         if(supportoAsincroni) {
  11168.             if(ricevutaAsincronaSimmetrica!=null && StatoFunzionalita.ABILITATO.equals(ricevutaAsincronaSimmetrica)) {
  11169.                 if(bf.length()>0) {
  11170.                     bf.append(", ");
  11171.                 }
  11172.                 bf.append(CostantiControlStation.LABEL_RICEVUTA_ASINCRONA_SIMMETRICA);
  11173.                 if(bfTooltips.length()>0) {
  11174.                     bfTooltips.append("\n");
  11175.                 }
  11176.                 bfTooltips.append(CostantiControlStation.LABEL_RICEVUTA_ASINCRONA_SIMMETRICA);
  11177.             }
  11178.             if(ricevutaAsincronaAsimmetrica!=null && StatoFunzionalita.ABILITATO.equals(ricevutaAsincronaAsimmetrica)) {
  11179.                 if(bf.length()>0) {
  11180.                     bf.append(", ");
  11181.                 }
  11182.                 bf.append(CostantiControlStation.LABEL_RICEVUTA_ASINCRONA_ASIMMETRICA);
  11183.                 if(bfTooltips.length()>0) {
  11184.                     bfTooltips.append("\n");
  11185.                 }
  11186.                 bfTooltips.append(CostantiControlStation.LABEL_RICEVUTA_ASINCRONA_ASIMMETRICA);
  11187.             }
  11188.         }
  11189.         if(supportoGestioneManifest) {
  11190.             if(gestioneManifest!=null && StatoFunzionalita.ABILITATO.equals(gestioneManifest)) {
  11191.                 if(bf.length()>0) {
  11192.                     bf.append(", ");
  11193.                 }
  11194.                 bf.append(CostantiControlStation.LABEL_GESTIONE_MANIFEST);
  11195.                 if(bfTooltips.length()>0) {
  11196.                     bfTooltips.append("\n");
  11197.                 }
  11198.                 bfTooltips.append(CostantiControlStation.LABEL_GESTIONE_MANIFEST);
  11199.             }
  11200.         }
  11201.         if(configPortaHandler!=null) {
  11202.             StringBuilder sbRequest = new StringBuilder();
  11203.             if(configPortaHandler.getRequest()!=null) {
  11204.                 if(configPortaHandler.getRequest().sizePreInList()>0) {
  11205.                     if(sbRequest.length()>0) {
  11206.                         sbRequest.append(", ");
  11207.                     }
  11208.                     sbRequest.append(PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_PRE_IN_SHORT).append(" (").append(configPortaHandler.getRequest().sizePreInList()).append(")");
  11209.                 }
  11210.                 if(configPortaHandler.getRequest().sizeInList()>0) {
  11211.                     if(sbRequest.length()>0) {
  11212.                         sbRequest.append(", ");
  11213.                     }
  11214.                     sbRequest.append(PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_IN_SHORT).append(" (").append(configPortaHandler.getRequest().sizeInList()).append(")");
  11215.                 }
  11216.                 if(configPortaHandler.getRequest().sizeInProtocolInfoList()>0) {
  11217.                     if(sbRequest.length()>0) {
  11218.                         sbRequest.append(", ");
  11219.                     }
  11220.                     sbRequest.append(PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_IN_PROTOCOL_INFO_SHORT).append(" (").append(configPortaHandler.getRequest().sizeInProtocolInfoList()).append(")");
  11221.                 }
  11222.                 if(configPortaHandler.getRequest().sizeOutList()>0) {
  11223.                     if(sbRequest.length()>0) {
  11224.                         sbRequest.append(", ");
  11225.                     }
  11226.                     sbRequest.append(PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_OUT_SHORT).append(" (").append(configPortaHandler.getRequest().sizeOutList()).append(")");
  11227.                 }  
  11228.                 if(configPortaHandler.getRequest().sizePostOutList()>0) {
  11229.                     if(sbRequest.length()>0) {
  11230.                         sbRequest.append(", ");
  11231.                     }
  11232.                     sbRequest.append(PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_POST_OUT_SHORT).append(" (").append(configPortaHandler.getRequest().sizePostOutList()).append(")");
  11233.                 }  
  11234.             }
  11235.             StringBuilder sbResponse = new StringBuilder();
  11236.             if(configPortaHandler.getResponse()!=null) {
  11237.                 if(configPortaHandler.getResponse().sizePreInList()>0) {
  11238.                     if(sbResponse.length()>0) {
  11239.                         sbResponse.append(", ");
  11240.                     }
  11241.                     sbResponse.append(PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_PRE_IN_SHORT).append(" (").append(configPortaHandler.getResponse().sizePreInList()).append(")");
  11242.                 }
  11243.                 if(configPortaHandler.getResponse().sizeInList()>0) {
  11244.                     if(sbResponse.length()>0) {
  11245.                         sbResponse.append(", ");
  11246.                     }
  11247.                     sbResponse.append(PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_IN_SHORT).append(" (").append(configPortaHandler.getResponse().sizeInList()).append(")");
  11248.                 }
  11249.                 if(configPortaHandler.getResponse().sizeInProtocolInfoList()>0) {
  11250.                     if(sbResponse.length()>0) {
  11251.                         sbResponse.append(", ");
  11252.                     }
  11253.                     sbResponse.append(PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_IN_PROTOCOL_INFO_SHORT).append(" (").append(configPortaHandler.getResponse().sizeInProtocolInfoList()).append(")");
  11254.                 }
  11255.                 if(configPortaHandler.getResponse().sizeOutList()>0) {
  11256.                     if(sbResponse.length()>0) {
  11257.                         sbResponse.append(", ");
  11258.                     }
  11259.                     sbResponse.append(PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_OUT_SHORT).append(" (").append(configPortaHandler.getResponse().sizeOutList()).append(")");
  11260.                 }  
  11261.                 if(configPortaHandler.getResponse().sizePostOutList()>0) {
  11262.                     if(sbResponse.length()>0) {
  11263.                         sbResponse.append(", ");
  11264.                     }
  11265.                     sbResponse.append(PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_POST_OUT_SHORT).append(" (").append(configPortaHandler.getResponse().sizePostOutList()).append(")");
  11266.                 }  
  11267.             }
  11268.             if(sbRequest.length()>0 || sbResponse.length()>0) {
  11269.                 if(bf.length()>0) {
  11270.                     bf.append(", ");
  11271.                 }
  11272.                 bf.append(CostantiControlStation.LABEL_MESSAGE_HANDLER);
  11273.                 if(sbRequest.length()>0) {
  11274.                     if(bfTooltips.length()>0) {
  11275.                         bfTooltips.append("\n");
  11276.                     }
  11277.                     bfTooltips.append(CostantiControlStation.LABEL_REQUEST_MESSAGE_HANDLER).append(": ").append(sbRequest.toString());
  11278.                 }
  11279.                 if(sbResponse.length()>0) {
  11280.                     if(bfTooltips.length()>0) {
  11281.                         bfTooltips.append("\n");
  11282.                     }
  11283.                     bfTooltips.append(CostantiControlStation.LABEL_RESPONSE_MESSAGE_HANDLER).append(": ").append(sbResponse.toString());
  11284.                 }
  11285.             }
  11286.         }
  11287.        
  11288.         if(bf.length()>0) {
  11289.             de.setStatusType(CheckboxStatusType.CONFIG_ENABLE);
  11290.             String vAbilitato = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO) : CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  11291.             de.setStatusValue(vAbilitato+" [ "+bf.toString()+" ]");
  11292.             de.setStatusToolTip(bfTooltips.toString());
  11293.         }
  11294.         else {
  11295.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  11296.             String vDisabilitato = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO) : CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  11297.             de.setStatusValue(vDisabilitato);
  11298.         }
  11299.        
  11300.     }
  11301.    
  11302.     public void setStatoExtendedList(DataElement de, int size, String stato, String statoTooltip) {
  11303.         setStatoExtendedList(de, size, stato, statoTooltip, true);
  11304.     }
  11305.     public void setStatoExtendedList(DataElement de, int size, String stato, String statoTooltip, boolean upperFirstChar) {
  11306.        
  11307.         de.setType(DataElementType.CHECKBOX);
  11308.        
  11309.         if(size>0) {
  11310.             de.setStatusType(CheckboxStatusType.CONFIG_ENABLE);
  11311.             String vAbilitato = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO) : CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  11312.             if(stato!=null) {
  11313.                 de.setStatusValue(vAbilitato+" [" +stato+ " ]");
  11314.             }
  11315.             else {
  11316.                 de.setStatusValue(vAbilitato);
  11317.             }
  11318.             if(statoTooltip!=null) {
  11319.                 de.setStatusToolTip(statoTooltip);
  11320.             }
  11321.             else {
  11322.                 de.setStatusToolTip("Sono registrate "+size+" proprietà");
  11323.             }
  11324.         }
  11325.         else {
  11326.             de.setStatusType(CheckboxStatusType.CONFIG_DISABLE);
  11327.             String vDisabilitato = upperFirstChar ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO) : CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  11328.             de.setStatusValue(vDisabilitato);
  11329.         }
  11330.        
  11331.     }
  11332.    
  11333.     public String getLabelStatoGestioneToken(String gestioneToken) {
  11334.         String label = CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  11335.        
  11336.         if(gestioneToken!=null && StatoFunzionalita.ABILITATO.getValue().equals(gestioneToken)) {
  11337.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  11338.         }
  11339.         return label;
  11340.     }
  11341.    
  11342.     public String getLabelStatoAutenticazione(String autenticazione, String autenticazioneOpzionale, String autenticazioneCustom) {
  11343.         String label = CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  11344.        
  11345.         if(autenticazione != null && !TipoAutenticazione.DISABILITATO.equals(autenticazione))
  11346.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  11347.        
  11348.         if(autenticazioneOpzionale != null && ServletUtils.isCheckBoxEnabled(autenticazioneOpzionale))
  11349.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  11350.        
  11351.         return label;
  11352.     }
  11353.    
  11354.     public String getLabelStatoAutorizzazione(String autorizzazione, String autorizzazioneContenuti,String autorizzazioneCustom) {
  11355.         String label = CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  11356.        
  11357.         if(!AutorizzazioneUtilities.STATO_DISABILITATO.equals(autorizzazione))
  11358.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  11359.        
  11360.         if(StringUtils.isNotEmpty(autorizzazioneContenuti))
  11361.             return CostantiControlStation.DEFAULT_VALUE_ABILITATO;
  11362.        
  11363.         return label;
  11364.     }
  11365.    
  11366.    
  11367.     public DataElement getServiceBindingDataElement(ServiceBinding serviceBinding) throws DriverControlStationException{
  11368.         return getServiceBindingDataElement(null, false, serviceBinding, true);
  11369.     }
  11370.    
  11371.     public DataElement getServiceBindingDataElement(IProtocolFactory<?> protocolFactory, boolean used, ServiceBinding serviceBinding) throws DriverControlStationException{
  11372.         return getServiceBindingDataElement(protocolFactory, used, serviceBinding, false);
  11373.     }
  11374.    
  11375.     public DataElement getServiceBindingDataElement(IProtocolFactory<?> protocolFactory, boolean used, ServiceBinding serviceBinding, boolean forceHidden) throws DriverControlStationException{
  11376.         DataElement de = null;
  11377.         if(!forceHidden) {
  11378.             try {
  11379.                 List<ServiceBinding> serviceBindingList = this.core.getServiceBindingList(protocolFactory);
  11380.                
  11381.                 de = new DataElement();
  11382.                 de.setName(CostantiControlStation.PARAMETRO_SERVICE_BINDING);
  11383.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING);
  11384.                
  11385.                 if(serviceBindingList != null && serviceBindingList.size() > 1){
  11386.                     if(used){
  11387.                         de.setType(DataElementType.TEXT);
  11388.                         de.setValue(serviceBinding.toString());
  11389.                     }else {
  11390.                         de.setSelected(serviceBinding.toString());
  11391.                         de.setType(DataElementType.SELECT);
  11392.                         de.setPostBack(true);
  11393.    
  11394.                         String [] values = new String[serviceBindingList.size()];
  11395.                         String [] labels = new String[serviceBindingList.size()];
  11396.                         for (int i =0; i < serviceBindingList.size() ; i ++) {
  11397.                             ServiceBinding serviceBinding2 = serviceBindingList.get(i);
  11398.                             switch (serviceBinding2) {
  11399.                             case REST:
  11400.                                 labels[i] = CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_REST;
  11401.                                 values[i] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_REST;
  11402.                                 break;
  11403.                             case SOAP:
  11404.                             default:
  11405.                                 labels[i] = CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_SOAP;
  11406.                                 values[i] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_SOAP;
  11407.                                 break;
  11408.                             }
  11409.                         }
  11410.                        
  11411.                         de.setValues(values);
  11412.                         de.setLabels(labels);
  11413.                     }
  11414.                 } else {
  11415.                     de.setValue(serviceBinding.toString());
  11416.                     de.setType(DataElementType.HIDDEN);
  11417.                 }
  11418.                 de.setSize(this.getSize());
  11419.             } catch (Exception e) {
  11420.                 this.logError("Exception: " + e.getMessage(), e);
  11421.                 throw new DriverControlStationException(e);
  11422.             }
  11423.         } else {
  11424.             de = new DataElement();
  11425.             de.setName(CostantiControlStation.PARAMETRO_SERVICE_BINDING);
  11426.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING);
  11427.             de.setValue(serviceBinding !=null ? serviceBinding.toString() : null);
  11428.             de.setType(DataElementType.HIDDEN);
  11429.         }
  11430.         return de;
  11431.     }
  11432.     public DataElement getMessageTypeDataElement(String parametroMessageType, IProtocolFactory<?> protocolFactory, ServiceBinding serviceBinding,MessageType value) throws DriverControlStationException{
  11433.         return this.getMessageTypeDataElement(parametroMessageType, protocolFactory, serviceBinding, value, this.isModalitaStandard()); // per defaut viene visualizzato solo se siamo in interfaccia avanzata
  11434.     }
  11435.    
  11436.     public DataElement getMessageTypeDataElement(String parametroMessageType, IProtocolFactory<?> protocolFactory, ServiceBinding serviceBinding,MessageType value, boolean hidden) throws DriverControlStationException{
  11437.         DataElement de = null;
  11438.         try {
  11439.             List<MessageType> messageTypeList = this.core.getMessageTypeList(protocolFactory, serviceBinding);
  11440.            
  11441.             de = new DataElement();
  11442.             de.setName(parametroMessageType);
  11443.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_MESSAGE_TYPE);
  11444.            
  11445.             if(!hidden && messageTypeList != null && messageTypeList.size() > 1){
  11446.                     de.setSelected(value != null ? value.toString() : null);
  11447.                     de.setType(DataElementType.SELECT);
  11448.                     //de.setPostBack(true);

  11449.                     String [] values = new String[messageTypeList.size()+ 1];
  11450.                     String [] labels = new String[messageTypeList.size()+ 1];
  11451.                     labels[0] = CostantiControlStation.LABEL_PARAMETRO_MESSAGE_TYPE_DEFAULT;
  11452.                     values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_TYPE_DEFAULT;
  11453.                     for (int i = 1 ; i <= messageTypeList.size() ; i ++) {
  11454.                         MessageType type = messageTypeList.get(i-1);
  11455.                         switch (type) {
  11456.                         case BINARY:
  11457.                             labels[i] = CostantiControlStation.LABEL_PARAMETRO_MESSAGE_TYPE_BINARY;
  11458.                             values[i] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_TYPE_BINARY;
  11459.                             break;
  11460.                         case JSON:
  11461.                             labels[i] = CostantiControlStation.LABEL_PARAMETRO_MESSAGE_TYPE_JSON;
  11462.                             values[i] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_TYPE_JSON;
  11463.                             break;
  11464.                         case MIME_MULTIPART:
  11465.                             labels[i] = CostantiControlStation.LABEL_PARAMETRO_MESSAGE_TYPE_MIME_MULTIPART;
  11466.                             values[i] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_TYPE_MIME_MULTIPART;
  11467.                             break;
  11468.                         case SOAP_11:
  11469.                             labels[i] = CostantiControlStation.LABEL_PARAMETRO_MESSAGE_TYPE_SOAP_11;
  11470.                             values[i] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_TYPE_SOAP_11;
  11471.                             break;
  11472.                         case SOAP_12:
  11473.                             labels[i] = CostantiControlStation.LABEL_PARAMETRO_MESSAGE_TYPE_SOAP_12;
  11474.                             values[i] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_TYPE_SOAP_12;
  11475.                             break;
  11476.                         case XML:
  11477.                         default:
  11478.                             labels[i] = CostantiControlStation.LABEL_PARAMETRO_MESSAGE_TYPE_XML;
  11479.                             values[i] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_TYPE_XML;
  11480.                             break;
  11481.                         }
  11482.                     }
  11483.                    
  11484.                     de.setValues(values);
  11485.                     de.setLabels(labels);
  11486.             } else {
  11487.                 de.setValue(value != null ? value.toString() : null);
  11488.                 de.setType(DataElementType.HIDDEN);
  11489.             }
  11490.             de.setSize(this.getSize());
  11491.         } catch (Exception e) {
  11492.             this.logError("Exception: " + e.getMessage(), e);
  11493.             throw new DriverControlStationException(e);
  11494.         }
  11495.         return de;
  11496.     }
  11497.    
  11498.     public DataElement getInterfaceTypeDataElement(TipoOperazione tipoOperazione, IProtocolFactory<?> protocolFactory, ServiceBinding serviceBinding,org.openspcoop2.protocol.manifest.constants.InterfaceType value) throws DriverControlStationException{
  11499.         DataElement de = null;
  11500.         try {
  11501.             List<org.openspcoop2.protocol.manifest.constants.InterfaceType> interfaceTypeList = this.core.getInterfaceTypeList(protocolFactory, serviceBinding);
  11502.            
  11503.             de = new DataElement();
  11504.             de.setName(CostantiControlStation.PARAMETRO_INTERFACE_TYPE);
  11505.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE);
  11506.            
  11507.             switch (tipoOperazione) {
  11508.             case ADD:
  11509.                 if(interfaceTypeList != null && interfaceTypeList.size() > 1){
  11510.                     de.setSelected(value != null ? value.toString() : null);
  11511.                     de.setType(DataElementType.SELECT);
  11512.                     de.setPostBack(true);

  11513.                     String [] values = new String[interfaceTypeList.size()];
  11514.                     String [] labels = new String[interfaceTypeList.size()];
  11515.                     for (int i =0; i < interfaceTypeList.size() ; i ++) {
  11516.                         org.openspcoop2.protocol.manifest.constants.InterfaceType type = interfaceTypeList.get(i);
  11517.                         switch (type) {
  11518.                         case OPEN_API_3:
  11519.                             labels[i] = CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_OPEN_API_3;
  11520.                             values[i] = CostantiControlStation.VALUE_PARAMETRO_INTERFACE_TYPE_OPEN_API_3;
  11521.                             break;
  11522.                         case SWAGGER_2:
  11523.                             labels[i] = CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_SWAGGER_2;
  11524.                             values[i] = CostantiControlStation.VALUE_PARAMETRO_INTERFACE_TYPE_SWAGGER_2;
  11525.                             break;
  11526.                         case WADL:
  11527.                             labels[i] = CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_WADL;
  11528.                             values[i] = CostantiControlStation.VALUE_PARAMETRO_INTERFACE_TYPE_WADL;
  11529.                             break;
  11530.                         case WSDL_11:
  11531.                         default:
  11532.                             labels[i] = CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_WSDL_11;
  11533.                             values[i] = CostantiControlStation.VALUE_PARAMETRO_INTERFACE_TYPE_WSDL_11;
  11534.                             break;
  11535.                         }
  11536.                     }
  11537.                    
  11538.                     de.setValues(values);
  11539.                     de.setLabels(labels);
  11540.             } else {
  11541.                 de.setValue(value != null ? value.toString() : null);
  11542.                 de.setType(DataElementType.HIDDEN);
  11543.             }
  11544.                 break;
  11545.             case CHANGE:
  11546.             case DEL:
  11547.             case LIST:
  11548.             case LOGIN:
  11549.             case LOGOUT:
  11550.             case OTHER:
  11551.             default:
  11552.                 de.setValue(value != null ? value.toString() : null);
  11553.                 de.setType(DataElementType.HIDDEN);
  11554.                 break;
  11555.             }
  11556.            
  11557.             de.setSize(this.getSize());
  11558.         } catch (Exception e) {
  11559.             this.logError("Exception: " + e.getMessage(), e);
  11560.             throw new DriverControlStationException(e);
  11561.         }
  11562.         return de;
  11563.     }
  11564.    
  11565.     public boolean porteAppAzioneCheckData(TipoOperazione add, List<String> azioniOccupate, List<MappingErogazionePortaApplicativa> list) throws DriverControlStationException {
  11566.         String[] azionis = this.getParameterValues(CostantiControlStation.PARAMETRO_AZIONI);
  11567.        
  11568.         if(azionis == null || azionis.length == 0) {
  11569.             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_PORTA_NON_PUO_ESSERE_VUOTA);
  11570.             return false;
  11571.         }
  11572.        
  11573.         for (String azione : azionis) {
  11574.             if(azioniOccupate.contains(azione)) {
  11575.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_PORTA_GIA_PRESENTE);
  11576.                 return false;          
  11577.             }
  11578.         }
  11579.        
  11580.         if(checkAzioniUtilizzateErogazione(list, azionis)==false) {
  11581.             return false;
  11582.         }
  11583.        
  11584.         return true;
  11585.     }
  11586.    
  11587.     public boolean porteDelAzioneCheckData(TipoOperazione add, List<String> azioniOccupate, List<MappingFruizionePortaDelegata> list) throws DriverControlStationException {
  11588.         String[] azionis = this.getParameterValues(CostantiControlStation.PARAMETRO_AZIONI);
  11589.        
  11590.         if(azionis == null || azionis.length == 0) {
  11591.             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_PORTA_NON_PUO_ESSERE_VUOTA);
  11592.             return false;
  11593.         }
  11594.        
  11595.         for (String azione : azionis) {
  11596.             if(azioniOccupate.contains(azione)) {
  11597.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_PORTA_GIA_PRESENTE);
  11598.                 return false;          
  11599.             }
  11600.         }
  11601.        
  11602.         if(checkAzioniUtilizzateFruizione(list, azionis)==false) {
  11603.             return false;
  11604.         }
  11605.        
  11606.         return true;
  11607.     }

  11608.     public String getMessaggioConfermaModificaRegolaMapping(boolean fromAPI, boolean isDefault,List<String> listaAzioni,ServiceBinding serviceBinding, String gruppo,
  11609.             boolean abilitazione, boolean multiline,boolean listElement) throws DriverConfigurazioneException {
  11610.         String pre = Costanti.HTML_MODAL_SPAN_PREFIX;
  11611.         String post = Costanti.HTML_MODAL_SPAN_SUFFIX;
  11612.        
  11613.         if(fromAPI) {
  11614.             return pre + ( abilitazione ? CostantiControlStation.MESSAGGIO_CONFERMA_ABILITAZIONE_FROM_API : CostantiControlStation.MESSAGGIO_CONFERMA_DISABILITAZIONE_FROM_API)  + post;
  11615.         }
  11616.         else {
  11617.             return pre + ( abilitazione ? MessageFormat.format(CostantiControlStation.MESSAGGIO_CONFERMA_ABILITAZIONE_GRUPPO,gruppo) : MessageFormat.format(CostantiControlStation.MESSAGGIO_CONFERMA_DISABILITAZIONE_GRUPPO,gruppo) )  + post;
  11618.         }
  11619.     }

  11620.     public String getLabelAzione(ServiceBinding serviceBinding) {
  11621.         return ServiceBinding.REST.equals(serviceBinding) ? CostantiControlStation.LABEL_PARAMETRO_RISORSA : CostantiControlStation.LABEL_PARAMETRO_AZIONE;
  11622.     }
  11623.     public String getLabelAzioni(ServiceBinding serviceBinding) {
  11624.         return ServiceBinding.REST.equals(serviceBinding) ? CostantiControlStation.LABEL_PARAMETRO_RISORSE : CostantiControlStation.LABEL_PARAMETRO_AZIONI;
  11625.     }
  11626.     public String getLabelAzioniDi(ServiceBinding serviceBinding) {
  11627.         return ServiceBinding.REST.equals(serviceBinding) ? CostantiControlStation.LABEL_PARAMETRO_RISORSE_CONFIG_DI : CostantiControlStation.LABEL_PARAMETRO_AZIONI_CONFIG_DI;
  11628.     }
  11629.     public String getLabelAllAzioniRidefiniteTooltip(ServiceBinding serviceBinding) {
  11630.         return ServiceBinding.REST.equals(serviceBinding) ? CostantiControlStation.LABEL_PARAMETRO_DEFAULT_ALL_RISORSE_RIDEFINITE_TOOLTIP : CostantiControlStation.LABEL_PARAMETRO_DEFAULT_ALL_AZIONI_RIDEFINITE_TOOLTIP;
  11631.     }
  11632.     public String getLabelAllAzioniConfigurate(ServiceBinding serviceBinding) {
  11633.         return ServiceBinding.REST.equals(serviceBinding) ? CostantiControlStation.LABEL_AGGIUNTA_RISORSE_COMPLETATA : CostantiControlStation.LABEL_AGGIUNTA_AZIONI_COMPLETATA;
  11634.     }
  11635.    
  11636.     public List<DataElement> addPorteAzioneToDati(TipoOperazione add, List<DataElement> dati, String string,
  11637.             String[] azioniDisponibiliList, String[] azioniDisponibiliLabelList, String[] azioni, ServiceBinding serviceBinding) {
  11638.        
  11639.         String label = this.getLabelAzioni(serviceBinding);
  11640.        
  11641.         DataElement de = new DataElement();
  11642.         de.setLabel(label);
  11643.         de.setType(DataElementType.TITLE);
  11644.         dati.add(de);
  11645.        
  11646.         // Azione
  11647.         de = new DataElement();
  11648.         de.setLabel(label);
  11649.         de.setValues(azioniDisponibiliList);
  11650.         de.setLabels(azioniDisponibiliLabelList);
  11651.         de.setSelezionati(azioni);
  11652.         de.setType(DataElementType.MULTI_SELECT);
  11653.         de.setName(CostantiControlStation.PARAMETRO_AZIONI);
  11654.         de.setRows(15);
  11655.         de.setRequired(true);
  11656.         dati.add(de);
  11657.        
  11658.         return dati;
  11659.     }
  11660.    
  11661.     // Prepara la lista di azioni delle porte
  11662.     public void preparePorteAzioneList(ISearch ricerca,
  11663.             List<String> listaAzioniParamDaPaginare, String idPorta, Integer parentConfigurazione, List<Parameter> lstParametriBreadcrumbs,
  11664.             String nomePorta, String objectName, List<Parameter> listaParametriSessione,
  11665.             String labelPerPorta, ServiceBinding serviceBinding, AccordoServizioParteComuneSintetico aspc) throws DriverControlStationException {
  11666.         try {
  11667.             ServletUtils.addListElementIntoSession(this.request, this.session, objectName,listaParametriSessione);

  11668.             // setto la barra del titolo

  11669.             String label = this.getLabelAzione(serviceBinding);
  11670.                        
  11671.             int idLista = -1;
  11672.             if(PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_AZIONE.equals(objectName)) {
  11673.                 idLista = Liste.PORTE_DELEGATE_AZIONI;
  11674.             }
  11675.             else {
  11676.                 idLista = Liste.PORTE_APPLICATIVE_AZIONI;
  11677.             }
  11678.             int limit = ricerca.getPageSize(idLista);
  11679.             int offset = ricerca.getIndexIniziale(idLista);
  11680.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  11681.             org.openspcoop2.core.registry.constants.HttpMethod httpMethod = null;
  11682.             if(!ServiceBinding.SOAP.equals(serviceBinding)) {
  11683.                 String filterHttpMethod = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_HTTP_METHOD);
  11684.                 this.addFilterHttpMethod(filterHttpMethod, false);
  11685.                
  11686.                 if(filterHttpMethod!=null) {
  11687.                     httpMethod = org.openspcoop2.core.registry.constants.HttpMethod.toEnumConstant(filterHttpMethod);
  11688.                 }
  11689.             }
  11690.            
  11691.             HashMap<String, ResourceSintetica> mapIdResourceToMethodPath = new HashMap<String, ResourceSintetica>();
  11692.            
  11693.             List<String> listaAzioniPaginata = new ArrayList<>();
  11694.             if(listaAzioniParamDaPaginare!=null && !listaAzioniParamDaPaginare.isEmpty()) {
  11695.                 List<String> listaAzioniDopoSearch = new ArrayList<>();
  11696.                
  11697.                 if(ServiceBinding.SOAP.equals(serviceBinding)) {
  11698.                     for (int i = 0; i < listaAzioniParamDaPaginare.size(); i++) {
  11699.                         String idRisorsa = listaAzioniParamDaPaginare.get(i);
  11700.                        
  11701.                         // verifico nome
  11702.                         if(search!=null && !"".equals(search)) {
  11703.                             if(!idRisorsa.toLowerCase().contains(search.toLowerCase())) {
  11704.                                 continue;
  11705.                             }
  11706.                         }
  11707.                        
  11708.                         // azione che ha un match
  11709.                         listaAzioniDopoSearch.add(idRisorsa);
  11710.                     }
  11711.                 }
  11712.                 else {
  11713.                     for (int i = 0; i < listaAzioniParamDaPaginare.size(); i++) {
  11714.                         String idRisorsa = listaAzioniParamDaPaginare.get(i);
  11715.                         ResourceSintetica risorsa = null;
  11716.                         for (ResourceSintetica resourceTmp : aspc.getResource()) {
  11717.                             if(resourceTmp.getNome().equals(idRisorsa)) {
  11718.                                 risorsa = resourceTmp;
  11719.                                 break;
  11720.                             }
  11721.                         }
  11722.                        
  11723.                         if(risorsa==null) {
  11724.                             throw new DriverControlStationException("Risorsa con id '"+idRisorsa+"' non esistente ?");
  11725.                         }
  11726.                        
  11727.                         // verifico path
  11728.                         if(search!=null && !"".equals(search)) {
  11729.                             if(risorsa.getPath()==null || !risorsa.getPath().toLowerCase().contains(search.toLowerCase())) {
  11730.                                 continue;
  11731.                             }
  11732.                         }
  11733.                        
  11734.                         // verifico metodo
  11735.                         if(httpMethod!=null) {
  11736.                             if(risorsa.getMethod()==null || !risorsa.getMethod().equals(httpMethod)) {
  11737.                                 continue;
  11738.                             }
  11739.                         }
  11740.                        
  11741.                         // azione che ha un match sia con path che con metodo
  11742.                         listaAzioniDopoSearch.add(idRisorsa);
  11743.                         if(risorsa!=null) {
  11744.                             mapIdResourceToMethodPath.put(idRisorsa, risorsa);
  11745.                         }
  11746.                     }
  11747.                 }
  11748.                
  11749.                 ricerca.setNumEntries(idLista, listaAzioniDopoSearch.size());
  11750.                
  11751.                 if(listaAzioniDopoSearch!=null && !listaAzioniDopoSearch.isEmpty()) {
  11752.                     for (int i = 0; i < listaAzioniDopoSearch.size(); i++) {
  11753.                         if(i>=offset && i<(offset+limit)) {
  11754.                             listaAzioniPaginata.add(listaAzioniDopoSearch.get(i));
  11755.                         }
  11756.                     }
  11757.                 }
  11758.             }
  11759.             else {
  11760.                 ricerca.setNumEntries(idLista, listaAzioniParamDaPaginare!=null ? listaAzioniParamDaPaginare.size() : 0);
  11761.             }
  11762.            
  11763.             this.pd.setIndex(offset);
  11764.             this.pd.setPageSize(limit);
  11765.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  11766.            
  11767.             if(ServiceBinding.SOAP.equals(serviceBinding)) {
  11768.                 this.pd.setSearchLabel(this.getLabelAzione(serviceBinding));
  11769.             }
  11770.             else {
  11771.                 this.pd.setSearchLabel(AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_RESOURCES_PATH);
  11772.             }
  11773.            
  11774.             if (search!=null && !search.equals("")) {
  11775.                 ServletUtils.enabledPageDataSearch(this.pd, label, search);
  11776.             }
  11777.            
  11778.             List<String> listaAzioni = new ArrayList<>();
  11779.             HashMap<String, ResourceSintetica> mapToResource = new HashMap<>();
  11780.             for (String azione : listaAzioniPaginata) {
  11781.                 if(ServiceBinding.SOAP.equals(serviceBinding)) {
  11782.                     listaAzioni.add(azione);
  11783.                 }
  11784.                 else {
  11785.                     ResourceSintetica risorsa = mapIdResourceToMethodPath.get(azione);
  11786.                     String nomeRisorsaConPathPerOrderBy =
  11787.                             (risorsa.getPath()==null ? "*" : risorsa.getPath())
  11788.                             +" " +
  11789.                             (risorsa.getMethod()==null ? "ALL" : risorsa.getMethod())   ;
  11790.                     listaAzioni.add(nomeRisorsaConPathPerOrderBy);
  11791.                     mapToResource.put(nomeRisorsaConPathPerOrderBy, risorsa);
  11792.                 }
  11793.             }
  11794.             Collections.sort(listaAzioni);
  11795.            
  11796.             lstParametriBreadcrumbs.add(new Parameter(labelPerPorta,null));

  11797.             // setto la barra del titolo
  11798.             ServletUtils.setPageDataTitle(this.pd, lstParametriBreadcrumbs.toArray(new Parameter[lstParametriBreadcrumbs.size()]));

  11799.             // setto le label delle colonne
  11800.             String[] labels = null;
  11801.             if(ServiceBinding.SOAP.equals(serviceBinding)) {
  11802.                 labels = new String[1];
  11803.                 labels[0] = label;
  11804.             }
  11805.             else {
  11806.                 labels = new String[2];
  11807.                 //labels[0] = label;
  11808.                 //labels[0] = AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_RESOURCES_HTTP_METHOD;
  11809.                 labels[0] = CostantiControlStation.LABEL_PARAMETRO_HTTP_METHOD_COMPACT;
  11810.                 labels[1] = AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_RESOURCES_PATH;
  11811.             }
  11812.             this.pd.setLabels(labels);

  11813.             // preparo i dati
  11814.             List<List<DataElement>> dati = new ArrayList<>();

  11815.             if (listaAzioni != null) {
  11816.                
  11817.                 Iterator<String> it = listaAzioni.iterator();
  11818.                 while (it.hasNext()) {
  11819.                     String nomeAzione = it.next();

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

  11821.                     if(ServiceBinding.SOAP.equals(serviceBinding)) {
  11822.                         DataElement de = new DataElement();
  11823.                         de.setValue(nomeAzione);
  11824.                         de.setIdToRemove(nomeAzione);
  11825.                         e.add(de);
  11826.                     }
  11827.                     else {
  11828.                         ResourceSintetica risorsa = mapToResource.get(nomeAzione);
  11829.                         String labelParametroApcResourcesHttpMethodQualsiasi = AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_RESOURCES_HTTP_METHOD_QUALSIASI;
  11830.                         //HTTP Method
  11831.                         DataElement de = getDataElementHTTPMethodResource(risorsa, labelParametroApcResourcesHttpMethodQualsiasi);  
  11832.                         e.add(de);
  11833.                        
  11834.                         de = new DataElement();
  11835.                         if(risorsa.getPath()==null || "".equals(risorsa.getPath())) {
  11836.                             de.setValue(AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_RESOURCES_PATH_QUALSIASI);
  11837.                         }
  11838.                         else {
  11839.                             de.setValue(risorsa.getPath());
  11840.                         }
  11841.                         de.setToolTip(risorsa.getNome());
  11842.                         de.setIdToRemove(risorsa.getNome());
  11843.                         e.add(de);
  11844.                     }

  11845.                     dati.add(e);
  11846.                 }
  11847.             }

  11848.            
  11849.             this.pd.setDati(dati);
  11850.             this.pd.setAddButton(true);

  11851.         } catch (Exception e) {
  11852.             this.logError("Exception: " + e.getMessage(), e);
  11853.             throw new DriverControlStationException(e);
  11854.         }
  11855.     }
  11856.    
  11857.     public DataElement getDataElementHTTPMethodResource(org.openspcoop2.core.registry.beans.ResourceSintetica risorsa,  String labelParametroApcResourcesHttpMethodQualsiasi) {
  11858.         return getDataElementHTTPMethodResource(risorsa.getMethod(), labelParametroApcResourcesHttpMethodQualsiasi, null);
  11859.     }
  11860.     public DataElement getDataElementHTTPMethodResource(org.openspcoop2.core.registry.Resource risorsa, String labelParametroApcResourcesHttpMethodQualsiasi, String detailURL) {
  11861.         return getDataElementHTTPMethodResource(risorsa.getMethod(), labelParametroApcResourcesHttpMethodQualsiasi, detailURL);
  11862.     }
  11863.     public DataElement getDataElementHTTPMethodResource(HttpMethod httpMethod,  String labelParametroApcResourcesHttpMethodQualsiasi, String detailUrl) {
  11864.        
  11865.         DataElement de = new DataElement();

  11866.         String styleClass = "resource-method-block resource-method-default";
  11867.         if(httpMethod==null) {
  11868.             de.setValue(labelParametroApcResourcesHttpMethodQualsiasi);
  11869.         }
  11870.         else {
  11871.             de.setValue(httpMethod.toString());
  11872.            
  11873.             switch (httpMethod) {
  11874.             case DELETE:
  11875.                 styleClass = "resource-method-block resource-method-delete";
  11876.                 break;
  11877.             case GET:
  11878.                 styleClass = "resource-method-block resource-method-get";
  11879.                 break;
  11880.             case HEAD:
  11881.                 styleClass = "resource-method-block resource-method-head";
  11882.                 break;
  11883.             case LINK:
  11884.                 styleClass = "resource-method-block resource-method-link";
  11885.                 break;
  11886.             case OPTIONS:
  11887.                 styleClass = "resource-method-block resource-method-options";
  11888.                 break;
  11889.             case PATCH:
  11890.                 styleClass = "resource-method-block resource-method-patch";
  11891.                 break;
  11892.             case POST:
  11893.                 styleClass = "resource-method-block resource-method-post";
  11894.                 break;
  11895.             case PUT:
  11896.                 styleClass = "resource-method-block resource-method-put";
  11897.                 break;
  11898.             case TRACE:
  11899.                 styleClass = "resource-method-block resource-method-trace";
  11900.                 break;
  11901.             case UNLINK:
  11902.                 styleClass = "resource-method-block resource-method-unlink";
  11903.                 break;
  11904.             default:
  11905.                 styleClass = "resource-method-block resource-method-default";
  11906.                 break;
  11907.             }
  11908.         }
  11909.         if(StringUtils.isNotEmpty(detailUrl)) {
  11910.             StringBuilder onClickFunction = new StringBuilder();
  11911.             onClickFunction.append(Costanti.JS_FUNCTION_GO_TO_PREFIX);
  11912.             onClickFunction.append(detailUrl);
  11913.             onClickFunction.append(Costanti.JS_FUNCTION_GO_TO_SUFFIX);
  11914.             de.setOnClick(onClickFunction.toString());
  11915.             styleClass += " resource-method-block-pointer";
  11916.         }
  11917.        
  11918.         de.setLabelStyleClass(styleClass);
  11919.         de.setWidthPx(75);
  11920.         return de;
  11921.     }
  11922.    
  11923.    
  11924.     public void addFilterServiceBinding(String serviceBinding, boolean postBack, boolean showAPISuffix) throws DriverControlStationException{
  11925.         try {
  11926.             ServiceBinding[] serviceBindings = ServiceBinding.values();
  11927.            
  11928.             String [] values = new String[serviceBindings.length + 1];
  11929.             String [] labels = new String[serviceBindings.length + 1];
  11930.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_QUALSIASI;
  11931.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_QUALSIASI;
  11932.             for (int i =0; i < serviceBindings.length ; i ++) {
  11933.                 ServiceBinding serviceBinding2 = serviceBindings[i];
  11934.                 switch (serviceBinding2) {
  11935.                 case REST:
  11936.                     labels[i+1] = CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_REST;
  11937.                     values[i+1] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_REST.toLowerCase();
  11938.                     break;
  11939.                 case SOAP:
  11940.                 default:
  11941.                     labels[i+1] = CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_SOAP;
  11942.                     values[i+1] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_SOAP.toLowerCase();
  11943.                     break;
  11944.                 }
  11945.             }
  11946.            
  11947.             String selectedValue = serviceBinding != null ? serviceBinding : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_QUALSIASI;
  11948.            
  11949.             String label = null;
  11950.             if(showAPISuffix) {
  11951.                 label = CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_API;
  11952.             }
  11953.             else {
  11954.                 label = CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING;
  11955.             }
  11956.            
  11957.             this.pd.addFilter(Filtri.FILTRO_SERVICE_BINDING, label, selectedValue, values, labels, postBack, this.getSize());
  11958.            
  11959.         } catch (Exception e) {
  11960.             this.logError("Exception: " + e.getMessage(), e);
  11961.             throw new DriverControlStationException(e);
  11962.         }
  11963.     }
  11964.    
  11965.     public void addFilterStatoAccordo(String statoAccordo, boolean postBack) throws DriverControlStationException{
  11966.         try {
  11967.             String [] stati = StatiAccordo.toArray();
  11968.             String [] statiLabel = StatiAccordo.toLabel();
  11969.             String [] values = new String[stati.length + 1];
  11970.             String [] labels = new String[stati.length + 1];
  11971.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_QUALSIASI;
  11972.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_QUALSIASI;
  11973.             for (int i =0; i < stati.length ; i ++) {
  11974.                 labels[i+1] = statiLabel[i];
  11975.                 values[i+1] = stati[i];
  11976.             }
  11977.            
  11978.             String selectedValue = statoAccordo != null ? statoAccordo : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_QUALSIASI;
  11979.            
  11980.             String label = CostantiControlStation.LABEL_PARAMETRO_STATO_PACKAGE;
  11981.            
  11982.             this.pd.addFilter(Filtri.FILTRO_STATO_ACCORDO, label, selectedValue, values, labels, postBack, this.getSize());
  11983.            
  11984.         } catch (Exception e) {
  11985.             this.logError("Exception: " + e.getMessage(), e);
  11986.             throw new DriverControlStationException(e);
  11987.         }
  11988.     }
  11989.    
  11990.     public void addFilterHttpMethod(String httpMethod, boolean postBack) throws DriverControlStationException{
  11991.         try {
  11992.             String [] metodi = org.openspcoop2.core.registry.constants.HttpMethod.toArray();
  11993.             String [] metodiLabel = metodi;
  11994.             String [] values = new String[metodi.length + 1];
  11995.             String [] labels = new String[metodi.length + 1];
  11996.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_HTTP_METHOD_QUALSIASI;
  11997.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_HTTP_METHOD_QUALSIASI;
  11998.             for (int i =0; i < metodi.length ; i ++) {
  11999.                 labels[i+1] = metodiLabel[i];
  12000.                 values[i+1] = metodi[i];
  12001.             }
  12002.            
  12003.             String selectedValue = httpMethod != null ? httpMethod : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_HTTP_METHOD_QUALSIASI;
  12004.            
  12005.             String label = CostantiControlStation.LABEL_PARAMETRO_HTTP_METHOD;
  12006.            
  12007.             this.pd.addFilter(Filtri.FILTRO_HTTP_METHOD, label, selectedValue, values, labels, postBack, this.getSize());
  12008.            
  12009.         } catch (Exception e) {
  12010.             this.logError("Exception: " + e.getMessage(), e);
  12011.             throw new DriverControlStationException(e);
  12012.         }
  12013.     }
  12014.    
  12015.     public void addFilterRuoloTipologia(String ruoloTipologia, boolean postBack) throws DriverControlStationException{
  12016.         try {
  12017.             String [] metodi = new String[2];
  12018.             metodi[0] = RuoloTipologia.INTERNO.getValue();
  12019.             metodi[1] = RuoloTipologia.ESTERNO.getValue();
  12020.             String [] metodiLabel = new String[2];
  12021.             metodiLabel[0] = CostantiControlStation.RUOLI_TIPOLOGIA_LABEL_INTERNO;
  12022.             metodiLabel[1] = CostantiControlStation.RUOLI_TIPOLOGIA_LABEL_ESTERNO;
  12023.             String [] values = new String[metodi.length + 1];
  12024.             String [] labels = new String[metodi.length + 1];
  12025.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_RUOLO_TIPOLOGIA_QUALSIASI;
  12026.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_RUOLO_TIPOLOGIA_QUALSIASI;
  12027.             for (int i =0; i < metodi.length ; i ++) {
  12028.                 labels[i+1] = metodiLabel[i];
  12029.                 values[i+1] = metodi[i];
  12030.             }
  12031.            
  12032.             String selectedValue = ruoloTipologia != null ? ruoloTipologia : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_RUOLO_TIPOLOGIA_QUALSIASI;
  12033.            
  12034.             String label = CostantiControlStation.LABEL_PARAMETRO_RUOLO_TIPOLOGIA;
  12035.            
  12036.             this.pd.addFilter(Filtri.FILTRO_RUOLO_TIPOLOGIA, label, selectedValue, values, labels, postBack, this.getSize());
  12037.            
  12038.         } catch (Exception e) {
  12039.             this.logError("Exception: " + e.getMessage(), e);
  12040.             throw new DriverControlStationException(e);
  12041.         }
  12042.     }
  12043.    
  12044.     public void addFilterRuoloContesto(String ruoloContesto, boolean postBack) throws DriverControlStationException{
  12045.         try {
  12046.             String [] metodi = new String[2];
  12047.             metodi[0] = RuoloContesto.PORTA_APPLICATIVA.getValue();
  12048.             metodi[1] = RuoloContesto.PORTA_DELEGATA.getValue();
  12049.             String [] metodiLabel = new String[2];
  12050.             metodiLabel[0] = CostantiControlStation.RUOLI_CONTESTO_UTILIZZO_LABEL_EROGAZIONE;
  12051.             metodiLabel[1] = CostantiControlStation.RUOLI_CONTESTO_UTILIZZO_LABEL_FRUIZIONE;
  12052.             String [] values = new String[metodi.length + 1];
  12053.             String [] labels = new String[metodi.length + 1];
  12054.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_RUOLO_CONTESTO_QUALSIASI;
  12055.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_RUOLO_CONTESTO_QUALSIASI;
  12056.             for (int i =0; i < metodi.length ; i ++) {
  12057.                 labels[i+1] = metodiLabel[i];
  12058.                 values[i+1] = metodi[i];
  12059.             }
  12060.            
  12061.             String selectedValue = ruoloContesto != null ? ruoloContesto : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_RUOLO_CONTESTO_QUALSIASI;
  12062.            
  12063.             String label = CostantiControlStation.LABEL_PARAMETRO_RUOLO_CONTESTO;
  12064.            
  12065.             this.pd.addFilter(Filtri.FILTRO_RUOLO_CONTESTO, label, selectedValue, values, labels, postBack, this.getSize());
  12066.            
  12067.         } catch (Exception e) {
  12068.             this.logError("Exception: " + e.getMessage(), e);
  12069.             throw new DriverControlStationException(e);
  12070.         }
  12071.     }
  12072.    
  12073.     public void addFilterScopeTipologia(String scopeTipologia, boolean postBack) throws DriverControlStationException{
  12074.         try {
  12075.             String [] metodi = new String[2];
  12076.             metodi[0] = "interno"; //RuoloTipologia.INTERNO.getValue();
  12077.             metodi[1] = "esterno"; //RuoloTipologia.ESTERNO.getValue();
  12078.             String [] metodiLabel = new String[2];
  12079.             metodiLabel[0] = CostantiControlStation.SCOPE_TIPOLOGIA_LABEL_INTERNO;
  12080.             metodiLabel[1] = CostantiControlStation.SCOPE_TIPOLOGIA_LABEL_ESTERNO;
  12081.             String [] values = new String[metodi.length + 1];
  12082.             String [] labels = new String[metodi.length + 1];
  12083.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SCOPE_TIPOLOGIA_QUALSIASI;
  12084.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SCOPE_TIPOLOGIA_QUALSIASI;
  12085.             for (int i =0; i < metodi.length ; i ++) {
  12086.                 labels[i+1] = metodiLabel[i];
  12087.                 values[i+1] = metodi[i];
  12088.             }
  12089.            
  12090.             String selectedValue = scopeTipologia != null ? scopeTipologia : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SCOPE_TIPOLOGIA_QUALSIASI;
  12091.            
  12092.             String label = CostantiControlStation.LABEL_PARAMETRO_SCOPE_TIPOLOGIA;
  12093.            
  12094.             this.pd.addFilter(Filtri.FILTRO_SCOPE_TIPOLOGIA, label, selectedValue, values, labels, postBack, this.getSize());
  12095.            
  12096.         } catch (Exception e) {
  12097.             this.logError("Exception: " + e.getMessage(), e);
  12098.             throw new DriverControlStationException(e);
  12099.         }
  12100.     }
  12101.    
  12102.     public void addFilterScopeContesto(String scopeContesto, boolean postBack) throws DriverControlStationException{
  12103.         try {
  12104.             String [] metodi = new String[2];
  12105.             metodi[0] = ScopeContesto.PORTA_APPLICATIVA.getValue();
  12106.             metodi[1] = ScopeContesto.PORTA_DELEGATA.getValue();
  12107.             String [] metodiLabel = new String[2];
  12108.             metodiLabel[0] = CostantiControlStation.SCOPE_CONTESTO_UTILIZZO_LABEL_EROGAZIONE;
  12109.             metodiLabel[1] = CostantiControlStation.SCOPE_CONTESTO_UTILIZZO_LABEL_FRUIZIONE;
  12110.             String [] values = new String[metodi.length + 1];
  12111.             String [] labels = new String[metodi.length + 1];
  12112.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SCOPE_CONTESTO_QUALSIASI;
  12113.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SCOPE_CONTESTO_QUALSIASI;
  12114.             for (int i =0; i < metodi.length ; i ++) {
  12115.                 labels[i+1] = metodiLabel[i];
  12116.                 values[i+1] = metodi[i];
  12117.             }
  12118.            
  12119.             String selectedValue = scopeContesto != null ? scopeContesto : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SCOPE_CONTESTO_QUALSIASI;
  12120.            
  12121.             String label = CostantiControlStation.LABEL_PARAMETRO_SCOPE_CONTESTO;
  12122.            
  12123.             this.pd.addFilter(Filtri.FILTRO_SCOPE_CONTESTO, label, selectedValue, values, labels, postBack, this.getSize());
  12124.            
  12125.         } catch (Exception e) {
  12126.             this.logError("Exception: " + e.getMessage(), e);
  12127.             throw new DriverControlStationException(e);
  12128.         }
  12129.     }
  12130.    
  12131.     public void addFilterDominio(String dominio, boolean postBack) throws DriverControlStationException{
  12132.         try {
  12133.            
  12134.             String [] sdValues = SoggettiCostanti.getSoggettiDominiValue();
  12135.             String [] sdLabels = SoggettiCostanti.getSoggettiDominiLabel();        
  12136.             String [] values = new String[sdValues.length + 1];
  12137.             String [] labels = new String[sdValues.length + 1];
  12138.             labels[0] = SoggettiCostanti.LABEL_PARAMETRO_SOGGETTO_DOMINIO_QUALSIASI;
  12139.             values[0] = SoggettiCostanti.DEFAULT_VALUE_PARAMETRO_SOGGETTO_DOMINIO_QUALSIASI;
  12140.             for (int i =0; i < sdValues.length ; i ++) {
  12141.                 labels[i+1] = sdLabels[i];
  12142.                 values[i+1] = sdValues[i];
  12143.             }
  12144.            
  12145.             String selectedValue = dominio != null ? dominio : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_QUALSIASI;
  12146.            
  12147.             this.pd.addFilter(Filtri.FILTRO_DOMINIO, SoggettiCostanti.LABEL_PARAMETRO_SOGGETTO_DOMINIO, selectedValue, values, labels, postBack, this.getSize());
  12148.            
  12149.         } catch (Exception e) {
  12150.             this.logError("Exception: " + e.getMessage(), e);
  12151.             throw new DriverControlStationException(e);
  12152.         }

  12153.     }
  12154.    
  12155.     public void addFilterRuolo(String ruolo, boolean postBack) throws DriverControlStationException{
  12156.         try {
  12157.            
  12158.             FiltroRicercaRuoli filtroRuoli = new FiltroRicercaRuoli();
  12159.             filtroRuoli.setContesto(RuoloContesto.QUALSIASI);
  12160.             filtroRuoli.setTipologia(RuoloTipologia.INTERNO);
  12161.             List<IDRuolo> listRuoli = this.ruoliCore.getAllIdRuoli(filtroRuoli);
  12162.             int length = 1;
  12163.             if(listRuoli!=null && listRuoli.size()>0) {
  12164.                 length+=listRuoli.size();
  12165.             }
  12166.             String [] values = new String[length];
  12167.             String [] labels = new String[length];
  12168.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_RUOLO_QUALSIASI;
  12169.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_RUOLO_QUALSIASI;
  12170.             if(listRuoli!=null && listRuoli.size()>0) {
  12171.                 for (int i =0; i < listRuoli.size() ; i ++) {
  12172.                     labels[i+1] = listRuoli.get(i).getNome();
  12173.                     values[i+1] = listRuoli.get(i).getNome();
  12174.                 }
  12175.             }
  12176.            
  12177.             this.pd.addFilter(Filtri.FILTRO_RUOLO, RuoliCostanti.LABEL_RUOLO, ruolo, values, labels, postBack, this.getSize());
  12178.            
  12179.         } catch (Exception e) {
  12180.             this.logError("Exception: " + e.getMessage(), e);
  12181.             throw new DriverControlStationException(e);
  12182.         }
  12183.     }
  12184.        
  12185.     public void addFilterTipoPolicy(String tipoPolicy, boolean postBack) throws DriverControlStationException{
  12186.         try {

  12187.             String selectedValue = tipoPolicy != null ? tipoPolicy : CostantiControlStation.DEFAULT_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPO;

  12188.             this.pd.addFilter(Filtri.FILTRO_TIPO_POLICY, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPO,
  12189.                     selectedValue,
  12190.                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_VALORI,
  12191.                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_LABELS,
  12192.                     postBack, this.getSize());
  12193.            
  12194.         } catch (Exception e) {
  12195.             this.logError("Exception: " + e.getMessage(), e);
  12196.             throw new DriverControlStationException(e);
  12197.         }
  12198.     }
  12199.    
  12200.     public void addFilterGruppo(String filterProtocollo, String gruppo, boolean postBack) throws DriverControlStationException{
  12201.         try {
  12202.            
  12203.             boolean isFilterProtocollo = filterProtocollo!=null &&
  12204.                     //!"".equals(filterProtocollo) &&
  12205.                     !CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PROTOCOLLO_QUALSIASI.equals(filterProtocollo);
  12206.            
  12207.             List<String> protocolli = this.core.getProtocolli(this.request, this.session);
  12208.             if(isFilterProtocollo) {
  12209.                 protocolli.clear();
  12210.                 protocolli.add(filterProtocollo);
  12211.             }
  12212.            
  12213.             FiltroRicercaGruppi filtroGruppi = new FiltroRicercaGruppi();
  12214.             filtroGruppi.setProtocolli(protocolli);
  12215.             List<IDGruppo> listGruppi = this.gruppiCore.getAllIdGruppi(filtroGruppi);
  12216.             int length = 1;
  12217.             if(listGruppi!=null && listGruppi.size()>0) {
  12218.                 length+=listGruppi.size();
  12219.             }
  12220.             String [] values = new String[length];
  12221.             String [] labels = new String[length];
  12222.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_GRUPPO_QUALSIASI;
  12223.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_GRUPPO_QUALSIASI;
  12224.             if(listGruppi!=null && listGruppi.size()>0) {
  12225.                 for (int i =0; i < listGruppi.size() ; i ++) {
  12226.                     labels[i+1] = listGruppi.get(i).getNome();
  12227.                     values[i+1] = listGruppi.get(i).getNome();
  12228.                 }
  12229.             }
  12230.            
  12231.             this.pd.addFilter(Filtri.FILTRO_GRUPPO, GruppiCostanti.LABEL_GRUPPO, gruppo, values, labels, postBack, this.getSize());
  12232.            
  12233.         } catch (Exception e) {
  12234.             this.logError("Exception: " + e.getMessage(), e);
  12235.             throw new DriverControlStationException(e);
  12236.         }
  12237.     }
  12238.    
  12239.     public void addFilterApi(String filterProtocollo, String filterTipoAccordo, String gruppo, String api, boolean postBack) throws DriverControlStationException{
  12240.         try {
  12241.            
  12242.             boolean isFilterProtocollo = filterProtocollo!=null &&
  12243.                     //!"".equals(filterProtocollo) &&
  12244.                     !CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PROTOCOLLO_QUALSIASI.equals(filterProtocollo);
  12245.            
  12246.             List<String> protocolli = this.core.getProtocolli(this.request, this.session);
  12247.             if(isFilterProtocollo) {
  12248.                 protocolli.clear();
  12249.                 protocolli.add(filterProtocollo);
  12250.             }
  12251.            
  12252.             FiltroRicercaAccordi filtroRicerca = new FiltroRicercaAccordi();
  12253.            
  12254.             filtroRicerca.setOrder(true);
  12255.            
  12256.             filtroRicerca.setProtocolli(protocolli);
  12257.            
  12258.             if(gruppo!=null && !CostantiControlStation.DEFAULT_VALUE_PARAMETRO_GRUPPO_QUALSIASI.equals(gruppo)) {
  12259.                 IDGruppo idGruppo = new IDGruppo(gruppo);
  12260.                 filtroRicerca.setIdGruppo(idGruppo);
  12261.             }
  12262.            
  12263.             if(filterTipoAccordo!=null && !CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_QUALSIASI.equals(filterTipoAccordo)) {
  12264.                 filtroRicerca.setServiceBinding(org.openspcoop2.core.registry.constants.ServiceBinding.toEnumConstant(filterTipoAccordo));
  12265.             }
  12266.            
  12267.             List<IDAccordo> listAccordi = null;
  12268.             try {
  12269.                 listAccordi = this.apcCore.getAllIdAccordiServizio(filtroRicerca);
  12270.             }catch(DriverRegistroServiziNotFound notFound) {
  12271.                 listAccordi = new ArrayList<IDAccordo>();
  12272.             }
  12273.             int length = 1;
  12274.             if(listAccordi!=null && listAccordi.size()>0) {
  12275.                 length+=listAccordi.size();
  12276.             }
  12277.             String [] values = new String[length];
  12278.             String [] labels = new String[length];
  12279.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_API_QUALSIASI;
  12280.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_API_QUALSIASI;
  12281.             if(listAccordi!=null && listAccordi.size()>0) {
  12282.                 for (int i =0; i < listAccordi.size() ; i ++) {
  12283.                     labels[i+1] = this.getLabelIdAccordo(listAccordi.get(i));
  12284.                     values[i+1] = IDAccordoFactory.getInstance().getUriFromIDAccordo(listAccordi.get(i));
  12285.                 }
  12286.             }
  12287.            
  12288.             this.pd.addFilter(Filtri.FILTRO_API, AccordiServizioParteComuneCostanti.LABEL_APC, api, values, labels, postBack, this.getSize());
  12289.            
  12290.         } catch (Exception e) {
  12291.             this.logError("Exception: " + e.getMessage(), e);
  12292.             throw new DriverControlStationException(e);
  12293.         }
  12294.     }
  12295.    
  12296.     public void addFilterCanale(CanaliConfigurazione canali, String canale, boolean postBack) throws DriverControlStationException{
  12297.         try {
  12298.            
  12299.             int length = 1;
  12300.             if(canali!=null && canali.sizeCanaleList()>0) {
  12301.                 length+=canali.sizeCanaleList();
  12302.             }
  12303.             String [] values = new String[length];
  12304.             String [] labels = new String[length];
  12305.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CANALE_QUALSIASI;
  12306.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CANALE_QUALSIASI;
  12307.             if(canali!=null && canali.sizeCanaleList()>0) {
  12308.                 for (int i =0; i < canali.sizeCanaleList() ; i ++) {
  12309.                     labels[i+1] = canali.getCanale(i).getNome();
  12310.                     if(canali.getCanale(i).isCanaleDefault()) {
  12311.                         values[i+1] = CostantiControlStation.PREFIX_VALUE_PARAMETRO_CANALE_DEFAULT+canali.getCanale(i).getNome();
  12312.                     }
  12313.                     else {
  12314.                         values[i+1] = canali.getCanale(i).getNome();
  12315.                     }
  12316.                 }
  12317.             }
  12318.            
  12319.             this.pd.addFilter(Filtri.FILTRO_CANALE, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_CANALE, canale, values, labels, postBack, this.getSize());
  12320.            
  12321.         } catch (Exception e) {
  12322.             this.logError("Exception: " + e.getMessage(), e);
  12323.             throw new DriverControlStationException(e);
  12324.         }
  12325.     }
  12326.    
  12327.     public void addFilterApiContesto(String apiContesto, boolean postBack) throws DriverControlStationException{
  12328.         this._addFilterApiContesto(false, false, false, apiContesto, postBack);
  12329.     }
  12330.     public void addFilterApiContestoRuoli(String apiContesto, boolean postBack) throws DriverControlStationException{
  12331.         this._addFilterApiContesto(true, true, false, apiContesto, postBack);
  12332.     }
  12333.     private void _addFilterApiContesto(boolean soggetti, boolean applicativi, boolean erogazioneFruizione, String apiContesto, boolean postBack) throws DriverControlStationException{
  12334.         try {
  12335.             int size = 2;
  12336.             if(soggetti) {
  12337.                 size++;
  12338.             }
  12339.             if(applicativi) {
  12340.                 size++;
  12341.             }
  12342.             if(erogazioneFruizione) {
  12343.                 size++;
  12344.             }
  12345.            
  12346.             String [] metodi = new String[size];
  12347.             int index = 0;
  12348.             if(soggetti) {
  12349.                 metodi[index++] = Filtri.FILTRO_API_CONTESTO_VALUE_SOGGETTI;
  12350.             }
  12351.             if(applicativi) {
  12352.                 metodi[index++] = Filtri.FILTRO_API_CONTESTO_VALUE_APPLICATIVI;
  12353.             }
  12354.             metodi[index++] = TipoPdD.APPLICATIVA.getTipo();
  12355.             metodi[index++] = TipoPdD.DELEGATA.getTipo();
  12356.             if(erogazioneFruizione) {
  12357.                 metodi[index++] = Filtri.FILTRO_API_CONTESTO_VALUE_EROGAZIONE_FRUIZIONE;
  12358.             }
  12359.             String [] metodiLabel = new String[size];
  12360.             index = 0;
  12361.             if(soggetti) {
  12362.                 metodiLabel[index++] = CostantiControlStation.API_CONTESTO_UTILIZZO_LABEL_SOGGETTI;
  12363.             }
  12364.             if(applicativi) {
  12365.                 metodiLabel[index++] = CostantiControlStation.API_CONTESTO_UTILIZZO_LABEL_APPLICATIVI;
  12366.             }
  12367.             metodiLabel[index++] = CostantiControlStation.API_CONTESTO_UTILIZZO_LABEL_EROGAZIONE;
  12368.             metodiLabel[index++] = CostantiControlStation.API_CONTESTO_UTILIZZO_LABEL_FRUIZIONE;
  12369.             if(erogazioneFruizione) {
  12370.                 metodi[index++] = CostantiControlStation.API_CONTESTO_UTILIZZO_LABEL_EROGAZIONE_FRUIZIONE;
  12371.             }
  12372.             String [] values = new String[metodi.length + 1];
  12373.             String [] labels = new String[metodi.length + 1];
  12374.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_API_CONTESTO_QUALSIASI;
  12375.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_API_CONTESTO_QUALSIASI;
  12376.             for (int i =0; i < metodi.length ; i ++) {
  12377.                 labels[i+1] = metodiLabel[i];
  12378.                 values[i+1] = metodi[i];
  12379.             }
  12380.            
  12381.             String selectedValue = apiContesto != null ? apiContesto : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_API_CONTESTO_QUALSIASI;
  12382.            
  12383.             String label = CostantiControlStation.LABEL_PARAMETRO_API_CONTESTO;
  12384.            
  12385.             this.pd.addFilter(Filtri.FILTRO_API_CONTESTO, label, selectedValue, values, labels, postBack, this.getSize());
  12386.            
  12387.         } catch (Exception e) {
  12388.             this.logError("Exception: " + e.getMessage(), e);
  12389.             throw new DriverControlStationException(e);
  12390.         }
  12391.     }
  12392.    
  12393.     public void addFilterApiImplementazione(String filterProtocollo, String filterSoggetto, String filterGruppo, String filterApiContesto, String apiImplementazione, boolean postBack) throws DriverControlStationException{
  12394.         try {
  12395.             boolean isFruizione = TipoPdD.DELEGATA.getTipo().equals(filterApiContesto);
  12396.             boolean isErogazione = TipoPdD.APPLICATIVA.getTipo().equals(filterApiContesto);
  12397.            
  12398.             if(!isErogazione && !isFruizione) {
  12399.                 return;
  12400.             }
  12401.            
  12402.             boolean isFilterProtocollo = filterProtocollo!=null &&
  12403.                     //!"".equals(filterProtocollo) &&
  12404.                     !CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PROTOCOLLO_QUALSIASI.equals(filterProtocollo);
  12405.             boolean isFilterSoggetto = filterSoggetto!=null &&
  12406.                     //!"".equals(filterSoggetto) &&
  12407.                     !CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI.equals(filterSoggetto);
  12408.             boolean isFilterGruppo = filterGruppo!=null &&
  12409.                     //!"".equals(filterGruppo) &&
  12410.                     !CostantiControlStation.DEFAULT_VALUE_PARAMETRO_GRUPPO_QUALSIASI.equals(filterGruppo);
  12411.            
  12412.             List<String> protocolli = this.core.getProtocolli(this.request, this.session);
  12413.             if(isFilterProtocollo) {
  12414.                 protocolli.clear();
  12415.                 protocolli.add(filterProtocollo);
  12416.             }
  12417.            
  12418.             String tipoSoggetto = null;
  12419.             String nomeSoggetto = null;
  12420.             String protocolloSelezionato = null;
  12421.             if(isFilterSoggetto) {
  12422.                 tipoSoggetto = filterSoggetto.split("/")[0];
  12423.                 nomeSoggetto = filterSoggetto.split("/")[1];
  12424.                 protocolloSelezionato = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(tipoSoggetto);
  12425.             }
  12426.             else {
  12427.                 protocolloSelezionato = protocolli.get(0);
  12428.             }
  12429.            
  12430.             String gruppo = null;
  12431.             if(isFilterGruppo) {
  12432.                 gruppo = filterGruppo;
  12433.             }
  12434.            
  12435.             List<String> valuesL = new ArrayList<>();
  12436.             List<String> labelsL = new ArrayList<>();
  12437.             if(isFruizione) {
  12438.                 List<IDFruizione> listFruizioni = this.apsCore.getFruizioni(protocolli, gruppo, tipoSoggetto, nomeSoggetto);
  12439.                 if(listFruizioni!=null && !listFruizioni.isEmpty()) {
  12440.                     for (IDFruizione idFruizione : listFruizioni) {
  12441.                         valuesL.add(idFruizione.toFormatString());
  12442.                         if(isFilterSoggetto) {
  12443.                             labelsL.add(this.getLabelIdServizio(idFruizione.getIdServizio()));
  12444.                         }
  12445.                         else {
  12446.                             labelsL.add(this.getLabelServizioFruizione(protocolloSelezionato, idFruizione.getIdFruitore(), idFruizione.getIdServizio()));
  12447.                         }
  12448.                     }
  12449.                 }
  12450.             }
  12451.             else {
  12452.                 List<IDServizio> listErogazioni = this.apsCore.getErogazioni(protocolli, gruppo, tipoSoggetto, nomeSoggetto);
  12453.                 if(listErogazioni!=null && !listErogazioni.isEmpty()) {
  12454.                     for (IDServizio idServizio : listErogazioni) {
  12455.                         valuesL.add(idServizio.toFormatString());
  12456.                         if(isFilterSoggetto) {
  12457.                             labelsL.add(this.getLabelIdServizioSenzaErogatore(idServizio));
  12458.                         }
  12459.                         else {
  12460.                             labelsL.add(this.getLabelIdServizio(idServizio));
  12461.                         }
  12462.                     }
  12463.                 }
  12464.             }
  12465.            
  12466.             String [] values = new String[valuesL.size() + 1];
  12467.             String [] labels = new String[labelsL.size() + 1];
  12468.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_API_IMPLEMENTAZIONE_QUALSIASI;
  12469.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_API_IMPLEMENTAZIONE_QUALSIASI;
  12470.             for (int i =0; i < valuesL.size() ; i ++) {
  12471.                 labels[i+1] = labelsL.get(i);
  12472.                 values[i+1] = valuesL.get(i);
  12473.             }
  12474.            
  12475.             String selectedValue = apiImplementazione != null ? apiImplementazione : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_API_IMPLEMENTAZIONE_QUALSIASI;
  12476.            
  12477.             String label = CostantiControlStation.LABEL_PARAMETRO_API_IMPLEMENTAZIONE;
  12478.            
  12479.             this.pd.addFilter(Filtri.FILTRO_API_IMPLEMENTAZIONE, label, selectedValue, values, labels, postBack, this.getSize());
  12480.            
  12481.         } catch (Exception e) {
  12482.             this.logError("Exception: " + e.getMessage(), e);
  12483.             throw new DriverControlStationException(e);
  12484.         }
  12485.     }
  12486.    
  12487.     public void addFilterApplicativo(String filterProtocollo, String filterSoggetto, String applicativo, boolean postBack) throws DriverControlStationException{
  12488.         try {
  12489.            
  12490.             boolean isFilterProtocollo = filterProtocollo!=null &&
  12491.                     //!"".equals(filterProtocollo) &&
  12492.                     !CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PROTOCOLLO_QUALSIASI.equals(filterProtocollo);
  12493.             boolean isFilterSoggetto = filterSoggetto!=null &&
  12494.                     //!"".equals(filterSoggetto) &&
  12495.                     !CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI.equals(filterSoggetto);
  12496.                        
  12497.             List<String> protocolli = this.core.getProtocolli(this.request, this.session);
  12498.             if(isFilterProtocollo) {
  12499.                 protocolli.clear();
  12500.                 protocolli.add(filterProtocollo);
  12501.             }
  12502.            
  12503.             String filterSoggettoTipo = null;
  12504.             String filterSoggettoNome = null;
  12505.             String protocolloSelezionato = null;
  12506.             if(isFilterSoggetto) {
  12507.                 filterSoggettoTipo = filterSoggetto.split("/")[0];
  12508.                 filterSoggettoNome = filterSoggetto.split("/")[1];
  12509.                 protocolloSelezionato = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(filterSoggettoTipo);
  12510.             }
  12511.             else {
  12512.                 protocolloSelezionato = protocolli.get(0);
  12513.             }
  12514.            
  12515.             List<String> valuesL = new ArrayList<>();
  12516.             List<String> labelsL = new ArrayList<>();
  12517.             List<IDServizioApplicativo> listApplicativi = this.confCore.getServiziApplicativi(null, protocolli, filterSoggettoTipo, filterSoggettoNome);
  12518.             if(listApplicativi!=null && !listApplicativi.isEmpty()) {
  12519.                 for (IDServizioApplicativo idApplicativo : listApplicativi) {
  12520.                     valuesL.add(idApplicativo.toFormatString());
  12521.                     if(isFilterSoggetto) {
  12522.                         labelsL.add(idApplicativo.getNome());
  12523.                     }
  12524.                     else {
  12525.                         labelsL.add(this.getLabelServizioApplicativo(protocolloSelezionato, idApplicativo));
  12526.                     }
  12527.                 }
  12528.             }
  12529.            
  12530.             String [] values = new String[valuesL.size() + 1];
  12531.             String [] labels = new String[labelsL.size() + 1];
  12532.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_APPLICATIVO_QUALSIASI;
  12533.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_APPLICATIVO_QUALSIASI;
  12534.             for (int i =0; i < valuesL.size() ; i ++) {
  12535.                 labels[i+1] = labelsL.get(i);
  12536.                 values[i+1] = valuesL.get(i);
  12537.             }
  12538.            
  12539.             String selectedValue = applicativo != null ? applicativo : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_APPLICATIVO_QUALSIASI;
  12540.            
  12541.             String label = CostantiControlStation.LABEL_PARAMETRO_APPLICATIVO;
  12542.            
  12543.             this.pd.addFilter(Filtri.FILTRO_SERVIZIO_APPLICATIVO, label, selectedValue, values, labels, postBack, this.getSize());
  12544.            
  12545.         } catch (Exception e) {
  12546.             this.logError("Exception: " + e.getMessage(), e);
  12547.             throw new DriverControlStationException(e);
  12548.         }
  12549.     }
  12550.    
  12551.     public void addFilterTipoCredenziali(String tipo, boolean postBack, boolean autenticazioneToken) throws DriverControlStationException{
  12552.         try {
  12553.             String [] tmp_labels = autenticazioneToken ? ConnettoriCostanti.CREDENZIALI_CON_TOKEN_LABELS : ConnettoriCostanti.CREDENZIALI_LABELS;
  12554.             String [] tmp_values = autenticazioneToken ? ConnettoriCostanti.CREDENZIALI_CON_TOKEN_VALUES : ConnettoriCostanti.CREDENZIALI_VALUES;
  12555.            
  12556.             String [] values = new String[tmp_values.length + 1];
  12557.             String [] labels = new String[tmp_labels.length + 1];
  12558.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_TIPO_CREDENZIALI_QUALSIASI;
  12559.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_TIPO_CREDENZIALI_QUALSIASI;
  12560.             for (int i =0; i < tmp_labels.length ; i ++) {
  12561.                 labels[i+1] = tmp_labels[i];
  12562.                 values[i+1] = tmp_values[i];
  12563.             }
  12564.            
  12565.             String selectedValue = tipo != null ? tipo : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_TIPO_CREDENZIALI_QUALSIASI;
  12566.            
  12567.             String label = ServiziApplicativiCostanti.LABEL_CREDENZIALE_ACCESSO;

  12568.             this.pd.addFilter(Filtri.FILTRO_TIPO_CREDENZIALI, label, selectedValue, values, labels, postBack, this.getSize());
  12569.            
  12570.         } catch (Exception e) {
  12571.             this.logError("Exception: " + e.getMessage(), e);
  12572.             throw new DriverControlStationException(e);
  12573.         }
  12574.     }
  12575.    
  12576.     public void addFilterCredenziale(String tipoCredenziale, String credenziale) throws DriverControlStationException{
  12577.         try {
  12578.             String label = null;
  12579.             if(ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL.equals(tipoCredenziale)) {
  12580.                 label = ServiziApplicativiCostanti.LABEL_CREDENZIALE_ACCESSO_HTTPS;
  12581.             }
  12582.             else if(ConnettoriCostanti.AUTENTICAZIONE_TIPO_BASIC.equals(tipoCredenziale)) {
  12583.                 label = ServiziApplicativiCostanti.LABEL_CREDENZIALE_ACCESSO_USERNAME;
  12584.             }
  12585.             else if(ConnettoriCostanti.AUTENTICAZIONE_TIPO_PRINCIPAL.equals(tipoCredenziale)) {
  12586.                 label = ServiziApplicativiCostanti.LABEL_CREDENZIALE_ACCESSO_PRINCIPAL;
  12587.             }
  12588.             else if(ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN.equals(tipoCredenziale)) {
  12589.                 label = ServiziApplicativiCostanti.LABEL_CREDENZIALE_ACCESSO_TOKEN_CLIENT_ID;
  12590.             }
  12591.            
  12592.             if(label!=null) {
  12593.                 this.pd.addTextFilter(Filtri.FILTRO_CREDENZIALE, label, credenziale, this.getSize());
  12594.             }
  12595.            
  12596.         } catch (Exception e) {
  12597.             this.logError("Exception: " + e.getMessage(), e);
  12598.             throw new DriverControlStationException(e);
  12599.         }
  12600.     }
  12601.    
  12602.     public void addFilterCredenzialeIssuer(String tipoCredenziale, String credenziale) throws DriverControlStationException{
  12603.         try {
  12604.             if(ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL.equals(tipoCredenziale)) {
  12605.                 String label = ServiziApplicativiCostanti.LABEL_CREDENZIALE_ACCESSO_HTTPS_ISSUER;
  12606.                 this.pd.addTextFilter(Filtri.FILTRO_CREDENZIALE_ISSUER, label, credenziale, this.getSize());
  12607.             }
  12608.            
  12609.         } catch (Exception e) {
  12610.             this.logError("Exception: " + e.getMessage(), e);
  12611.             throw new DriverControlStationException(e);
  12612.         }
  12613.     }

  12614.     public List<String> getTokenPolicyGestione(boolean forcePDND, boolean forceOAuth,
  12615.             boolean addElementNonSelezionatoSeMaggioreUno,
  12616.             String checkTokenPolicyConfigurataPresente, TipoOperazione tipoOperazione) throws DriverConfigurazioneException{
  12617.         return getTokenPolicy(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN, forcePDND, forceOAuth,
  12618.                 addElementNonSelezionatoSeMaggioreUno,
  12619.                 checkTokenPolicyConfigurataPresente, tipoOperazione);
  12620.     }
  12621.     public List<String> getTokenPolicyNegoziazione(boolean forcePDND, boolean forceOAuth,
  12622.             boolean addElementNonSelezionatoSeMaggioreUno,
  12623.             String checkTokenPolicyConfigurataPresente, TipoOperazione tipoOperazione) throws DriverConfigurazioneException{
  12624.         return getTokenPolicy(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_RETRIEVE_POLICY_TOKEN, forcePDND, forceOAuth,
  12625.                 addElementNonSelezionatoSeMaggioreUno,
  12626.                 checkTokenPolicyConfigurataPresente, tipoOperazione);
  12627.     }
  12628.     private List<String> getTokenPolicy(String tipologia, boolean forcePDND, boolean forceOAuth,
  12629.             boolean addElementNonSelezionatoSeMaggioreUno,
  12630.             String checkTokenPolicyConfigurataPresente, TipoOperazione tipoOperazione) throws DriverConfigurazioneException{
  12631.         List<GenericProperties> gestorePolicyTokenList = this.confCore.gestorePolicyTokenList(null, tipologia, null);
  12632.        
  12633.         boolean retrieve = ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_RETRIEVE_POLICY_TOKEN.equals(tipologia);
  12634.         List<String> l = filterPolicy(retrieve, gestorePolicyTokenList, forcePDND, forceOAuth);
  12635.        
  12636.         List<String> returnList = new ArrayList<>();
  12637.         if(!l.isEmpty()) {
  12638.            
  12639.             boolean forceValueNonSelezionato = TipoOperazione.CHANGE.equals(tipoOperazione) &&
  12640.                     (
  12641.                             checkTokenPolicyConfigurataPresente==null
  12642.                             ||
  12643.                             StringUtils.isEmpty(checkTokenPolicyConfigurataPresente)
  12644.                             ||
  12645.                             (!l.contains(checkTokenPolicyConfigurataPresente))
  12646.                     );
  12647.             if(
  12648.                     (addElementNonSelezionatoSeMaggioreUno && l.size()>1)
  12649.                     ||
  12650.                     (forceValueNonSelezionato)
  12651.             ) {
  12652.                 returnList.add(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO);
  12653.             }
  12654.             returnList.addAll(l);
  12655.         }
  12656.         else if(addElementNonSelezionatoSeMaggioreUno) {
  12657.             returnList.add(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO);
  12658.         }
  12659.        
  12660.         return returnList;
  12661.     }
  12662.     private List<String> filterPolicy(boolean retrieve, List<GenericProperties> gestorePolicyTokenList, boolean forcePDND, boolean forceOAuth){
  12663.         List<String> policyFiltered = new ArrayList<>();
  12664.         for (int i = 0; i < gestorePolicyTokenList.size(); i++) {
  12665.             GenericProperties genericProperties = gestorePolicyTokenList.get(i);
  12666.             String nome = genericProperties.getNome();
  12667.             if(forcePDND || forceOAuth) {
  12668.                 if(retrieve) {
  12669.                     addFilteredPolicyNegoziazione(genericProperties.getPropertyList(), policyFiltered, nome, forcePDND, forceOAuth);
  12670.                 }
  12671.                 else {
  12672.                     addFilteredPolicyGestione(policyFiltered, nome, forcePDND, forceOAuth);
  12673.                 }
  12674.             }
  12675.             else {
  12676.                 policyFiltered.add(nome);
  12677.             }
  12678.         }
  12679.         return policyFiltered;
  12680.     }
  12681.     private void addFilteredPolicyGestione(List<String> policyFiltered, String nome, boolean forcePDND, boolean forceOAuth){
  12682.         if(this.connettoriCore.isPolicyGestioneTokenPDND(nome)) {
  12683.             if(forcePDND) {
  12684.                 policyFiltered.add(nome);
  12685.             }
  12686.         }
  12687.         else {
  12688.             if(forceOAuth) {
  12689.                 policyFiltered.add(nome);
  12690.             }
  12691.         }
  12692.     }
  12693.     private void addFilteredPolicyNegoziazione(List<Property> gp, List<String> policyFiltered, String nome, boolean forcePDND, boolean forceOAuth){
  12694.        
  12695.         boolean pdnd = false;
  12696.         if(gp!=null && !gp.isEmpty()) {
  12697.             for (Property p : gp) {
  12698.                 if(org.openspcoop2.pdd.core.token.Costanti.POLICY_RETRIEVE_TOKEN_MODE_PDND.equals(p.getNome())) {
  12699.                     pdnd = "true".equalsIgnoreCase(p.getValore());
  12700.                     break;
  12701.                 }
  12702.             }
  12703.         }
  12704.        
  12705.         if(pdnd) {
  12706.             if(forcePDND) {
  12707.                 policyFiltered.add(nome);
  12708.             }
  12709.         }
  12710.         else {
  12711.             if(forceOAuth) {
  12712.                 policyFiltered.add(nome);
  12713.             }
  12714.         }
  12715.     }
  12716.    
  12717.     public void addFilterCredenzialeTokenPolicy(String tokenPolicy, boolean postBack) throws DriverControlStationException{
  12718.         try {
  12719.             List<GenericProperties> gestorePolicyTokenList = this.confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN, null);
  12720.             String [] policyLabels = new String[gestorePolicyTokenList.size() + 1];
  12721.             String [] policyValues = new String[gestorePolicyTokenList.size() + 1];

  12722.             policyLabels[0] = CostantiControlStation.LABEL_PARAMETRO_TIPO_CREDENZIALI_QUALSIASI;
  12723.             policyValues[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_TIPO_CREDENZIALI_QUALSIASI;

  12724.             for (int i = 0; i < gestorePolicyTokenList.size(); i++) {
  12725.                 GenericProperties genericProperties = gestorePolicyTokenList.get(i);
  12726.                 policyLabels[(i+1)] = genericProperties.getNome();
  12727.                 policyValues[(i+1)] = genericProperties.getNome();
  12728.             }
  12729.                
  12730.             String selectedValue = tokenPolicy != null ? tokenPolicy : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_TIPO_CREDENZIALI_QUALSIASI;
  12731.            
  12732.             String label = ServiziApplicativiCostanti.LABEL_CREDENZIALE_ACCESSO_TOKEN_POLICY;

  12733.             this.pd.addFilter(Filtri.FILTRO_CREDENZIALE_TOKEN_POLICY, label, selectedValue, policyValues, policyLabels, postBack, this.getSize());
  12734.                
  12735.         } catch (Exception e) {
  12736.             this.logError("Exception: " + e.getMessage(), e);
  12737.             throw new DriverControlStationException(e);
  12738.         }
  12739.     }
  12740.    
  12741.     public void addFilterStato(String stato, boolean addStatiAllarme, boolean postBack) throws DriverControlStationException{
  12742.         try {
  12743.             String [] statiValues = new String[addStatiAllarme?5:2];
  12744.             statiValues[0] = Filtri.FILTRO_STATO_VALORE_ABILITATO;
  12745.             statiValues[1] = Filtri.FILTRO_STATO_VALORE_DISABILITATO;
  12746.             if(addStatiAllarme) {
  12747.                 statiValues[2] = Filtri.FILTRO_STATO_VALORE_OK;
  12748.                 statiValues[3] = Filtri.FILTRO_STATO_VALORE_WARNING;
  12749.                 statiValues[4] = Filtri.FILTRO_STATO_VALORE_ERROR;
  12750.             }
  12751.             String [] statiLabel = new String[addStatiAllarme?5:2];
  12752.             statiLabel[0] = Filtri.FILTRO_STATO_VALORE_ABILITATO;
  12753.             statiLabel[1] = Filtri.FILTRO_STATO_VALORE_DISABILITATO;
  12754.             if(addStatiAllarme) {
  12755.                 statiLabel[2] = Filtri.FILTRO_STATO_VALORE_OK;
  12756.                 statiLabel[3] = Filtri.FILTRO_STATO_VALORE_WARNING;
  12757.                 statiLabel[4] = Filtri.FILTRO_STATO_VALORE_ERROR;
  12758.             }
  12759.             String [] values = new String[statiValues.length + 1];
  12760.             String [] labels = new String[statiValues.length + 1];
  12761.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_STATO_QUALSIASI;
  12762.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_STATO_QUALSIASI;
  12763.             for (int i =0; i < statiValues.length ; i ++) {
  12764.                 labels[i+1] = statiLabel[i];
  12765.                 values[i+1] = statiValues[i];
  12766.             }
  12767.            
  12768.             String selectedValue = stato != null ? stato : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_STATO_QUALSIASI;
  12769.            
  12770.             String label = CostantiControlStation.LABEL_PARAMETRO_STATO;
  12771.            
  12772.             this.pd.addFilter(Filtri.FILTRO_STATO, label, selectedValue, values, labels, postBack, this.getSize());
  12773.            
  12774.         } catch (Exception e) {
  12775.             this.logError("Exception: " + e.getMessage(), e);
  12776.             throw new DriverControlStationException(e);
  12777.         }
  12778.     }
  12779.    
  12780.     public String getLabelTipoRisorsaPolicyAttiva(TipoRisorsaPolicyAttiva tipo) {
  12781.         return this.getLabelTipoRisorsaPolicyAttiva(tipo.getValue());
  12782.     }
  12783.     public String getLabelTipoRisorsaPolicyAttiva(String tipo) {
  12784.         String labelRisorsaPolicyAttiva = null;
  12785.         for (int j = 0; j < CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_RISORSE_VALORI.length; j++) {
  12786.             if(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_RISORSE_VALORI[j].equals(tipo)) {
  12787.                 labelRisorsaPolicyAttiva = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_RISORSE_LABELS[j];
  12788.                 break;
  12789.             }
  12790.         }
  12791.         return labelRisorsaPolicyAttiva;
  12792.     }
  12793.    
  12794.     public void addFilterTipoRisorsaPolicy(List<TipoRisorsaPolicyAttiva> listaTipoRisorsa, String tipoRisorsaPolicy, boolean postBack) throws DriverControlStationException{
  12795.         try {
  12796.             if(listaTipoRisorsa!=null && listaTipoRisorsa.size()>1) {
  12797.                 String selectedValue = null;
  12798.                 if(tipoRisorsaPolicy != null) {
  12799.                     selectedValue = tipoRisorsaPolicy;
  12800.                 }
  12801.                 else {
  12802.                     selectedValue =  CostantiControlStation.DEFAULT_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA_TIPO_VALUE.getValue();
  12803.                 }
  12804.    
  12805.                 List<String> values = new ArrayList<>();
  12806.                 List<String> labels = new ArrayList<>();
  12807.                 for (int j = 0; j < CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_RISORSE_VALORI.length; j++) {
  12808.                     TipoRisorsaPolicyAttiva check = TipoRisorsaPolicyAttiva.toEnumConstant(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_TIPI_RISORSE_VALORI[j]);
  12809.                     if(listaTipoRisorsa.contains(check)) {
  12810.                         values.add(check.getValue());
  12811.                         labels.add(this.getLabelTipoRisorsaPolicyAttiva(check));
  12812.                     }
  12813.                 }
  12814.                
  12815.                 this.pd.addFilter(Filtri.FILTRO_TIPO_RISORSA_POLICY, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_POLICY_RISORSA_TIPO,
  12816.                         selectedValue,
  12817.                         values.toArray(new String[1]),
  12818.                         labels.toArray(new String[1]),
  12819.                         postBack, this.getSize());
  12820.             }
  12821.            
  12822.         } catch (Exception e) {
  12823.             this.logError("Exception: " + e.getMessage(), e);
  12824.             throw new DriverControlStationException(e);
  12825.         }
  12826.     }
  12827.     public void removeFilterTipoRisorsaPolicy() throws DriverControlStationException{
  12828.         try {
  12829.             this.pd.removeFilter(Filtri.FILTRO_TIPO_RISORSA_POLICY);
  12830.         } catch (Exception e) {
  12831.             this.logError("Exception: " + e.getMessage(), e);
  12832.             throw new DriverControlStationException(e);
  12833.         }
  12834.     }
  12835.    
  12836.     public void addFilterTipoTokenPolicy(String tipo, boolean postBack,
  12837.             List<String> nomiConfigurazioniPolicyGestioneToken, List<String> labelConfigurazioniPolicyGestioneToken) throws DriverControlStationException{
  12838.         try {
  12839.             if(nomiConfigurazioniPolicyGestioneToken!=null) {
  12840.                 int length = nomiConfigurazioniPolicyGestioneToken.size() +1;
  12841.                 String [] values = new String[length];
  12842.                 String [] labels = new String[length];
  12843.                 labels[0] = CostantiControlStation.LABEL_PARAMETRO_TIPO_TOKEN_POLICY_QUALSIASI;
  12844.                 values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_TIPO_TOKEN_POLICY_QUALSIASI;
  12845.                 if(nomiConfigurazioniPolicyGestioneToken!=null && nomiConfigurazioniPolicyGestioneToken.size()>0) {
  12846.                     for (int i =0; i < nomiConfigurazioniPolicyGestioneToken.size() ; i ++) {
  12847.                         labels[i+1] = labelConfigurazioniPolicyGestioneToken.get(i);
  12848.                         values[i+1] = nomiConfigurazioniPolicyGestioneToken.get(i);
  12849.                     }
  12850.                 }
  12851.                
  12852.                 this.pd.addFilter(Filtri.FILTRO_TIPO_TOKEN_POLICY, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPO, tipo, values, labels, postBack, this.getSize());
  12853.             }
  12854.         } catch (Exception e) {
  12855.             this.logError("Exception: " + e.getMessage(), e);
  12856.             throw new DriverControlStationException(e);
  12857.         }
  12858.     }
  12859.    
  12860.    
  12861.    
  12862.     public void setFilterRuoloServizioApplicativo(ISearch ricerca, int idLista) throws DriverControlStationException{
  12863.         if(this.core.isApplicativiServerEnabled(this)) {
  12864.             if(Liste.SERVIZIO_APPLICATIVO==idLista || Liste.SERVIZI_APPLICATIVI_BY_SOGGETTO==idLista) {
  12865.                 ricerca.addFilter(idLista, Filtri.FILTRO_TIPO_SERVIZIO_APPLICATIVO, CostantiConfigurazione.CLIENT_OR_SERVER);
  12866.             }
  12867.         } else {
  12868.             if( (this.isModalitaCompleta()==false) &&
  12869.                     (Liste.SERVIZIO_APPLICATIVO==idLista || Liste.SERVIZI_APPLICATIVI_BY_SOGGETTO==idLista)) {
  12870.                 ricerca.addFilter(idLista, Filtri.FILTRO_RUOLO_SERVIZIO_APPLICATIVO, Filtri.VALUE_FILTRO_RUOLO_SERVIZIO_APPLICATIVO_FRUITORE);
  12871.             }
  12872.         }
  12873.     }
  12874.    
  12875.     public void setFilterSelectedProtocol(ISearch ricerca, int idLista) throws DriverControlStationException{
  12876.         List<String> protocolli = null;
  12877.         try {
  12878.             if(this.core.isUsedByApi()) {
  12879.                 protocolli = ProtocolFactoryManager.getInstance().getProtocolNamesAsList();
  12880.             }else {
  12881.                 protocolli = this.core.getProtocolli(this.request, this.session);
  12882.             }
  12883.         }catch(Exception e) {
  12884.             throw new DriverControlStationException(e.getMessage(),e);
  12885.         }
  12886.         if(protocolli!=null && protocolli.size()>0) {
  12887.             if(protocolli.size()==1) {
  12888.                 ricerca.addFilter(idLista, Filtri.FILTRO_PROTOCOLLO, protocolli.get(0));
  12889.             }
  12890.             else {
  12891.                 ricerca.addFilter(idLista, Filtri.FILTRO_PROTOCOLLI, Filtri.convertToString(protocolli));
  12892.             }
  12893.         }      
  12894.     }
  12895.     public String addFilterProtocol(ISearch ricerca, int idLista) throws DriverControlStationException{
  12896.         return this.addFilterProtocol(ricerca, idLista, false);
  12897.     }
  12898.     public String addFilterProtocol(ISearch ricerca, int idLista, boolean postBack) throws DriverControlStationException{
  12899.         List<String> protocolli = null;
  12900.         try {
  12901.             protocolli = this.core.getProtocolli(this.request, this.session);
  12902.         }catch(Exception e) {
  12903.             throw new DriverControlStationException(e.getMessage(),e);
  12904.         }
  12905.         return _addFilterProtocol(ricerca, idLista, protocolli, postBack);
  12906.     }
  12907.    
  12908.     public String addFilterProtocol(ISearch ricerca, int idLista,List<String> protocolli) throws DriverControlStationException{
  12909.         return addFilterProtocol(ricerca, idLista, protocolli, false);
  12910.     }
  12911.     public String addFilterProtocol(ISearch ricerca, int idLista,List<String> protocolli, boolean postBack) throws DriverControlStationException{
  12912.         return _addFilterProtocol(ricerca, idLista, protocolli, postBack);
  12913.     }

  12914.     private String _addFilterProtocol(ISearch ricerca, int idLista, List<String> protocolli, boolean postBack) throws DriverControlStationException {
  12915.         if(protocolli!=null && protocolli.size()>1) {
  12916.             String filterProtocol = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_PROTOCOLLO);
  12917.             this.addFilterProtocollo(protocolli, filterProtocol, postBack);
  12918.             return filterProtocol;
  12919.         }
  12920.         return null;
  12921.     }
  12922.     private void addFilterProtocollo(List<String> protocolli, String protocolloSelected,boolean postBack) throws DriverControlStationException{
  12923.         try {
  12924.            
  12925.             if(protocolli!=null && protocolli.size()>1) {

  12926.                 String [] values = new String[protocolli.size() + 1];
  12927.                 String [] labels = new String[protocolli.size() + 1];
  12928.                 labels[0] = CostantiControlStation.LABEL_PARAMETRO_PROTOCOLLO_QUALSIASI;
  12929.                 values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PROTOCOLLO_QUALSIASI;
  12930.                 for (int i =0; i < protocolli.size() ; i ++) {
  12931.                     String protocollo = protocolli.get(i);
  12932.                     labels[i+1] = getLabelProtocollo(protocollo);
  12933.                     values[i+1] = protocollo;
  12934.                 }
  12935.                
  12936.                 String selectedValue = protocolloSelected != null ? protocolloSelected : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PROTOCOLLO_QUALSIASI;
  12937.                
  12938.                 this.pd.addFilter(Filtri.FILTRO_PROTOCOLLO, CostantiControlStation.LABEL_PARAMETRO_PROTOCOLLO, selectedValue, values, labels, postBack, this.getSize());
  12939.                
  12940.             }
  12941.                
  12942.         } catch (Exception e) {
  12943.             this.logError("Exception: " + e.getMessage(), e);
  12944.             throw new DriverControlStationException(e);
  12945.         }
  12946.     }
  12947.    
  12948.     public void addFilterSoggetto(String soggetto, String protocollo, boolean soloSoggettiOperativi, boolean postBack) throws DriverControlStationException{
  12949.         try {
  12950.             String userLogin = ServletUtils.getUserLoginFromSession(this.session);
  12951.            
  12952.             ConsoleSearch searchSoggetti = new ConsoleSearch(true);
  12953.             searchSoggetti.addFilter(Liste.SOGGETTI, Filtri.FILTRO_PROTOCOLLO, protocollo);
  12954.             if(soloSoggettiOperativi) {
  12955.                 searchSoggetti.addFilter(Liste.SOGGETTI, Filtri.FILTRO_DOMINIO, SoggettiCostanti.SOGGETTO_DOMINIO_OPERATIVO_VALUE);
  12956.             }
  12957.             List<org.openspcoop2.core.registry.Soggetto> listSoggetti = null;
  12958.             if(this.apsCore.isVisioneOggettiGlobale(userLogin)){
  12959.                 listSoggetti = this.soggettiCore.soggettiRegistroList(null, searchSoggetti);
  12960.             }else{
  12961.                 listSoggetti = this.soggettiCore.soggettiRegistroList(userLogin, searchSoggetti);
  12962.             }
  12963.            
  12964.             int length = 1;
  12965.             if(listSoggetti!=null && listSoggetti.size()>0) {
  12966.                 length+=listSoggetti.size();
  12967.             }
  12968.             String [] values = new String[length];
  12969.             String [] labels = new String[length];
  12970.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  12971.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  12972.             if(listSoggetti!=null && listSoggetti.size()>0) {
  12973.                 for (int i =0; i < listSoggetti.size() ; i ++) {
  12974.                     IDSoggetto idSoggetto = new IDSoggetto(listSoggetti.get(i).getTipo(), listSoggetti.get(i).getNome());
  12975.                     labels[i+1] = this.getLabelNomeSoggetto(idSoggetto);
  12976.                     values[i+1] = idSoggetto.toString();
  12977.                 }
  12978.             }
  12979.            
  12980.             this.pd.addFilter(Filtri.FILTRO_SOGGETTO, SoggettiCostanti.LABEL_SOGGETTO, soggetto, values, labels, postBack, this.getSize());
  12981.            
  12982.         } catch (Exception e) {
  12983.             this.logError("Exception: " + e.getMessage(), e);
  12984.             throw new DriverControlStationException(e);
  12985.         }
  12986.     }
  12987.    
  12988.     public void addFilterSoggettoErogatoreStringaLiberaContains(ISearch ricerca, int idLista) throws DriverControlStationException{
  12989.         try {
  12990.             String soggettoErogatoreValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_SOGGETTO_EROGATORE_CONTAINS);
  12991.                
  12992.             String filterLabel = SoggettiCostanti.LABEL_SOGGETTO_EROGATORE;
  12993.            
  12994.             this.pd.addTextFilter(Filtri.FILTRO_SOGGETTO_EROGATORE_CONTAINS, filterLabel, soggettoErogatoreValue, this.getSize());
  12995.            
  12996.         } catch (Exception e) {
  12997.             this.logError("Exception: " + e.getMessage(), e);
  12998.             throw new DriverControlStationException(e);
  12999.         }
  13000.     }
  13001.    
  13002.     public void addFilterSubtitle(String subtitleName, String subtitleLabel, boolean visualizzaSottosezioneAperta) throws DriverControlStationException{
  13003.         try {
  13004.             this.pd.addSubtitleFilter(subtitleName, subtitleLabel, visualizzaSottosezioneAperta);
  13005.         }catch(Exception e) {
  13006.             throw new DriverControlStationException(e.getMessage(),e);
  13007.         }
  13008.     }
  13009.    
  13010.     public void impostaAperturaSubtitle(String subtitleName) throws DriverControlStationException{
  13011.         try {
  13012.             this.pd.impostaAperturaSubtitle(subtitleName, null, this.getPostBackElementName());
  13013.         }catch(Exception e) {
  13014.             throw new DriverControlStationException(e.getMessage(),e);
  13015.         }
  13016.     }
  13017.    
  13018.     public void impostaAperturaSubtitle(String subtitleName, boolean visualizzaSottosezioneAperta) throws DriverControlStationException{
  13019.         try {
  13020.             this.pd.impostaAperturaSubtitle(subtitleName, visualizzaSottosezioneAperta, this.getPostBackElementName());
  13021.         }catch(Exception e) {
  13022.             throw new DriverControlStationException(e.getMessage(),e);
  13023.         }
  13024.     }
  13025.    
  13026.     public void addFilterHidden(String name, String value) throws DriverControlStationException{
  13027.         try {
  13028.             this.pd.addHiddenFilter(name, value, this.getSize());
  13029.         }catch(Exception e) {
  13030.             throw new DriverControlStationException(e.getMessage(),e);
  13031.         }
  13032.     }
  13033.    
  13034.    
  13035.    
  13036.     public void addFilterStatoImplementazioneAPI(ISearch ricerca, int idLista) throws DriverControlStationException{
  13037.         try {
  13038.            
  13039.             List<String> statoList = new ArrayList<>();
  13040.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_STATO_VALORE_ABILITATO);
  13041.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_STATO_VALORE_DISABILITATO);
  13042.            
  13043.             int length = statoList.size() + 1;
  13044.            
  13045.             String [] values = new String[length];
  13046.             String [] labels = new String[length];
  13047.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_STATO_QUALSIASI;
  13048.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_STATO_QUALSIASI;
  13049.             for (int i =0; i < statoList.size() ; i ++) {
  13050.                 labels[i+1] = statoList.get(i);
  13051.                 values[i+1] = statoList.get(i);
  13052.             }
  13053.            
  13054.             String statoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_STATO);
  13055.            
  13056.             this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_STATO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_STATO, statoValue, values, labels, false, this.getSize());
  13057.            
  13058.         } catch (Exception e) {
  13059.             this.logError("Exception: " + e.getMessage(), e);
  13060.             throw new DriverControlStationException(e);
  13061.         }
  13062.     }
  13063.    
  13064.    
  13065.     public void addFilterTipoAutenticazioneToken(ISearch ricerca, int idLista) throws DriverControlStationException{
  13066.         try {
  13067.            
  13068.             // controllo esistenza token policy
  13069.             List<GenericProperties> gestorePolicyTokenList = this.confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN, null);
  13070.        
  13071.             if(gestorePolicyTokenList.size() > 0) {
  13072.                 int length = gestorePolicyTokenList.size() + 1;
  13073.                
  13074.                 String [] values = new String[length];
  13075.                 String [] labels = new String[length];
  13076.                 labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_AUTENTICAZIONE_TOKEN_QUALSIASI;
  13077.                 values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_AUTENTICAZIONE_TOKEN_QUALSIASI;
  13078.            
  13079.                 for (int i = 0; i < gestorePolicyTokenList.size(); i++) {
  13080.                     GenericProperties genericProperties = gestorePolicyTokenList.get(i);
  13081.                     labels[(i+1)] = genericProperties.getNome();
  13082.                     values[(i+1)] = genericProperties.getNome();
  13083.                 }
  13084.                
  13085.                 String tokenPolicyValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_AUTENTICAZIONE_TOKEN_TIPO);
  13086.                
  13087.                 this.pd.addFilter(Filtri.FILTRO_AUTENTICAZIONE_TOKEN_TIPO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_TIPO_AUTENTICAZIONE_TOKEN, tokenPolicyValue, values, labels, false, this.getSize());
  13088.             }
  13089.            
  13090.         } catch (Exception e) {
  13091.             this.logError("Exception: " + e.getMessage(), e);
  13092.             throw new DriverControlStationException(e);
  13093.         }
  13094.     }
  13095.    
  13096.     public String addFilterTipoAutenticazioneTrasporto(ISearch ricerca, int idLista, boolean postBack, boolean modiErogazione, Boolean confPersParam) throws DriverControlStationException{
  13097.         String tipoAutenticazioneValue = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_AUTENTICAZIONE_TRASPORTO_QUALSIASI;
  13098.         try {
  13099.            
  13100.             List<String> autenticazioneValues = TipoAutenticazione.getValues();
  13101.             List<String> autenticazioneLabels = TipoAutenticazione.getLabels();
  13102.            
  13103.             boolean confPers = confPersParam!=null && confPersParam.booleanValue();
  13104.            
  13105.             int length = autenticazioneValues.size() + 1;
  13106.             if (confPers){
  13107.                 length++;
  13108.             }
  13109.            
  13110.             String [] values = new String[length];
  13111.             String [] labels = new String[length];
  13112.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  13113.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  13114.             int i =0;
  13115.             for (; i < autenticazioneValues.size() ; i ++) {
  13116.                 labels[i+1] = autenticazioneLabels.get(i);
  13117.                 values[i+1] = autenticazioneValues.get(i);
  13118.             }
  13119.             if (confPers){
  13120.                 values[i+1] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM;
  13121.                 labels[i+1] = CostantiControlStation.DEFAULT_LABEL_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM;
  13122.             }
  13123.            
  13124.             tipoAutenticazioneValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_AUTENTICAZIONE_TRASPORTO_TIPO);
  13125.            
  13126.             String label = modiErogazione ? CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_TIPO_AUTENTICAZIONE_CANALE : CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_TIPO_AUTENTICAZIONE_TRASPORTO;
  13127.            
  13128.             this.pd.addFilter(Filtri.FILTRO_AUTENTICAZIONE_TRASPORTO_TIPO, label, tipoAutenticazioneValue, values, labels, postBack, this.getSize());
  13129.            
  13130.         } catch (Exception e) {
  13131.             this.logError("Exception: " + e.getMessage(), e);
  13132.             throw new DriverControlStationException(e);
  13133.         }
  13134.        
  13135.         return tipoAutenticazioneValue;
  13136.     }
  13137.    
  13138.     public void addFilterTipoAutenticazioneTrasportoPlugin(ISearch ricerca, int idLista, String tipoAutenticazione, boolean fruizioni) throws DriverControlStationException{
  13139.         try {
  13140.             if(tipoAutenticazione != null && tipoAutenticazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM)) {
  13141.                
  13142.                 String pluginValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_AUTENTICAZIONE_TRASPORTO_TIPO_PLUGIN);
  13143.                 String pluginLabel = "";
  13144.            
  13145.                 List<DataElement> dati = new ArrayList<>();
  13146.                
  13147.                 String tipoAutenticazioneCustom = fruizioni ? Filtri.FILTRO_RUOLO_VALORE_FRUIZIONE : Filtri.FILTRO_RUOLO_VALORE_EROGAZIONE;
  13148.                 this.addCustomFieldSearchForm(TipoPlugin.AUTENTICAZIONE,
  13149.                         tipoAutenticazioneCustom,
  13150.                         null,
  13151.                         Filtri.FILTRO_AUTENTICAZIONE_TRASPORTO_TIPO,
  13152.                         Filtri.FILTRO_AUTENTICAZIONE_TRASPORTO_TIPO_PLUGIN,
  13153.                         pluginLabel,
  13154.                         pluginValue, false, dati,
  13155.                         false);        
  13156.                
  13157.                 // dentro dati c'e' solo un elemento
  13158.                 DataElement dataElement = dati.get(0);
  13159.                
  13160.                 if(dataElement.getValues() != null && dataElement.getValues().length > 0) {
  13161.                     this.pd.addFilter(Filtri.FILTRO_AUTENTICAZIONE_TRASPORTO_TIPO_PLUGIN, pluginLabel, pluginValue, dataElement.getValues(), dataElement.getLabels(), false, this.getSize());
  13162.                 }
  13163.             }
  13164.         } catch (Exception e) {
  13165.             this.logError("Exception: " + e.getMessage(), e);
  13166.             throw new DriverControlStationException(e);
  13167.         }
  13168.     }
  13169.    
  13170.     public void addFilterConfigurazioneRateLimiting(ISearch ricerca, int idLista) throws DriverControlStationException{
  13171.         try {
  13172.            
  13173.             List<String> statoList = new ArrayList<>();
  13174.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_RATE_LIMITING_STATO_VALORE_ABILITATO);
  13175.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_RATE_LIMITING_STATO_VALORE_DISABILITATO);
  13176.            
  13177.             int length = statoList.size() + 1;
  13178.            
  13179.             String [] values = new String[length];
  13180.             String [] labels = new String[length];
  13181.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RATE_LIMITING_STATO_QUALSIASI;
  13182.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_RATE_LIMITING_STATO_QUALSIASI;
  13183.             for (int i =0; i < statoList.size() ; i ++) {
  13184.                 labels[i+1] = statoList.get(i);
  13185.                 values[i+1] = statoList.get(i);
  13186.             }
  13187.            
  13188.             String statoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_RATE_LIMITING_STATO);
  13189.            
  13190.             this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_RATE_LIMITING_STATO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_RATE_LIMITING_STATO, statoValue, values, labels, false, this.getSize());
  13191.            
  13192.         } catch (Exception e) {
  13193.             this.logError("Exception: " + e.getMessage(), e);
  13194.             throw new DriverControlStationException(e);
  13195.         }
  13196.     }
  13197.    
  13198.     public void addFilterConfigurazioneValidazione(ISearch ricerca, int idLista) throws DriverControlStationException{
  13199.         try {
  13200.            
  13201.             List<String> statoList = new ArrayList<>();
  13202.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_VALIDAZIONE_STATO_VALORE_ABILITATO);
  13203.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_VALIDAZIONE_STATO_VALORE_DISABILITATO);
  13204.            
  13205.             int length = statoList.size() + 1;
  13206.            
  13207.             String [] values = new String[length];
  13208.             String [] labels = new String[length];
  13209.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_VALIDAZIONE_STATO_QUALSIASI;
  13210.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_VALIDAZIONE_STATO_QUALSIASI;
  13211.             for (int i =0; i < statoList.size() ; i ++) {
  13212.                 labels[i+1] = statoList.get(i);
  13213.                 values[i+1] = statoList.get(i);
  13214.             }
  13215.            
  13216.             String statoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_VALIDAZIONE_STATO);
  13217.            
  13218.             this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_VALIDAZIONE_STATO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_VALIDAZIONE_STATO, statoValue, values, labels, false, this.getSize());
  13219.            
  13220.         } catch (Exception e) {
  13221.             this.logError("Exception: " + e.getMessage(), e);
  13222.             throw new DriverControlStationException(e);
  13223.         }
  13224.     }
  13225.    
  13226.     public void addFilterConfigurazioneCacheRisposta(ISearch ricerca, int idLista) throws DriverControlStationException{
  13227.         try {
  13228.            
  13229.             List<String> statoList = new ArrayList<>();
  13230.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_CACHE_RISPOSTA_STATO_VALORE_ABILITATO);
  13231.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_CACHE_RISPOSTA_STATO_VALORE_DISABILITATO);
  13232.            
  13233.             int length = statoList.size() + 1;
  13234.            
  13235.             String [] values = new String[length];
  13236.             String [] labels = new String[length];
  13237.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CACHE_RISPOSTA_STATO_QUALSIASI;
  13238.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CACHE_RISPOSTA_STATO_QUALSIASI;
  13239.             for (int i =0; i < statoList.size() ; i ++) {
  13240.                 labels[i+1] = statoList.get(i);
  13241.                 values[i+1] = statoList.get(i);
  13242.             }
  13243.            
  13244.             String statoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_CACHE_RISPOSTA_STATO);
  13245.            
  13246.             this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_CACHE_RISPOSTA_STATO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_CACHE_RISPOSTA_STATO, statoValue, values, labels, false, this.getSize());
  13247.            
  13248.         } catch (Exception e) {
  13249.             this.logError("Exception: " + e.getMessage(), e);
  13250.             throw new DriverControlStationException(e);
  13251.         }
  13252.     }
  13253.    
  13254.     public void addFilterConfigurazioneMessageSecurity(ISearch ricerca, int idLista) throws DriverControlStationException{
  13255.         try {
  13256.            
  13257.             List<String> statoList = new ArrayList<>();
  13258.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_MESSAGE_SECURITY_VALORE_ABILITATO);
  13259.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_MESSAGE_SECURITY_STATO_VALORE_ABILITATO_RICHIESTA);
  13260.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_MESSAGE_SECURITY_STATO_VALORE_ABILITATO_RISPOSTA);
  13261.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_MESSAGE_SECURITY_VALORE_DISABILITATO);
  13262.            
  13263.             int length = statoList.size() + 1;
  13264.            
  13265.             String [] values = new String[length];
  13266.             String [] labels = new String[length];
  13267.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_MESSAGE_SECURITY_STATO_QUALSIASI;
  13268.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_MESSAGE_SECURITY_STATO_QUALSIASI;
  13269.             for (int i =0; i < statoList.size() ; i ++) {
  13270.                 labels[i+1] = statoList.get(i);
  13271.                 values[i+1] = statoList.get(i);
  13272.             }
  13273.            
  13274.             String statoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_MESSAGE_SECURITY_STATO);
  13275.            
  13276.             this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_MESSAGE_SECURITY_STATO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_MESSAGE_SECURITY_STATO, statoValue, values, labels, false, this.getSize());
  13277.            
  13278.         } catch (Exception e) {
  13279.             this.logError("Exception: " + e.getMessage(), e);
  13280.             throw new DriverControlStationException(e);
  13281.         }
  13282.     }
  13283.    
  13284.     public void addFilterConfigurazioneMTOM(ISearch ricerca, int idLista, String filterTipoAccordo) throws DriverControlStationException{
  13285.         try {
  13286.            
  13287.             if(filterTipoAccordo==null ||
  13288.                     CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_QUALSIASI.equals(filterTipoAccordo) ||
  13289.                     CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_SOAP.toLowerCase().equals(filterTipoAccordo)) {
  13290.                
  13291.                 List<String> statoList = new ArrayList<>();
  13292.                 statoList.add(Filtri.FILTRO_CONFIGURAZIONE_MTOM_VALORE_ABILITATO);
  13293.                 statoList.add(Filtri.FILTRO_CONFIGURAZIONE_MTOM_STATO_VALORE_ABILITATO_RICHIESTA);
  13294.                 statoList.add(Filtri.FILTRO_CONFIGURAZIONE_MTOM_STATO_VALORE_ABILITATO_RISPOSTA);
  13295.                 statoList.add(Filtri.FILTRO_CONFIGURAZIONE_MTOM_VALORE_DISABILITATO);
  13296.                
  13297.                 int length = statoList.size() + 1;
  13298.                
  13299.                 String [] values = new String[length];
  13300.                 String [] labels = new String[length];
  13301.                 labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_MTOM_STATO_QUALSIASI;
  13302.                 values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_MTOM_STATO_QUALSIASI;
  13303.                 for (int i =0; i < statoList.size() ; i ++) {
  13304.                     labels[i+1] = statoList.get(i);
  13305.                     values[i+1] = statoList.get(i);
  13306.                 }
  13307.                
  13308.                 String statoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_MTOM_STATO);
  13309.                
  13310.                 this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_MTOM_STATO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_MTOM_STATO, statoValue, values, labels, false, this.getSize());
  13311.             }
  13312.            
  13313.         } catch (Exception e) {
  13314.             this.logError("Exception: " + e.getMessage(), e);
  13315.             throw new DriverControlStationException(e);
  13316.         }
  13317.     }
  13318.    
  13319.     public void addFilterConfigurazioneTrasformazione(ISearch ricerca, int idLista) throws DriverControlStationException{
  13320.         try {
  13321.            
  13322.             List<String> statoList = new ArrayList<>();
  13323.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_TRASFORMAZIONE_STATO_VALORE_ABILITATO);
  13324.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_TRASFORMAZIONE_STATO_VALORE_DISABILITATO);
  13325.            
  13326.             int length = statoList.size() + 1;
  13327.            
  13328.             String [] values = new String[length];
  13329.             String [] labels = new String[length];
  13330.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONE_STATO_QUALSIASI;
  13331.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONE_STATO_QUALSIASI;
  13332.             for (int i =0; i < statoList.size() ; i ++) {
  13333.                 labels[i+1] = statoList.get(i);
  13334.                 values[i+1] = statoList.get(i);
  13335.             }
  13336.            
  13337.             String statoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_TRASFORMAZIONE_STATO);
  13338.            
  13339.             this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_TRASFORMAZIONE_STATO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_TRASFORMAZIONE_STATO, statoValue, values, labels, false, this.getSize());
  13340.            
  13341.         } catch (Exception e) {
  13342.             this.logError("Exception: " + e.getMessage(), e);
  13343.             throw new DriverControlStationException(e);
  13344.         }
  13345.     }
  13346.    
  13347.     public String addFilterConfigurazioneTransazioni(ISearch ricerca, int idLista, boolean postBack) throws DriverControlStationException{
  13348.         String configurazioneTransazioniTipoValue = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRANSAZIONI_QUALSIASI;
  13349.         try {
  13350.             List<String> tipoList = new ArrayList<>();
  13351.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_TRANSAZIONI_VALORE_DEFAULT);
  13352.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_TRANSAZIONI_VALORE_RIDEFINITO_ABILITATO_DATABASE_O_FILETRACE);
  13353.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_TRANSAZIONI_VALORE_RIDEFINITO_ABILITATO_SOLO_DATABASE);
  13354.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_TRANSAZIONI_VALORE_RIDEFINITO_ABILITATO_SOLO_FILETRACE);
  13355.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_TRANSAZIONI_VALORE_RIDEFINITO_ABILITATO_DATABASE_E_FILETRACE);
  13356.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_TRANSAZIONI_VALORE_RIDEFINITO_DISABILITATO);
  13357.            
  13358.            
  13359.             int length = tipoList.size() + 1;
  13360.            
  13361.             String [] values = new String[length];
  13362.             String [] labels = new String[length];
  13363.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRANSAZIONI_QUALSIASI;
  13364.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRANSAZIONI_QUALSIASI;
  13365.             for (int i =0; i < tipoList.size() ; i ++) {
  13366.                 labels[i+1] = tipoList.get(i);
  13367.                 values[i+1] = tipoList.get(i);
  13368.             }
  13369.            
  13370.             configurazioneTransazioniTipoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_TRANSAZIONI);
  13371.            
  13372.             this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_TRANSAZIONI, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_TRANSAZIONI, configurazioneTransazioniTipoValue, values, labels, postBack, this.getSize());
  13373.            
  13374.         } catch (Exception e) {
  13375.             this.logError("Exception: " + e.getMessage(), e);
  13376.             throw new DriverControlStationException(e);
  13377.         }
  13378.        
  13379.         return configurazioneTransazioniTipoValue;
  13380.     }
  13381.    
  13382.     public void addFilterConfigurazioneCorrelazioneApplicativa(ISearch ricerca, int idLista) throws DriverControlStationException{
  13383.         try {
  13384.            
  13385.             List<String> statoList = new ArrayList<>();
  13386.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_VALORE_ABILITATO);
  13387.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_STATO_VALORE_ABILITATO_RICHIESTA);
  13388.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_STATO_VALORE_ABILITATO_RISPOSTA);
  13389.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_VALORE_DISABILITATO);
  13390.            
  13391.             int length = statoList.size() + 1;
  13392.            
  13393.             String [] values = new String[length];
  13394.             String [] labels = new String[length];
  13395.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_STATO_QUALSIASI;
  13396.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_STATO_QUALSIASI;
  13397.             for (int i =0; i < statoList.size() ; i ++) {
  13398.                 labels[i+1] = statoList.get(i);
  13399.                 values[i+1] = statoList.get(i);
  13400.             }
  13401.            
  13402.             String statoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_STATO);
  13403.            
  13404.             this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_STATO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_STATO, statoValue, values, labels, false, this.getSize());
  13405.            
  13406.         } catch (Exception e) {
  13407.             this.logError("Exception: " + e.getMessage(), e);
  13408.             throw new DriverControlStationException(e);
  13409.         }
  13410.     }
  13411.    
  13412.     public String addFilterConfigurazioneTipoDump(ISearch ricerca, int idLista, boolean postBack) throws DriverControlStationException{
  13413.         String configurazioneDumpTipoValue = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_DUMP_QUALSIASI;
  13414.         try {
  13415.             List<String> tipoList = new ArrayList<>();
  13416.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_DEFAULT);
  13417.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO);
  13418.            
  13419.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_RICHIESTA);
  13420.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_RISPOSTA);
  13421.            
  13422.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_RICHIESTA_INGRESSO);
  13423.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_RICHIESTA_USCITA);
  13424.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_RISPOSTA_INGRESSO);
  13425.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_RISPOSTA_USCITA);
  13426.            
  13427.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_SOLO_HEADER);
  13428.            
  13429.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_SOLO_HEADER_RICHIESTA);
  13430.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_SOLO_HEADER_RISPOSTA);
  13431.            
  13432.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_SOLO_HEADER_RICHIESTA_INGRESSO);
  13433.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_SOLO_HEADER_RICHIESTA_USCITA);

  13434.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_SOLO_HEADER_RISPOSTA_INGRESSO);
  13435.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_ABILITATO_SOLO_HEADER_RISPOSTA_USCITA);

  13436.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_DISABILITATO);
  13437.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_DISABILITATO_RICHIESTA);
  13438.             tipoList.add(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO_VALORE_RIDEFINITO_DISABILITATO_RISPOSTA);
  13439.            
  13440.            
  13441.             int length = tipoList.size() + 1;
  13442.            
  13443.             String [] values = new String[length];
  13444.             String [] labels = new String[length];
  13445.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TIPO_DUMP_QUALSIASI;
  13446.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TIPO_DUMP_QUALSIASI;
  13447.             for (int i =0; i < tipoList.size() ; i ++) {
  13448.                 labels[i+1] = tipoList.get(i);
  13449.                 values[i+1] = tipoList.get(i);
  13450.             }
  13451.            
  13452.             configurazioneDumpTipoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO);
  13453.            
  13454.             this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_DUMP_TIPO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_TIPO_DUMP, configurazioneDumpTipoValue, values, labels, postBack, this.getSize());
  13455.            
  13456.         } catch (Exception e) {
  13457.             this.logError("Exception: " + e.getMessage(), e);
  13458.             throw new DriverControlStationException(e);
  13459.         }
  13460.        
  13461.         return configurazioneDumpTipoValue;
  13462.     }
  13463.    
  13464.     public String addFilterConfigurazioneCORS(ISearch ricerca, int idLista) throws DriverControlStationException{
  13465.         try {
  13466.            
  13467.             List<String> statoList = new ArrayList<>();
  13468.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_CORS_TIPO_VALORE_DEFAULT);
  13469.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_CORS_TIPO_VALORE_RIDEFINITO_ABILITATO);
  13470.             statoList.add(Filtri.FILTRO_CONFIGURAZIONE_CORS_TIPO_VALORE_RIDEFINITO_DISABILITATO);
  13471.            
  13472.             int length = statoList.size() + 1;
  13473.            
  13474.             String [] values = new String[length];
  13475.             String [] labels = new String[length];
  13476.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_STATO_QUALSIASI;
  13477.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CORS_STATO_QUALSIASI;
  13478.             for (int i =0; i < statoList.size() ; i ++) {
  13479.                 labels[i+1] = statoList.get(i);
  13480.                 values[i+1] = statoList.get(i);
  13481.             }
  13482.            
  13483.             String statoValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_CORS_TIPO);
  13484.            
  13485.             this.pd.addFilter(Filtri.FILTRO_CONFIGURAZIONE_CORS_TIPO, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_CORS_STATO, statoValue, values, labels, true, this.getSize());
  13486.            
  13487.             return statoValue;
  13488.            
  13489.         } catch (Exception e) {
  13490.             this.logError("Exception: " + e.getMessage(), e);
  13491.             throw new DriverControlStationException(e);
  13492.         }
  13493.     }
  13494.    
  13495.     public void addFilterConfigurazioneCORSOrigin(ISearch ricerca, int idLista, String gestioneCORS) throws DriverControlStationException{
  13496.         try {
  13497.             if(gestioneCORS != null && Filtri.FILTRO_CONFIGURAZIONE_CORS_TIPO_VALORE_RIDEFINITO_ABILITATO.equals(gestioneCORS)) {
  13498.            
  13499.                 String corsOriginValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONFIGURAZIONE_CORS_ORIGIN);
  13500.                
  13501.                 this.pd.addTextFilter(Filtri.FILTRO_CONFIGURAZIONE_CORS_ORIGIN, CostantiControlStation.LABEL_FILTRO_CONFIGURAZIONE_CORS_ORIGIN, corsOriginValue, this.getSize());
  13502.             }
  13503.         } catch (Exception e) {
  13504.             this.logError("Exception: " + e.getMessage(), e);
  13505.             throw new DriverControlStationException(e);
  13506.         }
  13507.     }
  13508.    
  13509.     public String addFilterTipoConnettore(ISearch ricerca, int idLista, boolean visualizzaVoceIM) throws DriverControlStationException{
  13510.         return this.addFilterTipoConnettore(ricerca, idLista, visualizzaVoceIM, true);
  13511.     }
  13512.     public String addFilterTipoConnettore(ISearch ricerca, int idLista, boolean visualizzaVoceIM, boolean postBack) throws DriverControlStationException{
  13513.         String tipoConnettoreValue = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  13514.         try {
  13515.            
  13516.            
  13517.             List<String> connettoriList = Connettori.getList();
  13518.             // rimozione disabilitato
  13519.             int indexDisabled = -1;
  13520.             for (int i = 0; i < connettoriList.size(); i++) {
  13521.                 if(TipiConnettore.DISABILITATO.getNome().equals(connettoriList.get(i))) {
  13522.                     indexDisabled = i;
  13523.                     break;
  13524.                 }
  13525.             }
  13526.             if(indexDisabled>=0) {
  13527.                 connettoriList.remove(indexDisabled);
  13528.             }
  13529.             if (!connettoriList.contains(TipiConnettore.HTTPS.toString())) {
  13530.                 connettoriList.add(TipiConnettore.HTTPS.toString());
  13531.             }
  13532.            
  13533.             Boolean confPers = ServletUtils.getObjectFromSession(this.request, this.session, Boolean.class, CostantiControlStation.SESSION_PARAMETRO_GESTIONE_CONFIGURAZIONI_PERSONALIZZATE);
  13534.             if(confPers==null) {
  13535.                 confPers = this.core!=null ? this.core.isShowConfigurazioniPersonalizzate() : true;
  13536.             }

  13537.             TipologiaConnettori tipologiaConnettori = null;
  13538.             try {
  13539.                 tipologiaConnettori = Utilities.getTipologiaConnettori(this.core);
  13540.             } catch (Exception e) {
  13541.                 // default
  13542.                 tipologiaConnettori = TipologiaConnettori.TIPOLOGIA_CONNETTORI_ALL;
  13543.             }
  13544.            
  13545.             // custom come da schermata configurazione connettore
  13546.             if (confPers && TipologiaConnettori.TIPOLOGIA_CONNETTORI_ALL.equals(tipologiaConnettori))
  13547.                 connettoriList.add(TipiConnettore.CUSTOM.toString());
  13548.            
  13549.             List<String> connettoriListLabels = new ArrayList<>();
  13550.             for (String tipoConnettore : connettoriList) {
  13551.                 TipiConnettore tipoC = TipiConnettore.toEnumFromName(tipoConnettore);
  13552.                 if(tipoC!=null) {
  13553.                     connettoriListLabels.add(tipoC.getLabel());
  13554.                 }
  13555.                 else {
  13556.                     connettoriListLabels.add(tipoConnettore);
  13557.                 }
  13558.             }
  13559.            
  13560.             // IM
  13561.             if(visualizzaVoceIM) {
  13562.                 if(this.core.isIntegrationManagerEnabled()) {
  13563.                     connettoriList.add(Filtri.FILTRO_CONNETTORE_TIPO_VALORE_IM);
  13564.                     connettoriListLabels.add(ConnettoriCostanti.LABEL_FILTRO_TIPO_CONNETTORE_IM);
  13565.                 }
  13566.             }
  13567.            
  13568.             int length = connettoriList.size() + 1;
  13569.            
  13570.             String [] values = new String[length];
  13571.             String [] labels = new String[length];
  13572.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  13573.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  13574.             for (int i =0; i < connettoriList.size() ; i ++) {
  13575.                 labels[i+1] = connettoriListLabels.get(i);
  13576.                 values[i+1] = connettoriList.get(i);
  13577.             }
  13578.            
  13579.             tipoConnettoreValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONNETTORE_TIPO);
  13580.            
  13581.             this.pd.addFilter(Filtri.FILTRO_CONNETTORE_TIPO, ConnettoriCostanti.LABEL_FILTRO_TIPO_CONNETTORE, tipoConnettoreValue, values, labels, postBack, this.getSize());
  13582.            
  13583.         } catch (Exception e) {
  13584.             this.logError("Exception: " + e.getMessage(), e);
  13585.             throw new DriverControlStationException(e);
  13586.         }
  13587.        
  13588.         return tipoConnettoreValue;
  13589.     }
  13590.    
  13591.     public void addFilterConnettorePlugin(ISearch ricerca, int idLista, String tipoConnettore) throws DriverControlStationException{
  13592.         try {
  13593.             if(tipoConnettore != null && tipoConnettore.equals(TipiConnettore.CUSTOM.toString())) {
  13594.                
  13595.                 String pluginValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONNETTORE_TIPO_PLUGIN);
  13596.                 String pluginLabel = "";
  13597.            
  13598.                 List<DataElement> dati = new ArrayList<>();
  13599.                
  13600.                 this.addCustomFieldSearchForm(TipoPlugin.CONNETTORE,
  13601.                         null,
  13602.                         null,
  13603.                         Filtri.FILTRO_CONNETTORE_TIPO,
  13604.                         Filtri.FILTRO_CONNETTORE_TIPO_PLUGIN,
  13605.                         pluginLabel,
  13606.                         pluginValue, false, dati,
  13607.                         false);
  13608.                
  13609.                 // dentro dati c'e' solo un elemento
  13610.                 DataElement dataElement = dati.get(0);
  13611.                
  13612.                 if(dataElement.getValues() != null && dataElement.getValues().length > 0) {
  13613.                     this.pd.addFilter(Filtri.FILTRO_CONNETTORE_TIPO_PLUGIN, pluginLabel, pluginValue, dataElement.getValues(), dataElement.getLabels(), false, this.getSize());
  13614.                 }
  13615.             }
  13616.         } catch (Exception e) {
  13617.             this.logError("Exception: " + e.getMessage(), e);
  13618.             throw new DriverControlStationException(e);
  13619.         }
  13620.     }
  13621.    
  13622.     public void addFilterConnettoreTokenPolicy(ISearch ricerca, int idLista, String tipoConnettore) throws DriverControlStationException{
  13623.         try {
  13624.             if(tipoConnettore != null &&
  13625.                 (tipoConnettore.equals("") ||
  13626.                         tipoConnettore.equals(TipiConnettore.HTTPS.toString())||
  13627.                         tipoConnettore.equals(TipiConnettore.HTTP.toString()))) {
  13628.            
  13629.                 // controllo esistenza token policy
  13630.                 List<GenericProperties> gestorePolicyTokenList = this.confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_RETRIEVE_POLICY_TOKEN, null);
  13631.            
  13632.                 if(gestorePolicyTokenList.size() > 0) {
  13633.                     int length = gestorePolicyTokenList.size() + 1;
  13634.                    
  13635.                     String [] values = new String[length];
  13636.                     String [] labels = new String[length];
  13637.                     labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  13638.                     values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  13639.                
  13640.                     for (int i = 0; i < gestorePolicyTokenList.size(); i++) {
  13641.                         GenericProperties genericProperties = gestorePolicyTokenList.get(i);
  13642.                         labels[(i+1)] = genericProperties.getNome();
  13643.                         values[(i+1)] = genericProperties.getNome();
  13644.                     }
  13645.                    
  13646.                     String tokenPolicyValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONNETTORE_TOKEN_POLICY);
  13647.                    
  13648.                     this.pd.addFilter(Filtri.FILTRO_CONNETTORE_TOKEN_POLICY, ConnettoriCostanti.LABEL_FILTRO_CONNETTORE_TOKEN_POLICY, tokenPolicyValue, values, labels, false, this.getSize());
  13649.                 }
  13650.             }
  13651.         } catch (Exception e) {
  13652.             this.logError("Exception: " + e.getMessage(), e);
  13653.             throw new DriverControlStationException(e);
  13654.         }
  13655.     }
  13656.    
  13657.     public void addFilterConnettoreEndpoint(ISearch ricerca, int idLista, String tipoConnettore) throws DriverControlStationException{
  13658.         try {
  13659.             if(tipoConnettore != null &&
  13660.                 (tipoConnettore.equals("") ||
  13661.                         tipoConnettore.equals(TipiConnettore.HTTPS.toString())||
  13662.                         tipoConnettore.equals(TipiConnettore.HTTP.toString())||
  13663.                         tipoConnettore.equals(TipiConnettore.JMS.toString())||
  13664.                         tipoConnettore.equals(TipiConnettore.FILE.toString()))) {
  13665.            
  13666.                 String endpointValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONNETTORE_ENDPOINT);
  13667.                
  13668.                 String filterLabel = ConnettoriCostanti.LABEL_FILTRO_CONNETTORE_ENDPOINT;
  13669.                
  13670.                 if(tipoConnettore.equals(TipiConnettore.JMS.toString())) {
  13671.                     filterLabel = ConnettoriCostanti.LABEL_FILTRO_CONNETTORE_ENDPOINT_JMS;
  13672.                 }
  13673.                
  13674.                 if(tipoConnettore.equals(TipiConnettore.FILE.toString())) {
  13675.                     filterLabel = ConnettoriCostanti.LABEL_FILTRO_CONNETTORE_ENDPOINT_FILE;
  13676.                 }
  13677.                    
  13678.                 this.pd.addTextFilter(Filtri.FILTRO_CONNETTORE_ENDPOINT, filterLabel, endpointValue, this.getSize());
  13679.             }
  13680.         } catch (Exception e) {
  13681.             this.logError("Exception: " + e.getMessage(), e);
  13682.             throw new DriverControlStationException(e);
  13683.         }
  13684.     }
  13685.    
  13686.     public void addFilterConnettoreKeystore(ISearch ricerca, int idLista, String tipoConnettore) throws DriverControlStationException{
  13687.         try {
  13688.             if(tipoConnettore != null &&
  13689.                 (tipoConnettore.equals(TipiConnettore.HTTPS.toString()))) {
  13690.            
  13691.                 String keystoreValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONNETTORE_KEYSTORE);
  13692.                
  13693.                 String filterLabel = ConnettoriCostanti.LABEL_FILTRO_CONNETTORE_KEYSTORE;
  13694.                    
  13695.                 this.pd.addTextFilter(Filtri.FILTRO_CONNETTORE_KEYSTORE, filterLabel, keystoreValue, this.getSize());
  13696.             }
  13697.         } catch (Exception e) {
  13698.             this.logError("Exception: " + e.getMessage(), e);
  13699.             throw new DriverControlStationException(e);
  13700.         }
  13701.     }
  13702.    
  13703.     public void addFilterConnettoreDebug(ISearch ricerca, int idLista, String tipoConnettore) throws DriverControlStationException{
  13704.         try {
  13705.            
  13706.             List<String> connettoriList = new ArrayList<>();
  13707.             connettoriList.add(Filtri.FILTRO_CONNETTORE_DEBUG_VALORE_ABILITATO);
  13708.             connettoriList.add(Filtri.FILTRO_CONNETTORE_DEBUG_VALORE_DISABILITATO);
  13709.            
  13710.             int length = connettoriList.size() + 1;
  13711.            
  13712.             String [] values = new String[length];
  13713.             String [] labels = new String[length];
  13714.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  13715.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  13716.             for (int i =0; i < connettoriList.size() ; i ++) {
  13717.                 labels[i+1] = connettoriList.get(i);
  13718.                 values[i+1] = connettoriList.get(i);
  13719.             }
  13720.            
  13721.             String debugValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONNETTORE_DEBUG);
  13722.            
  13723.             this.pd.addFilter(Filtri.FILTRO_CONNETTORE_DEBUG, ConnettoriCostanti.LABEL_FILTRO_CONNETTORE_DEBUG, debugValue, values, labels, false, this.getSize());
  13724.            
  13725.         } catch (Exception e) {
  13726.             this.logError("Exception: " + e.getMessage(), e);
  13727.             throw new DriverControlStationException(e);
  13728.         }
  13729.     }
  13730.    
  13731.     public String addFilterNomeConnettoreMultiplo(ISearch ricerca, int idLista) throws DriverControlStationException{
  13732.         try {
  13733.             String nomeValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONNETTORE_MULTIPLO_NOME);
  13734.            
  13735.             String filterLabel = ConnettoriCostanti.LABEL_FILTRO_CONNETTORE_MULTIPLO_NOME;
  13736.                
  13737.             this.pd.addTextFilter(Filtri.FILTRO_CONNETTORE_MULTIPLO_NOME, filterLabel, nomeValue, this.getSize());
  13738.            
  13739.             return nomeValue;
  13740.         } catch (Exception e) {
  13741.             this.logError("Exception: " + e.getMessage(), e);
  13742.             throw new DriverControlStationException(e);
  13743.         }
  13744.     }
  13745.    
  13746.     public void addFilterFiltroConnettoreMultiplo(ISearch ricerca, int idLista, boolean behaviourConFiltri) throws DriverControlStationException{
  13747.         try {
  13748.             if(behaviourConFiltri) {
  13749.            
  13750.                 String filtroValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_CONNETTORE_MULTIPLO_FILTRO);
  13751.                
  13752.                 String filterLabel = ConnettoriCostanti.LABEL_FILTRO_CONNETTORE_MULTIPLO_FILTRO;
  13753.                    
  13754.                 this.pd.addTextFilter(Filtri.FILTRO_CONNETTORE_MULTIPLO_FILTRO, filterLabel, filtroValue, this.getSize());
  13755.             }
  13756.         } catch (Exception e) {
  13757.             this.logError("Exception: " + e.getMessage(), e);
  13758.             throw new DriverControlStationException(e);
  13759.         }
  13760.     }
  13761.    
  13762.     public void addFilterModIKeystorePath(ISearch ricerca, int idLista) throws DriverControlStationException{
  13763.         try {
  13764.            
  13765.             String keystorePathValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_KEYSTORE_PATH);
  13766.             String filterPathLabel = CostantiLabel.MODIPA_API_IMPL_PROFILO_SICUREZZA_MESSAGGIO_CERTIFICATI_KEYSTORE_PATH_MODE_LABEL;
  13767.             this.pd.addTextFilter(Filtri.FILTRO_MODI_KEYSTORE_PATH, filterPathLabel, keystorePathValue, this.getSize());
  13768.            
  13769.         } catch (Exception e) {
  13770.             this.logError("Exception: " + e.getMessage(), e);
  13771.             throw new DriverControlStationException(e);
  13772.         }
  13773.     }
  13774.    
  13775.     public void addFilterModIKeystoreSubject(ISearch ricerca, int idLista) throws DriverControlStationException{
  13776.         try {
  13777.            
  13778.             String keystoreSubjectValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_KEYSTORE_SUBJECT);
  13779.             String filterSubjectLabel = CostantiLabel.MODIPA_API_IMPL_PROFILO_SICUREZZA_MESSAGGIO_CERTIFICATI_X509_SUBJECT_MODE_LABEL;
  13780.             this.pd.addTextFilter(Filtri.FILTRO_MODI_KEYSTORE_SUBJECT, filterSubjectLabel, keystoreSubjectValue, this.getSize());
  13781.            
  13782.         } catch (Exception e) {
  13783.             this.logError("Exception: " + e.getMessage(), e);
  13784.             throw new DriverControlStationException(e);
  13785.         }
  13786.     }
  13787.    
  13788.     public void addFilterModIKeystoreIssuer(ISearch ricerca, int idLista) throws DriverControlStationException{
  13789.         try {
  13790.            
  13791.             String keystoreIssuerValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_KEYSTORE_ISSUER);
  13792.             String filterIssuerLabel = CostantiLabel.MODIPA_API_IMPL_PROFILO_SICUREZZA_MESSAGGIO_CERTIFICATI_X509_ISSUER_MODE_LABEL;
  13793.             this.pd.addTextFilter(Filtri.FILTRO_MODI_KEYSTORE_ISSUER, filterIssuerLabel, keystoreIssuerValue, this.getSize());
  13794.            
  13795.         } catch (Exception e) {
  13796.             this.logError("Exception: " + e.getMessage(), e);
  13797.             throw new DriverControlStationException(e);
  13798.         }
  13799.     }
  13800.    
  13801.     public void addFilterModITokenPolicy(ISearch ricerca, int idLista, boolean postBack) throws DriverControlStationException{
  13802.         try {
  13803.             List<GenericProperties> gestorePolicyTokenList = this.confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN, null);
  13804.             String [] policyLabels = new String[gestorePolicyTokenList.size() + 1];
  13805.             String [] policyValues = new String[gestorePolicyTokenList.size() + 1];

  13806.             policyLabels[0] = CostantiControlStation.LABEL_PARAMETRO_TIPO_CREDENZIALI_QUALSIASI;
  13807.             policyValues[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_TIPO_CREDENZIALI_QUALSIASI;

  13808.             for (int i = 0; i < gestorePolicyTokenList.size(); i++) {
  13809.                 GenericProperties genericProperties = gestorePolicyTokenList.get(i);
  13810.                 policyLabels[(i+1)] = genericProperties.getNome();
  13811.                 policyValues[(i+1)] = genericProperties.getNome();
  13812.             }
  13813.                
  13814.             String tokenPolicyValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_SICUREZZA_TOKEN_POLICY);
  13815.             String selectedValue = tokenPolicyValue != null ? tokenPolicyValue : CostantiControlStation.DEFAULT_VALUE_PARAMETRO_TIPO_CREDENZIALI_QUALSIASI;
  13816.            
  13817.             String label = CostantiLabel.LABEL_CREDENZIALI_AUTENTICAZIONE_TOKEN_POLICY;

  13818.             this.pd.addFilter(Filtri.FILTRO_MODI_SICUREZZA_TOKEN_POLICY, label, selectedValue, policyValues, policyLabels, postBack, this.getSize());
  13819.            
  13820.         } catch (Exception e) {
  13821.             this.logError("Exception: " + e.getMessage(), e);
  13822.             throw new DriverControlStationException(e);
  13823.         }
  13824.     }
  13825.    
  13826.     public void addFilterModITokenClientId(ISearch ricerca, int idLista) throws DriverControlStationException{
  13827.         try {
  13828.            
  13829.             String tokenClientIdValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_SICUREZZA_TOKEN_CLIENT_ID);
  13830.             String tokenClientIdLabel = CostantiLabel.LABEL_CREDENZIALI_AUTENTICAZIONE_TOKEN_CLIENT_ID_SEARCH;
  13831.             this.pd.addTextFilter(Filtri.FILTRO_MODI_SICUREZZA_TOKEN_CLIENT_ID, tokenClientIdLabel, tokenClientIdValue, this.getSize());
  13832.            
  13833.         } catch (Exception e) {
  13834.             this.logError("Exception: " + e.getMessage(), e);
  13835.             throw new DriverControlStationException(e);
  13836.         }
  13837.     }
  13838.    
  13839.     public void addFilterModIAudience(ISearch ricerca, int idLista, boolean applicativi, String filterTipoAccordo, String filterDominio) throws DriverControlStationException{
  13840.         try {
  13841.             String audienceValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_AUDIENCE);
  13842.            
  13843.             String filterLabel = null;
  13844.             if(applicativi) {
  13845.                 if(SoggettiCostanti.SOGGETTO_DOMINIO_ESTERNO_VALUE.equals(filterDominio)) {
  13846.                     filterLabel = CostantiLabel.MODIPA_APPLICATIVI_AUDIENCE_RISPOSTA_INFO_DOMINIO_ESTERNO_LABEL;
  13847.                 }
  13848.                 else {
  13849.                     filterLabel = CostantiLabel.MODIPA_APPLICATIVI_AUDIENCE_RISPOSTA_INFO_DOMINIO_INTERNO_LABEL_FILTRO_RICERCA;
  13850.                 }
  13851.             }
  13852.             else {
  13853.                 if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_REST.toLowerCase().equals(filterTipoAccordo)) {
  13854.                     filterLabel = CostantiLabel.MODIPA_API_IMPL_PROFILO_SICUREZZA_MESSAGGIO_AUDIENCE_RICHIESTA_REST_LABEL;
  13855.                 }
  13856.                 else if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_SOAP.toLowerCase().equals(filterTipoAccordo)) {
  13857.                     filterLabel = CostantiLabel.MODIPA_API_IMPL_PROFILO_SICUREZZA_MESSAGGIO_AUDIENCE_RICHIESTA_SOAP_LABEL;
  13858.                 }
  13859.                 else {
  13860.                     filterLabel = CostantiLabel.MODIPA_APPLICATIVI_AUDIENCE_WSATO_LABEL;
  13861.                 }
  13862.             }
  13863.                
  13864.             this.pd.addTextFilter(Filtri.FILTRO_MODI_AUDIENCE, filterLabel, audienceValue, this.getSize());
  13865.         } catch (Exception e) {
  13866.             this.logError("Exception: " + e.getMessage(), e);
  13867.             throw new DriverControlStationException(e);
  13868.         }
  13869.     }
  13870.    
  13871.     public void addFilterModISicurezzaCanale(ISearch ricerca, int idLista) throws DriverControlStationException{
  13872.         try {
  13873.             // controllo esistenza token policy
  13874.             List<String> labelsList = this.getProfiloModIPAFiltroSicurezzaCanaleLabels();
  13875.             List<String> valuesList = this.getProfiloModIPAFiltroSicurezzaCanaleValues();
  13876.             int length = valuesList.size() + 1;
  13877.                
  13878.             String [] values = new String[length];
  13879.             String [] labels = new String[length];
  13880.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  13881.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  13882.            
  13883.             for (int i = 0; i < valuesList.size(); i++) {
  13884.                 labels[(i+1)] = labelsList.get(i);
  13885.                 values[(i+1)] = valuesList.get(i);
  13886.             }
  13887.            
  13888.             String sicurezzaCanaleValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_SICUREZZA_CANALE);
  13889.            
  13890.             this.pd.addFilter(Filtri.FILTRO_MODI_SICUREZZA_CANALE, CostantiLabel.MODIPA_API_PROFILO_CANALE_LABEL, sicurezzaCanaleValue, values, labels, false, this.getSize());
  13891.         } catch (Exception e) {
  13892.             this.logError("Exception: " + e.getMessage(), e);
  13893.             throw new DriverControlStationException(e);
  13894.         }
  13895.     }
  13896.    
  13897.     public void addFilterModISicurezzaMessaggio(ISearch ricerca, int idLista, String serviceBindingValue) throws DriverControlStationException{
  13898.         try {
  13899.             // controllo esistenza token policy
  13900.             List<String> labelsList = this.getProfiloModIPAFiltroSicurezzaMessaggioLabels(serviceBindingValue);
  13901.             List<String> valuesList = this.getProfiloModIPAFiltroSicurezzaMessaggioValues(serviceBindingValue);
  13902.             int length = valuesList.size() + 1;
  13903.                
  13904.             String [] values = new String[length];
  13905.             String [] labels = new String[length];
  13906.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  13907.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  13908.            
  13909.             for (int i = 0; i < valuesList.size(); i++) {
  13910.                 labels[(i+1)] = labelsList.get(i);
  13911.                 values[(i+1)] = valuesList.get(i);
  13912.             }
  13913.            
  13914.             String sicurezzaCanaleValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_SICUREZZA_MESSAGGIO);
  13915.            
  13916.             this.pd.addFilter(Filtri.FILTRO_MODI_SICUREZZA_MESSAGGIO, CostantiLabel.MODIPA_API_PROFILO_SICUREZZA_MESSAGGIO_LABEL, sicurezzaCanaleValue, values, labels, false, this.getSize());
  13917.         } catch (Exception e) {
  13918.             this.logError("Exception: " + e.getMessage(), e);
  13919.             throw new DriverControlStationException(e);
  13920.         }
  13921.     }
  13922.    
  13923.     public void addFilterModIGenerazioneToken(ISearch ricerca, int idLista) throws DriverControlStationException{
  13924.         try {
  13925.             String [] v = {CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH_VALUE_LOCALE,
  13926.                     CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH_VALUE_PDND,
  13927.                     CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH_VALUE_OAUTH};
  13928.             List<String> valuesList = Arrays.asList(v);
  13929.            
  13930.             String [] l = {CostantiLabel.MODIPA_SICUREZZA_CHOICE_MESSAGE_LABEL,
  13931.                     CostantiLabel.MODIPA_SICUREZZA_CHOICE_TOKEN_PDND_LABEL,
  13932.                     CostantiLabel.MODIPA_SICUREZZA_CHOICE_TOKEN_OAUTH_LABEL};
  13933.             List<String> labelsList = Arrays.asList(l);
  13934.            
  13935.             int length = valuesList.size() + 1;
  13936.                
  13937.             String [] values = new String[length];
  13938.             String [] labels = new String[length];
  13939.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  13940.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  13941.            
  13942.             for (int i = 0; i < valuesList.size(); i++) {
  13943.                 labels[(i+1)] = labelsList.get(i);
  13944.                 values[(i+1)] = valuesList.get(i);
  13945.             }
  13946.            
  13947.             String generazioneTokenValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_SORGENTE_TOKEN);
  13948.            
  13949.             this.pd.addFilter(Filtri.FILTRO_MODI_SORGENTE_TOKEN, CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH, generazioneTokenValue, values, labels, false, this.getSize());
  13950.         } catch (Exception e) {
  13951.             this.logError("Exception: " + e.getMessage(), e);
  13952.             throw new DriverControlStationException(e);
  13953.         }
  13954.     }
  13955.    
  13956.     public String addFilterModISicurezzaMessaggioSA(ISearch ricerca, int idLista, boolean postback) throws DriverControlStationException{
  13957.         try {
  13958.             /**List<String> valuesList = Arrays.asList(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA);*/
  13959.             // non ha senso in modi controllare quelli disabilitati
  13960.             String [] valueAbilitatoOnly = {StatoFunzionalita.ABILITATO.getValue()};
  13961.             List<String> valuesList = Arrays.asList(valueAbilitatoOnly);
  13962.             int length = valuesList.size() + 1;
  13963.                
  13964.             String [] values = new String[length];
  13965.             String [] labels = new String[length];
  13966.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  13967.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  13968.            
  13969.             for (int i = 0; i < valuesList.size(); i++) {
  13970.                 labels[(i+1)] = valuesList.get(i);
  13971.                 values[(i+1)] = valuesList.get(i);
  13972.             }
  13973.            
  13974.             String sicurezzaMessaggioValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_SICUREZZA_MESSAGGIO);
  13975.            
  13976.             this.pd.addFilter(Filtri.FILTRO_MODI_SICUREZZA_MESSAGGIO, CostantiLabel.MODIPA_SICUREZZA_MESSAGGIO_FIRMA_APPLICATIVO_SUBTITLE_LABEL, sicurezzaMessaggioValue, values, labels, postback, this.getSize());
  13977.            
  13978.             return sicurezzaMessaggioValue;
  13979.            
  13980.         } catch (Exception e) {
  13981.             this.logError("Exception: " + e.getMessage(), e);
  13982.             throw new DriverControlStationException(e);
  13983.         }
  13984.     }
  13985.    
  13986.     public String addFilterModISicurezzaTokenSA(ISearch ricerca, int idLista, boolean postback) throws DriverControlStationException{
  13987.         try {
  13988.             /**List<String> valuesList = Arrays.asList(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA);*/
  13989.             // non ha senso in modi controllare quelli disabilitati
  13990.             String [] valueAbilitatoOnly = {StatoFunzionalita.ABILITATO.getValue()};
  13991.             List<String> valuesList = Arrays.asList(valueAbilitatoOnly);
  13992.             int length = valuesList.size() + 1;
  13993.                
  13994.             String [] values = new String[length];
  13995.             String [] labels = new String[length];
  13996.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  13997.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  13998.            
  13999.             for (int i = 0; i < valuesList.size(); i++) {
  14000.                 labels[(i+1)] = valuesList.get(i);
  14001.                 values[(i+1)] = valuesList.get(i);
  14002.             }
  14003.            
  14004.             String sicurezzaMessaggioValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_SICUREZZA_TOKEN);
  14005.            
  14006.             this.pd.addFilter(Filtri.FILTRO_MODI_SICUREZZA_TOKEN, CostantiLabel.MODIPA_SICUREZZA_TOKEN_SUBTITLE_LABEL, sicurezzaMessaggioValue, values, labels, postback, this.getSize());
  14007.            
  14008.             return sicurezzaMessaggioValue;
  14009.            
  14010.         } catch (Exception e) {
  14011.             this.logError("Exception: " + e.getMessage(), e);
  14012.             throw new DriverControlStationException(e);
  14013.         }
  14014.     }
  14015.    
  14016.     public void addFilterModIDigestRichiesta(ISearch ricerca, int idLista) throws DriverControlStationException{
  14017.         try {
  14018.             /**List<String> valuesList = Arrays.asList(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA);*/
  14019.             // non ha senso in modi controllare quelli disabilitati
  14020.             String [] valueAbilitatoOnly = {StatoFunzionalita.ABILITATO.getValue()};
  14021.             List<String> valuesList = Arrays.asList(valueAbilitatoOnly);
  14022.             int length = valuesList.size() + 1;
  14023.                
  14024.             String [] values = new String[length];
  14025.             String [] labels = new String[length];
  14026.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  14027.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  14028.            
  14029.             for (int i = 0; i < valuesList.size(); i++) {
  14030.                 labels[(i+1)] = valuesList.get(i);
  14031.                 values[(i+1)] = valuesList.get(i);
  14032.             }
  14033.            
  14034.             String digestRichiestaValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_DIGEST_RICHIESTA);
  14035.            
  14036.             this.pd.addFilter(Filtri.FILTRO_MODI_DIGEST_RICHIESTA, CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_REQUEST_DIGEST_LABEL,
  14037.                     digestRichiestaValue, values, labels, false, this.getSize());
  14038.         } catch (Exception e) {
  14039.             this.logError("Exception: " + e.getMessage(), e);
  14040.             throw new DriverControlStationException(e);
  14041.         }
  14042.     }
  14043.    
  14044.     public void addFilterModIInfoUtente(ISearch ricerca, int idLista) throws DriverControlStationException{
  14045.         try {
  14046.             String [] v = {CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_CORNICE_SICUREZZA_PATTERN_AUDIT_REST_01,
  14047.                     CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_CORNICE_SICUREZZA_PATTERN_AUDIT_REST_02,
  14048.                     CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_CORNICE_SICUREZZA_PATTERN_OLD};
  14049.             List<String> valuesList = Arrays.asList(v);
  14050.            
  14051.             String [] l = {CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_CORNICE_SICUREZZA_PATTERN_AUDIT_REST_01,
  14052.                     CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_CORNICE_SICUREZZA_PATTERN_AUDIT_REST_02,
  14053.                     CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_CORNICE_SICUREZZA_PATTERN_OLD};
  14054.             List<String> labelsList = Arrays.asList(l);
  14055.            
  14056.             int length = valuesList.size() + 1;
  14057.                
  14058.             String [] values = new String[length];
  14059.             String [] labels = new String[length];
  14060.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  14061.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  14062.            
  14063.             for (int i = 0; i < valuesList.size(); i++) {
  14064.                 labels[(i+1)] = labelsList.get(i);
  14065.                 values[(i+1)] = valuesList.get(i);
  14066.             }
  14067.            
  14068.             String infoUtenteValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_MODI_INFORMAZIONI_UTENTE);
  14069.            
  14070.             this.pd.addFilter(Filtri.FILTRO_MODI_INFORMAZIONI_UTENTE, CostantiControlStation.LABEL_FILTRO_MODIPA_INFO_UTENTE, infoUtenteValue, values, labels, false, this.getSize());
  14071.         } catch (Exception e) {
  14072.             this.logError("Exception: " + e.getMessage(), e);
  14073.             throw new DriverControlStationException(e);
  14074.         }
  14075.     }

  14076.     public List<String> getProfiloModIPAFiltroSicurezzaCanaleValues() {
  14077.         try {
  14078.             List<String> values = new ArrayList<>();
  14079.             values.add(CostantiDB.MODIPA_PROFILO_SICUREZZA_CANALE_VALUE_IDAC01);
  14080.             values.add(CostantiDB.MODIPA_PROFILO_SICUREZZA_CANALE_VALUE_IDAC02);
  14081.             return values;
  14082.         }catch(Throwable t) {
  14083.             return null;
  14084.         }
  14085.     }
  14086.    
  14087.     public List<String> getProfiloModIPAFiltroSicurezzaCanaleLabels() {
  14088.         List<String> labels = null;
  14089.         try {
  14090.             labels = new ArrayList<>();
  14091.             labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_CANALE_LABEL_IDAC01);
  14092.             labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_CANALE_LABEL_IDAC02);
  14093.             return labels;
  14094.         }catch(Exception t) {
  14095.             return labels;
  14096.         }
  14097.     }
  14098.    
  14099.     public List<String> getProfiloModIPAFiltroSicurezzaMessaggioValues(String serviceBindingValue) {
  14100.         List<String> values = null;
  14101.         try {
  14102.             values = new ArrayList<>();
  14103.             values.add(CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_VALUE_IDAM01);
  14104.             values.add(CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_VALUE_IDAM02);
  14105.             values.add(CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_VALUE_IDAM0301);
  14106.             values.add(CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_VALUE_IDAM0302);
  14107.             if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_REST.toLowerCase().equals(serviceBindingValue)
  14108.                     ||
  14109.                     !CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_SOAP.toLowerCase().equals(serviceBindingValue)) {
  14110.                 values.add(CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_VALUE_IDAM0401);
  14111.                 values.add(CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_VALUE_IDAM0402);
  14112.             }
  14113.             return values;
  14114.         }catch(Exception t) {
  14115.             return values;
  14116.         }
  14117.     }
  14118.    
  14119.     public List<String> getProfiloModIPAFiltroSicurezzaMessaggioLabels(String serviceBindingValue) {
  14120.         List<String> labels = null;
  14121.         try {
  14122.             labels = new ArrayList<>();
  14123.            
  14124.             if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_REST.toLowerCase().equals(serviceBindingValue) ) {
  14125.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM01_REST);
  14126.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM02_REST);
  14127.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM0301_REST);
  14128.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM0302_REST);
  14129.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM0401_REST);
  14130.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM0402_REST);
  14131.             }
  14132.             else if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SERVICE_BINDING_SOAP.toLowerCase().equals(serviceBindingValue) ) {
  14133.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM01_SOAP);
  14134.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM02_SOAP);
  14135.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM0301_SOAP);
  14136.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM0302_SOAP);
  14137.             }
  14138.             else {
  14139.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM01);
  14140.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM02);
  14141.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM0301);
  14142.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM0302);
  14143.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM0401);
  14144.                 labels.add(CostantiLabel.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_LABEL_IDAM0402);
  14145.             }
  14146.            
  14147.             return labels;
  14148.         }catch(Exception t) {
  14149.             return labels;
  14150.         }
  14151.     }
  14152.    
  14153.    
  14154.     public void addFilterProprietaNome(ISearch ricerca, int idLista, List<String> nomiProprieta) throws DriverControlStationException{
  14155.         try {
  14156.             // controllo esistenza token policy
  14157.             int length = nomiProprieta.size() + 1;
  14158.                
  14159.             String [] values = new String[length];
  14160.             String [] labels = new String[length];
  14161.             labels[0] = CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI;
  14162.             values[0] = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI;
  14163.            
  14164.             for (int i = 0; i < nomiProprieta.size(); i++) {
  14165.                 labels[(i+1)] = nomiProprieta.get(i);
  14166.                 values[(i+1)] = nomiProprieta.get(i);
  14167.             }
  14168.            
  14169.             String nomeProprietaValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_PROPRIETA_NOME);
  14170.            
  14171.             this.pd.addFilter(Filtri.FILTRO_PROPRIETA_NOME, CostantiControlStation.LABEL_FILTRO_PROPRIETA_NOME, nomeProprietaValue, values, labels, false, this.getSize());
  14172.         } catch (Exception e) {
  14173.             this.logError("Exception: " + e.getMessage(), e);
  14174.             throw new DriverControlStationException(e);
  14175.         }
  14176.     }
  14177.    
  14178.     public void addFilterProprietaValore(ISearch ricerca, int idLista, List<String> nomiProprieta) throws DriverControlStationException{
  14179.         try {
  14180.             String valoreProprietaValue = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_PROPRIETA_VALORE);
  14181.            
  14182.             String filterLabel = CostantiControlStation.LABEL_FILTRO_PROPRIETA_VALORE;
  14183.                
  14184.             this.pd.addTextFilter(Filtri.FILTRO_PROPRIETA_VALORE, filterLabel, valoreProprietaValue, this.getSize());
  14185.         } catch (Exception e) {
  14186.             this.logError("Exception: " + e.getMessage(), e);
  14187.             throw new DriverControlStationException(e);
  14188.         }
  14189.     }
  14190.    
  14191.     // LABEL PROTOCOLLI
  14192.    
  14193.     public List<String> getLabelsProtocolli(List<String> protocolli) throws DriverControlStationException{
  14194.         try {
  14195.             return NamingUtils.getLabelsProtocolli(protocolli);
  14196.         }catch(Exception e) {
  14197.             throw new DriverControlStationException(e.getMessage(),e);
  14198.         }
  14199.     }
  14200.    
  14201.     public String getLabelProtocollo(String protocollo) throws DriverControlStationException{
  14202.         try {
  14203.             return NamingUtils.getLabelProtocollo(protocollo);
  14204.         }catch(Exception e) {
  14205.             throw new DriverControlStationException(e.getMessage(),e);
  14206.         }
  14207.     }
  14208.        
  14209.     public static String _getLabelProtocollo(String protocollo) throws DriverControlStationException{
  14210.         try {
  14211.             return NamingUtils.getLabelProtocollo(protocollo);
  14212.         }catch(Exception e) {
  14213.             throw new DriverControlStationException(e.getMessage(),e);
  14214.         }
  14215.     }
  14216.    
  14217.     public String getDescrizioneProtocollo(String protocollo) throws DriverControlStationException{
  14218.         try {
  14219.             return NamingUtils.getDescrizioneProtocollo(protocollo);
  14220.         }catch(Exception e) {
  14221.             throw new DriverControlStationException(e.getMessage(),e);
  14222.         }
  14223.     }
  14224.    
  14225.     public String getWebSiteProtocollo(String protocollo) throws DriverControlStationException{
  14226.         try {
  14227.             return NamingUtils.getWebSiteProtocollo(protocollo);
  14228.         }catch(Exception e) {
  14229.             throw new DriverControlStationException(e.getMessage(),e);
  14230.         }
  14231.     }
  14232.    
  14233.    
  14234.     // LABEL SOGGETTI
  14235.    
  14236.     public String getLabelNomeSoggetto(IDSoggetto idSoggetto) throws DriverControlStationException{
  14237.         try {
  14238.             return NamingUtils.getLabelSoggetto(idSoggetto);
  14239.         }catch(Exception e) {
  14240.             throw new DriverControlStationException(e.getMessage(),e);
  14241.         }
  14242.     }
  14243.    
  14244.     public static String _getLabelNomeSoggetto(IDSoggetto idSoggetto) throws DriverControlStationException{
  14245.         try {
  14246.             return NamingUtils.getLabelSoggetto(idSoggetto);
  14247.         }catch(Exception e) {
  14248.             throw new DriverControlStationException(e.getMessage(),e);
  14249.         }
  14250.     }
  14251.     public String getLabelNomeSoggetto(String protocollo, IDSoggetto idSoggetto) throws DriverControlStationException{
  14252.         try {
  14253.             return NamingUtils.getLabelSoggetto(protocollo, idSoggetto);
  14254.         }catch(Exception e) {
  14255.             throw new DriverControlStationException(e.getMessage(),e);
  14256.         }
  14257.     }
  14258.     public String getLabelNomeSoggetto(String protocollo, String tipoSoggetto, String nomeSoggetto) throws DriverControlStationException{
  14259.         try {
  14260.             return NamingUtils.getLabelSoggetto(protocollo, tipoSoggetto, nomeSoggetto);
  14261.         }catch(Exception e) {
  14262.             throw new DriverControlStationException(e.getMessage(),e);
  14263.         }
  14264.     }
  14265.    
  14266.    
  14267.     // APPLICATIVI
  14268.    
  14269.     public String getLabelServizioApplicativo(IDServizioApplicativo idServizioApplicativo) throws DriverControlStationException{
  14270.         try {
  14271.             return NamingUtils.getLabelServizioApplicativo(idServizioApplicativo);
  14272.         }catch(Exception e) {
  14273.             throw new DriverControlStationException(e.getMessage(),e);
  14274.         }
  14275.     }
  14276.     public String getLabelServizioApplicativo(String protocollo, IDServizioApplicativo idServizioApplicativo) throws DriverControlStationException{
  14277.         try {
  14278.             return NamingUtils.getLabelServizioApplicativo(protocollo, idServizioApplicativo);
  14279.         }catch(Exception e) {
  14280.             throw new DriverControlStationException(e.getMessage(),e);
  14281.         }
  14282.     }
  14283.     public String getLabelServizioApplicativoConDominioSoggetto(IDServizioApplicativo idServizioApplicativo) throws DriverControlStationException{
  14284.         try {
  14285.             return NamingUtils.getLabelServizioConDominioErogatore(idServizioApplicativo.getNome(),NamingUtils.getLabelSoggetto(idServizioApplicativo.getIdSoggettoProprietario()));
  14286.         }catch(Exception e) {
  14287.             throw new DriverControlStationException(e.getMessage(),e);
  14288.         }
  14289.     }
  14290.     public String getLabelServizioApplicativoConDominioSoggetto(String protocollo, IDServizioApplicativo idServizioApplicativo) throws DriverControlStationException{
  14291.         try {
  14292.             return NamingUtils.getLabelServizioConDominioErogatore(idServizioApplicativo.getNome(),NamingUtils.getLabelSoggetto(protocollo, idServizioApplicativo.getIdSoggettoProprietario()));
  14293.         }catch(Exception e) {
  14294.             throw new DriverControlStationException(e.getMessage(),e);
  14295.         }
  14296.     }
  14297.    
  14298.    
  14299.     // LABEL API
  14300.    
  14301.     public String getLabelIdAccordo(AccordoServizioParteComune as) throws DriverControlStationException{
  14302.         try {
  14303.             return NamingUtils.getLabelAccordoServizioParteComune(as);
  14304.         }catch(Exception e) {
  14305.             throw new DriverControlStationException(e.getMessage(),e);
  14306.         }
  14307.     }
  14308.     public String getLabelIdAccordo(AccordoServizioParteComuneSintetico as) throws DriverControlStationException{
  14309.         try {
  14310.             return NamingUtils.getLabelAccordoServizioParteComune(as);
  14311.         }catch(Exception e) {
  14312.             throw new DriverControlStationException(e.getMessage(),e);
  14313.         }
  14314.     }
  14315.     public String getLabelIdAccordo(IDAccordo idAccordo) throws DriverControlStationException{
  14316.         try {
  14317.             return NamingUtils.getLabelAccordoServizioParteComune(idAccordo);
  14318.         }catch(Exception e) {
  14319.             throw new DriverControlStationException(e.getMessage(),e);
  14320.         }
  14321.     }
  14322.     public String getLabelIdAccordo(String protocollo, IDAccordo idAccordo) throws DriverControlStationException{
  14323.         try {
  14324.             return NamingUtils.getLabelAccordoServizioParteComune(protocollo, idAccordo);
  14325.         }catch(Exception e) {
  14326.             throw new DriverControlStationException(e.getMessage(),e);
  14327.         }
  14328.     }
  14329.     public String getLabelIdAccordoSenzaReferente(String protocollo, IDAccordo idAccordo) throws DriverControlStationException{
  14330.         try {
  14331.             return NamingUtils.getLabelAccordoServizioParteComune(protocollo, idAccordo,false);
  14332.         }catch(Exception e) {
  14333.             throw new DriverControlStationException(e.getMessage(),e);
  14334.         }
  14335.     }
  14336.    
  14337.    
  14338.     // LABEL SERVIZI
  14339.    
  14340.     public String getLabelNomeServizio(String protocollo, String tipoServizio, String nomeServizio, Integer versioneInt) throws DriverControlStationException{
  14341.         try {
  14342.             return NamingUtils.getLabelAccordoServizioParteSpecificaSenzaErogatore(protocollo, tipoServizio, nomeServizio, versioneInt);
  14343.         }catch(Exception e) {
  14344.             throw new DriverControlStationException(e.getMessage(),e);
  14345.         }
  14346.     }
  14347.     public String getLabelIdServizio(AccordoServizioParteSpecifica as) throws DriverControlStationException{
  14348.         try {
  14349.             return NamingUtils.getLabelAccordoServizioParteSpecifica(as);
  14350.         }catch(Exception e) {
  14351.             throw new DriverControlStationException(e.getMessage(),e);
  14352.         }
  14353.     }
  14354.     public String getLabelIdServizio(IDServizio idServizio) throws DriverControlStationException{
  14355.         try {
  14356.             return NamingUtils.getLabelAccordoServizioParteSpecifica(idServizio);
  14357.         }catch(Exception e) {
  14358.             throw new DriverControlStationException(e.getMessage(),e);
  14359.         }
  14360.     }
  14361.     public String getLabelIdServizio(String protocollo, IDServizio idServizio) throws DriverControlStationException{
  14362.         try {
  14363.             return NamingUtils.getLabelAccordoServizioParteSpecifica(protocollo, idServizio);
  14364.         }catch(Exception e) {
  14365.             throw new DriverControlStationException(e.getMessage(),e);
  14366.         }
  14367.     }
  14368.     public String getLabelIdServizioSenzaErogatore(String protocollo, IDServizio idServizio) throws DriverControlStationException{
  14369.         try {
  14370.             return NamingUtils.getLabelAccordoServizioParteSpecificaSenzaErogatore(protocollo, idServizio);
  14371.         }catch(Exception e) {
  14372.             throw new DriverControlStationException(e.getMessage(),e);
  14373.         }
  14374.     }
  14375.     public String getLabelIdServizioSenzaErogatore(IDServizio idServizio) throws DriverControlStationException{
  14376.         try {
  14377.             return NamingUtils.getLabelAccordoServizioParteSpecificaSenzaErogatore(idServizio);
  14378.         }catch(Exception e) {
  14379.             throw new DriverControlStationException(e.getMessage(),e);
  14380.         }
  14381.     }
  14382.     public String getLabelServizioFruizione(String protocollo, IDSoggetto idSoggettoFruitore, AccordoServizioParteSpecifica asps) throws DriverControlStationException{
  14383.         try {
  14384.             return this.getLabelServizioFruizione(protocollo, idSoggettoFruitore, this.idServizioFactory.getIDServizioFromAccordo(asps));
  14385.         }catch(Exception e) {
  14386.             throw new DriverControlStationException(e.getMessage(),e);
  14387.         }
  14388.     }
  14389.     public String getLabelServizioFruizione(String protocollo, IDSoggetto idSoggettoFruitore, IDServizio idServizio) throws DriverControlStationException{
  14390.         String servizio = this.getLabelIdServizioSenzaErogatore(protocollo, idServizio);
  14391.         String soggetto = this.getLabelNomeSoggetto(protocollo, idServizio.getSoggettoErogatore());
  14392.         String labelServizio = NamingUtils.getLabelServizioConDominioErogatore(servizio, soggetto);
  14393.         boolean showSoggettoFruitoreInFruizioni = this.core.isMultitenant() &&
  14394.                 !this.isSoggettoMultitenantSelezionato();
  14395.         if(showSoggettoFruitoreInFruizioni) {
  14396.             String labelFruitore = this.getLabelNomeSoggetto(protocollo, idSoggettoFruitore);
  14397.             return labelFruitore + " -> " + labelServizio;
  14398.         }
  14399.         else {
  14400.             return labelServizio;
  14401.         }
  14402.     }
  14403.     public String getLabelServizioErogazione(String protocollo, AccordoServizioParteSpecifica asps) throws DriverControlStationException{
  14404.         try {
  14405.             return this.getLabelServizioErogazione(protocollo, this.idServizioFactory.getIDServizioFromAccordo(asps));
  14406.         }catch(Exception e) {
  14407.             throw new DriverControlStationException(e.getMessage(),e);
  14408.         }
  14409.     }
  14410.     public String getLabelServizioErogazione(String protocollo, IDServizio idServizio) throws DriverControlStationException{
  14411.         boolean showSoggettoErogatoreInErogazioni = this.core.isMultitenant() &&
  14412.                 !this.isSoggettoMultitenantSelezionato();
  14413.         if(showSoggettoErogatoreInErogazioni) {
  14414.             String servizio = this.getLabelIdServizioSenzaErogatore(protocollo, idServizio);
  14415.             String soggetto = this.getLabelNomeSoggetto(protocollo, idServizio.getSoggettoErogatore());
  14416.             return NamingUtils.getLabelServizioConDominioErogatore(servizio, soggetto);
  14417.         }
  14418.         else {
  14419.             return this.getLabelIdServizioSenzaErogatore(protocollo, idServizio);
  14420.         }
  14421.        
  14422.     }
  14423.    
  14424.     public String getLabelServizio(IDSoggetto idSoggettoFruitore, boolean gestioneFruitori, IDServizio idServizio, String tipoProtocollo) throws DriverControlStationException {
  14425.         String labelServizio = null;
  14426.         if(gestioneFruitori) {
  14427.             labelServizio = this.getLabelServizioFruizione(tipoProtocollo, idSoggettoFruitore, idServizio);
  14428.         }
  14429.         else {
  14430.             labelServizio = this.getLabelServizioErogazione(tipoProtocollo, idServizio);
  14431.         }
  14432.         return labelServizio;
  14433.     }
  14434.    
  14435.     public String getLabelServizio(IDSoggetto idSoggettoFruitore, boolean gestioneFruitori, AccordoServizioParteSpecifica asps, String tipoProtocollo) throws DriverControlStationException {
  14436.         String labelServizio = null;
  14437.         if(gestioneFruitori) {
  14438.             labelServizio = this.getLabelServizioFruizione(tipoProtocollo, idSoggettoFruitore, asps);
  14439.         }
  14440.         else {
  14441.             labelServizio = this.getLabelServizioErogazione(tipoProtocollo, asps);
  14442.         }
  14443.         return labelServizio;
  14444.     }
  14445.    
  14446.     // LABEL ACCORDI COOPERAZIONE
  14447.    
  14448.     public String getLabelIdAccordoCooperazione(AccordoCooperazione ac) throws DriverControlStationException{
  14449.         try {
  14450.             return NamingUtils.getLabelAccordoCooperazione(ac);
  14451.         }catch(Exception e) {
  14452.             throw new DriverControlStationException(e.getMessage(),e);
  14453.         }
  14454.     }
  14455.     public String getLabelIdAccordoCooperazione(IDAccordoCooperazione idAccordo) throws DriverControlStationException{
  14456.         try {
  14457.             return NamingUtils.getLabelAccordoCooperazione(idAccordo);
  14458.         }catch(Exception e) {
  14459.             throw new DriverControlStationException(e.getMessage(),e);
  14460.         }
  14461.     }
  14462.     public String getLabelIdAccordoCooperazione(String protocollo, IDAccordoCooperazione idAccordo) throws DriverControlStationException{
  14463.         try {
  14464.             return NamingUtils.getLabelAccordoCooperazione(protocollo, idAccordo);
  14465.         }catch(Exception e) {
  14466.             throw new DriverControlStationException(e.getMessage(),e);
  14467.         }
  14468.     }
  14469.    
  14470.    
  14471.    
  14472.     // Validazione contenuti
  14473.    
  14474.     public void validazioneContenuti(TipoOperazione tipoOperazione,List<DataElement> dati, boolean isPortaDelegata, String xsd, String tipoValidazione, String applicaMTOM,
  14475.             ServiceBinding serviceBinding, FormatoSpecifica formatoSpecifica) throws DriverControlStationException{
  14476.         validazioneContenuti(tipoOperazione, dati, true,isPortaDelegata,xsd,tipoValidazione,applicaMTOM, serviceBinding, formatoSpecifica);
  14477.     }
  14478.    
  14479.     public void validazioneContenuti(TipoOperazione tipoOperazione,List<DataElement> dati, boolean addSezione,boolean isPortaDelegata, String xsd, String tipoValidazione, String applicaMTOM,
  14480.             ServiceBinding serviceBinding, FormatoSpecifica formatoSpecifica) {
  14481.         DataElement de = new DataElement();
  14482.        
  14483.         if(addSezione) {
  14484.             de = new DataElement();
  14485.             de.setType(DataElementType.TITLE);
  14486.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_VALIDAZIONE_CONTENUTI);
  14487.             dati.add(de);
  14488.         }
  14489.        
  14490.         String[] tipoXsd = { CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_VALIDAZIONE_ABILITATO,
  14491.                 CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_VALIDAZIONE_DISABILITATO,
  14492.                 CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_VALIDAZIONE_WARNING_ONLY };
  14493.        
  14494.         de = new DataElement();
  14495.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_STATO);
  14496.         de.setType(DataElementType.SELECT);
  14497.         de.setName(CostantiControlStation.PARAMETRO_PORTE_XSD);
  14498.         de.setValues(tipoXsd);
  14499.         //      de.setOnChange("CambiaMode('" + tipoOp + "')");
  14500.         de.setPostBack(true);
  14501.         de.setSelected(xsd);
  14502.         dati.add(de);
  14503.        
  14504.         if (CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_VALIDAZIONE_ABILITATO.equals(xsd) ||
  14505.                 CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_VALIDAZIONE_WARNING_ONLY.equals(xsd)) {
  14506.            
  14507.             List<String> tipiValidazione = new ArrayList<>();
  14508.             tipiValidazione.add(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_TIPO_VALIDAZIONE_INTERFACE);
  14509.             tipiValidazione.add(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_TIPO_VALIDAZIONE_XSD);
  14510.             if(!this.isModalitaStandard()) {
  14511.                 tipiValidazione.add(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_TIPO_VALIDAZIONE_OPENSPCOOP);
  14512.             }
  14513.            
  14514.             List<String> labelTipiValidazione = new ArrayList<>();
  14515.             switch (formatoSpecifica) {
  14516.             case OPEN_API_3:
  14517.                 labelTipiValidazione.add(CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_OPEN_API_3);
  14518.                 break;
  14519.             case SWAGGER_2:
  14520.                 labelTipiValidazione.add(CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_SWAGGER_2);
  14521.                 break;
  14522.             case WADL:
  14523.                 labelTipiValidazione.add(CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_WADL);
  14524.                 break;
  14525.             case WSDL_11:
  14526.                 labelTipiValidazione.add(CostantiControlStation.LABEL_PARAMETRO_INTERFACE_TYPE_WSDL_11);
  14527.                 break;
  14528.             }
  14529.             labelTipiValidazione.add(CostantiControlStation.LABEL_PARAMETRO_SCHEMI_XSD);
  14530.             if(!this.isModalitaStandard()) {
  14531.                 labelTipiValidazione.add(CostantiControlStation.LABEL_PARAMETRO_REGISTRO_OPENSPCOOP);
  14532.             }
  14533.            
  14534.             //String[] tipi_validazione = { "xsd", "wsdl" };
  14535.             de = new DataElement();
  14536.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_TIPO);
  14537.             de.setName(CostantiControlStation.PARAMETRO_PORTE_TIPO_VALIDAZIONE);
  14538.             if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_TIPO_VALIDAZIONE_OPENSPCOOP.equals(tipoValidazione) && this.isModalitaStandard()) {
  14539.                 de.setType(DataElementType.HIDDEN);
  14540.                 de.setValue(tipoValidazione);
  14541.             }
  14542.             else {
  14543.                 de.setType(DataElementType.SELECT);
  14544.                 de.setValues(tipiValidazione);
  14545.                 de.setLabels(labelTipiValidazione);
  14546.                 de.setSelected(tipoValidazione);
  14547.             }
  14548.             dati.add(de);
  14549.            
  14550.             if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_TIPO_VALIDAZIONE_OPENSPCOOP.equals(tipoValidazione) && this.isModalitaStandard()) {
  14551.                 de = new DataElement();
  14552.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_TIPO);
  14553.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_TIPO_VALIDAZIONE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  14554.                 de.setType(DataElementType.TEXT);
  14555.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_REGISTRO_OPENSPCOOP);
  14556.                 dati.add(de);
  14557.             }
  14558.            
  14559.            
  14560.             // Applica MTOM
  14561.             de = new DataElement();
  14562.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_ACCETTA_MTOM);
  14563.             if(ServiceBinding.SOAP.equals(serviceBinding)) {
  14564.                 de.setType(DataElementType.CHECKBOX);
  14565.                 if( ServletUtils.isCheckBoxEnabled(applicaMTOM) || CostantiRegistroServizi.ABILITATO.equals(applicaMTOM) ){
  14566.                     de.setSelected(true);
  14567.                 }
  14568.             }
  14569.             else{
  14570.                 de.setType(DataElementType.HIDDEN);
  14571.                 de.setValue(applicaMTOM);
  14572.             }        
  14573.             de.setName(CostantiControlStation.PARAMETRO_PORTE_APPLICA_MTOM);
  14574.             dati.add(de);
  14575.         }
  14576.     }
  14577.    
  14578.     public boolean validazioneContenutiCheck(TipoOperazione tipoOperazione,boolean isPortaDelegata) throws DriverControlStationException {
  14579.         String xsd = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_XSD);
  14580.        
  14581.         // Controllo che i campi "select" abbiano uno dei valori ammessi
  14582.         if (!xsd.equals(CostantiControlStation.DEFAULT_VALUE_ABILITATO) && !xsd.equals(CostantiControlStation.DEFAULT_VALUE_DISABILITATO) && !xsd.equals(CostantiControlStation.DEFAULT_VALUE_WARNING_ONLY)) {
  14583.             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_VALIDAZIONE_XSD_DEV_ESSERE_ABILITATO_DISABILITATO_O_WARNING_ONLY);
  14584.             return false;
  14585.         }
  14586.        
  14587.         return true;
  14588.     }
  14589.    
  14590.     public void addFilterAzione(Map<String,String> azioni, String azione, ServiceBinding serviceBinding) throws DriverControlStationException{
  14591.         String[] azioniDisponibiliList = new String [0];
  14592.         String[] azioniDisponibiliLabelList = new String [0];
  14593.         if(azioni!=null && azioni.size()>0) {
  14594.             azioniDisponibiliList = new String[azioni.size()];
  14595.             azioniDisponibiliLabelList = new String[azioni.size()];
  14596.             int i = 0;
  14597.             for (String string : azioni.keySet()) {
  14598.                 azioniDisponibiliList[i] = string;
  14599.                 azioniDisponibiliLabelList[i] = azioni.get(string);
  14600.                 if("Qualsiasi".equals(azioniDisponibiliLabelList[i])) {
  14601.                     azioniDisponibiliLabelList[i] = "Method e Path Qualsiasi";
  14602.                 }
  14603.                 i++;
  14604.             }
  14605.         }
  14606.        
  14607.         this.addFilterAzione(azioniDisponibiliList,azioniDisponibiliLabelList, azione, serviceBinding);      
  14608.     }
  14609.    
  14610.     public void addFilterAzione(String []azioni, String []azioniLabels, String azione, ServiceBinding serviceBinding) throws DriverControlStationException{
  14611.         try {
  14612.             String [] values = new String[azioni.length + 1];
  14613.             String [] labels = new String[azioni.length + 1];
  14614.             labels[0] = CostantiControlStation.LABEL_QUALSIASI;
  14615.             values[0] = CostantiControlStation.DEFAULT_VALUE_AZIONE_RISORSA_NON_SELEZIONATA;
  14616.             for (int i =0; i < azioni.length ; i ++) {
  14617.                 labels[i+1] = azioniLabels[i];
  14618.                 values[i+1] = azioni[i];
  14619.             }
  14620.            
  14621.             String selectedValue = StringUtils.isNotEmpty(azione) ? azione : CostantiControlStation.DEFAULT_VALUE_AZIONE_RISORSA_NON_SELEZIONATA;
  14622.            
  14623.             this.pd.addFilter(Filtri.FILTRO_AZIONE,
  14624.                     this.getLabelAzione(serviceBinding),
  14625.                     selectedValue, values, labels, false, this.getSize());
  14626.            
  14627.         } catch (Exception e) {
  14628.             this.logError("Exception: " + e.getMessage(), e);
  14629.             throw new DriverControlStationException(e);
  14630.         }
  14631.     }
  14632.    
  14633.    
  14634.     public void addConfigurazioneDumpToDati(TipoOperazione tipoOperazione,List<DataElement> dati, boolean showStato, String statoDump, boolean showRealtime, String realtime, String statoDumpRichiesta, String statoDumpRisposta,
  14635.             String dumpRichiestaIngressoHeader, String dumpRichiestaIngressoPayload, String dumpRichiestaIngressoPayloadParsing, String dumpRichiestaIngressoBody, String dumpRichiestaIngressoAttachments,
  14636.             String dumpRichiestaUscitaHeader, String dumpRichiestaUscitaPayload, String dumpRichiestaUscitaPayloadParsing, String dumpRichiestaUscitaBody, String dumpRichiestaUscitaAttachments,
  14637.             String dumpRispostaIngressoHeader, String dumpRispostaIngressoPayload, String dumpRispostaIngressoPayloadParsing, String dumpRispostaIngressoBody , String dumpRispostaIngressoAttachments,
  14638.             String dumpRispostaUscitaHeader, String dumpRispostaUscitaPayload, String dumpRispostaUscitaPayloadParsing, String dumpRispostaUscitaBody, String dumpRispostaUscitaAttachments,
  14639.             boolean portaApplicativa) throws DriverControlStationException{
  14640.        
  14641.         // TipoPdD
  14642.         DataElement de = new DataElement();
  14643.         de.setName(CostantiControlStation.PARAMETRO_DUMP_TIPO_CONFIGURAZIONE);
  14644.         de.setType(DataElementType.HIDDEN);
  14645.         de.setValue(portaApplicativa ? TipoPdD.APPLICATIVA.getTipo() : TipoPdD.DELEGATA.getTipo());
  14646.         dati.add(de);
  14647.        
  14648.         if(showStato || showRealtime) {
  14649.             de = new DataElement();
  14650.             de.setType(DataElementType.TITLE);
  14651.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_GENERALE);
  14652.             dati.add(de);
  14653.         }
  14654.            
  14655.         String valuesProp [] = {StatoFunzionalita.ABILITATO.getValue(), StatoFunzionalita.DISABILITATO.getValue()};
  14656.         String labelsProp [] = {CostantiControlStation.DEFAULT_VALUE_ABILITATO, CostantiControlStation.DEFAULT_VALUE_DISABILITATO};
  14657.        
  14658.         // stato generale dump
  14659.         de = new DataElement();
  14660.         de.setName(CostantiControlStation.PARAMETRO_DUMP_STATO);
  14661.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO);
  14662.         if(showStato) {
  14663.             try {
  14664.                 de.setType(DataElementType.SELECT);
  14665.                 String valuesStato [] = {CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_DEFAULT, CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO};
  14666.                 String labelsStato [] = {this.getDumpLabelDefault(true, portaApplicativa), CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_RIDEFINITO};
  14667.                 de.setSelected(statoDump);
  14668.                 de.setLabels(labelsStato);
  14669.                 de.setValues(valuesStato);
  14670.                 de.setPostBack(true);
  14671.             }catch(Exception e) {
  14672.                 throw new DriverControlStationException(e.getMessage(),e);
  14673.             }
  14674.         } else {
  14675.             de.setType(DataElementType.HIDDEN);
  14676.             de.setValue(statoDump);
  14677.         }
  14678.         dati.add(de);
  14679.        
  14680.         if(!showStato || statoDump.equals(CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO)) {
  14681.        
  14682.             // Realtime
  14683.             de = new DataElement();
  14684.             de.setName(CostantiControlStation.PARAMETRO_DUMP_REALTIME);
  14685.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_REALTIME);
  14686.             if(showRealtime) {
  14687.                 de.setType(DataElementType.SELECT);
  14688.                 de.setSelected(realtime);
  14689.                 de.setLabels(labelsProp);
  14690.                 de.setValues(valuesProp);
  14691.             } else {
  14692.                 de.setType(DataElementType.HIDDEN);
  14693.                 de.setValue(realtime);
  14694.             }
  14695.             dati.add(de);
  14696.            
  14697.             // Sezione Richiesta
  14698.             de = new DataElement();
  14699.             de.setType(DataElementType.TITLE);
  14700.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_RICHIESTA);
  14701.             dati.add(de);

  14702.             // Stato Dump Richiesta
  14703.             de = new DataElement();
  14704.             de.setName(CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_STATO);
  14705.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_STATO);
  14706.             de.setType(DataElementType.SELECT);
  14707.             de.setSelected(statoDumpRichiesta);
  14708.             de.setLabels(labelsProp);
  14709.             de.setValues(valuesProp);
  14710.             de.setPostBack(true);
  14711.             dati.add(de);
  14712.            
  14713.             if(statoDumpRichiesta.equals(StatoFunzionalita.ABILITATO.getValue())) {
  14714.                
  14715.                 try {
  14716.                    
  14717.                     // sotto sezione ingresso
  14718.                     addSottoSezioneDump(dati,
  14719.                             valuesProp, labelsProp,
  14720.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO,
  14721.                             CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_INGRESSO_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_HEADERS,dumpRichiestaIngressoHeader,
  14722.                             CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD, dumpRichiestaIngressoPayload,
  14723.                             CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD_PARSING, dumpRichiestaIngressoPayloadParsing,
  14724.                             CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_INGRESSO_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_BODY, dumpRichiestaIngressoBody,
  14725.                             CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_INGRESSO_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_ATTACHMENTS, dumpRichiestaIngressoAttachments
  14726.                             );
  14727.    
  14728.                                    
  14729.                     // sotto sezione uscita
  14730.                     addSottoSezioneDump(dati,
  14731.                             valuesProp, labelsProp,
  14732.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA,
  14733.                             CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_USCITA_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_HEADERS,dumpRichiestaUscitaHeader,
  14734.                             CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD, dumpRichiestaUscitaPayload,
  14735.                             CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD_PARSING, dumpRichiestaUscitaPayloadParsing,
  14736.                             CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_USCITA_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_BODY, dumpRichiestaUscitaBody,
  14737.                             CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_USCITA_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_ATTACHMENTS, dumpRichiestaUscitaAttachments
  14738.                             );
  14739.                    
  14740.                 }catch(Exception e) {
  14741.                     throw new DriverControlStationException(e.getMessage(),e);
  14742.                 }

  14743.             }
  14744.            
  14745.            
  14746.             // Sezione Risposta
  14747.             de = new DataElement();
  14748.             de.setType(DataElementType.TITLE);
  14749.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_RISPOSTA);
  14750.             dati.add(de);

  14751.             // Stato Dump Richiesta
  14752.             de = new DataElement();
  14753.             de.setName(CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_STATO);
  14754.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_STATO);
  14755.             de.setType(DataElementType.SELECT);
  14756.             de.setSelected(statoDumpRisposta);
  14757.             de.setLabels(labelsProp);
  14758.             de.setValues(valuesProp);
  14759.             de.setPostBack(true);  
  14760.             dati.add(de);
  14761.            
  14762.             if(statoDumpRisposta.equals(StatoFunzionalita.ABILITATO.getValue())) {
  14763.                
  14764.                 try {
  14765.                
  14766.                     // sotto sezione ingresso
  14767.                     addSottoSezioneDump(dati,
  14768.                             valuesProp, labelsProp,
  14769.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO,
  14770.                             CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_INGRESSO_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_HEADERS,dumpRispostaIngressoHeader,
  14771.                             CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD, dumpRispostaIngressoPayload,
  14772.                             CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD_PARSING, dumpRispostaIngressoPayloadParsing,
  14773.                             CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_INGRESSO_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_BODY, dumpRispostaIngressoBody,
  14774.                             CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_INGRESSO_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_ATTACHMENTS, dumpRispostaIngressoAttachments
  14775.                             );
  14776.    
  14777.                                    
  14778.                     // sotto sezione uscita
  14779.                     addSottoSezioneDump(dati,
  14780.                             valuesProp, labelsProp,
  14781.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA,
  14782.                             CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_USCITA_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_HEADERS,dumpRispostaUscitaHeader,
  14783.                             CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD, dumpRispostaUscitaPayload,
  14784.                             CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD_PARSING, dumpRispostaUscitaPayloadParsing,
  14785.                             CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_USCITA_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_BODY, dumpRispostaUscitaBody,
  14786.                             CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_USCITA_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_ATTACHMENTS, dumpRispostaUscitaAttachments
  14787.                             );

  14788.                 }catch(Exception e) {
  14789.                     throw new DriverControlStationException(e.getMessage(),e);
  14790.                 }
  14791.             }
  14792.         }
  14793.     }
  14794.    
  14795.     private void addSottoSezioneDump(List<DataElement> dati, String valuesProp [], String labelsProp [],
  14796.             String labelSezione,
  14797.             String paramHeaders, String labelHeaders, String dumpHeader,
  14798.             String paramPayload, String labelPayload, String dumpPayload,
  14799.             String paramPayloadParsing, String labelPayloadParsing, String dumpPayloadParsing,
  14800.             String paramBody, String labelBody, String dumpBody,
  14801.             String paramAttachments, String labelAttachments, String dumpAttachments) throws UtilsException {
  14802.        
  14803.         DataElement de = new DataElement();
  14804.         de.setType(DataElementType.SUBTITLE);
  14805.         de.setLabel(labelSezione);
  14806.         dati.add(de);
  14807.        
  14808.         // header
  14809.         de = new DataElement();
  14810.         de.setName(paramHeaders);
  14811.         de.setLabel(labelHeaders);
  14812.         de.setType(DataElementType.SELECT);
  14813.         de.setSelected(dumpHeader);
  14814.         de.setLabels(labelsProp);
  14815.         de.setValues(valuesProp);
  14816.         dati.add(de);
  14817.        
  14818.         boolean multipartPayloadParsing = this.core.isRegistrazioneMessaggiMultipartPayloadParsingEnabled();
  14819.         if(!multipartPayloadParsing) {
  14820.             // regole configurate con modalita' attiva
  14821.             if(StatoFunzionalita.ABILITATO.getValue().equals(dumpPayload) &&
  14822.                     StatoFunzionalita.ABILITATO.getValue().equals(dumpPayloadParsing)) {
  14823.                 multipartPayloadParsing = true;
  14824.             }
  14825.         }
  14826.        
  14827.         // payload
  14828.         de = new DataElement();
  14829.         de.setName(paramPayload);
  14830.         de.setLabel(labelPayload);
  14831.         de.setType(DataElementType.SELECT);
  14832.         de.setSelected(dumpPayload);
  14833.         de.setLabels(labelsProp);
  14834.         de.setValues(valuesProp);
  14835.         if(multipartPayloadParsing) {
  14836.             de.setPostBack(true);
  14837.         }
  14838.         dati.add(de);
  14839.        
  14840.         // payload parsing ingresso
  14841.         de = new DataElement();
  14842.         de.setName(paramPayloadParsing);
  14843.         de.setLabel(labelPayloadParsing);
  14844.         de.setValue(dumpPayloadParsing);
  14845.         if(multipartPayloadParsing && dumpPayload!=null && dumpPayload.equals(StatoFunzionalita.ABILITATO.getValue())) {
  14846.             de.setType(DataElementType.SELECT);
  14847.             de.setSelected(dumpPayloadParsing);
  14848.             de.setLabels(labelsProp);
  14849.             de.setValues(valuesProp);
  14850.             de.setPostBack(true);
  14851.         }
  14852.         else {
  14853.             de.setType(DataElementType.HIDDEN);
  14854.             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  14855.         }
  14856.         dati.add(de);
  14857.        
  14858.         // body ingresso
  14859.         de = new DataElement();
  14860.         de.setName(paramBody);
  14861.         de.setLabel(labelBody);
  14862.         de.setValue(dumpBody);
  14863.         if(multipartPayloadParsing && dumpPayloadParsing!=null && dumpPayloadParsing.equals(StatoFunzionalita.ABILITATO.getValue())) {
  14864.             de.setType(DataElementType.SELECT);
  14865.             de.setSelected(dumpBody);
  14866.             de.setLabels(labelsProp);
  14867.             de.setValues(valuesProp);
  14868.         }
  14869.         else {
  14870.             de.setType(DataElementType.HIDDEN);
  14871.             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  14872.         }
  14873.         dati.add(de);
  14874.        
  14875.         // attachments ingresso
  14876.         de = new DataElement();
  14877.         de.setName(paramAttachments);
  14878.         de.setLabel(labelAttachments);
  14879.         de.setValue(dumpAttachments);
  14880.         if(multipartPayloadParsing && dumpPayloadParsing!=null && dumpPayloadParsing.equals(StatoFunzionalita.ABILITATO.getValue())) {
  14881.             de.setType(DataElementType.SELECT);
  14882.             de.setSelected(dumpAttachments);
  14883.             de.setLabels(labelsProp);
  14884.             de.setValues(valuesProp);
  14885.         }
  14886.         else {
  14887.             de.setType(DataElementType.HIDDEN);
  14888.             de.setValue(StatoFunzionalita.DISABILITATO.getValue());
  14889.         }
  14890.         dati.add(de);
  14891.     }
  14892.    
  14893.     protected String getGestioneCorsLabelDefault(boolean usePrefixDefault) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  14894.        
  14895.         StringBuilder bf = new StringBuilder();
  14896.         if(usePrefixDefault) {
  14897.             bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT);
  14898.             bf.append(" (");
  14899.         }
  14900.         CorsConfigurazione cc = this.confCore.getConfigurazioneGenerale().getGestioneCors();
  14901.         if(cc==null || cc.getStato()==null) {
  14902.             bf.append(StatoFunzionalita.DISABILITATO.getValue());
  14903.         }
  14904.         else {
  14905.             if(StatoFunzionalita.DISABILITATO.equals(cc.getStato())) {
  14906.                 bf.append(cc.getStato().getValue());
  14907.             }
  14908.             else {
  14909.                 bf.append(getLabelTipoGestioneCors(cc.getTipo()));
  14910.             }
  14911.         }
  14912.         if(usePrefixDefault) {
  14913.             bf.append(")");
  14914.         }
  14915.         return bf.toString();
  14916.     }
  14917.    
  14918.     protected String getLabelTipoGestioneCors(TipoGestioneCORS tipo) {
  14919.         if(tipo==null || "".equals(tipo.toString())) {
  14920.             return "undefined";
  14921.         }
  14922.         if(TipoGestioneCORS.GATEWAY.equals(tipo)) {
  14923.             return StatoFunzionalita.ABILITATO.getValue();
  14924.         }
  14925.         else {
  14926.             return StatoFunzionalita.ABILITATO.getValue()+" (applicativo)";
  14927.         }
  14928.     }
  14929.    
  14930.     protected String getResponseCachingLabelDefault(boolean usePrefixDefault) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  14931.        
  14932.         StringBuilder bf = new StringBuilder();
  14933.         if(usePrefixDefault) {
  14934.             bf.append(CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT);
  14935.             bf.append(" (");
  14936.         }
  14937.         ResponseCachingConfigurazioneGenerale rg = this.confCore.getConfigurazioneGenerale().getResponseCaching();
  14938.         if(rg==null || rg.getConfigurazione()==null || rg.getConfigurazione().getStato()==null) {
  14939.             bf.append(StatoFunzionalita.DISABILITATO.getValue());
  14940.         }
  14941.         else {
  14942.             bf.append(rg.getConfigurazione().getStato().getValue());
  14943.         }
  14944.         if(usePrefixDefault) {
  14945.             bf.append(")");
  14946.         }
  14947.         return bf.toString();
  14948.     }
  14949.    
  14950.     protected String getDumpLabelDefault(boolean usePrefixDefault, boolean portaApplicativa) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  14951.         String labelDefault = CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT;
  14952.        
  14953.         Dump dConfig = this.confCore.getConfigurazioneGenerale().getDump();
  14954.         DumpConfigurazione dumpConfigurazione = null;
  14955.         if(dConfig!=null) {
  14956.             dumpConfigurazione = portaApplicativa ? dConfig.getConfigurazionePortaApplicativa() : dConfig.getConfigurazionePortaDelegata();
  14957.         }
  14958.        
  14959.         if(dConfig==null || dumpConfigurazione==null) {
  14960.             if(usePrefixDefault) {
  14961.                 labelDefault = CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT +" (disabilitato)";
  14962.             }
  14963.             else {
  14964.                 labelDefault = "disabilitato";
  14965.             }
  14966.         }
  14967.         else {
  14968.             boolean richiesta =
  14969.                     (
  14970.                         dumpConfigurazione.getRichiestaIngresso()!=null
  14971.                         &&
  14972.                         (
  14973.                                 StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaIngresso().getHeaders())
  14974.                                 ||
  14975.                                 (StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaIngresso().getPayload())
  14976.                                         &&
  14977.                                         (
  14978.                                         StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaIngresso().getBody())
  14979.                                         ||
  14980.                                         StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaIngresso().getAttachments())
  14981.                                         )
  14982.                                 )
  14983.                         )
  14984.                     )
  14985.                     ||
  14986.                     (
  14987.                         dumpConfigurazione.getRichiestaUscita()!=null
  14988.                         &&
  14989.                         (
  14990.                                 StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaUscita().getHeaders())
  14991.                                 ||
  14992.                                 (StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaUscita().getPayload())
  14993.                                         &&
  14994.                                         (
  14995.                                         StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaUscita().getBody())
  14996.                                         ||
  14997.                                         StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRichiestaUscita().getAttachments())
  14998.                                         )
  14999.                                 )
  15000.                         )
  15001.                     )
  15002.                     ;
  15003.             boolean risposta =
  15004.                 (
  15005.                     dumpConfigurazione.getRispostaIngresso()!=null
  15006.                     &&
  15007.                     (
  15008.                             StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaIngresso().getHeaders())
  15009.                             ||
  15010.                             (StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaIngresso().getPayload())
  15011.                                     &&
  15012.                                     (
  15013.                                     StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaIngresso().getBody())
  15014.                                     ||
  15015.                                     StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaIngresso().getAttachments())
  15016.                                     )
  15017.                             )
  15018.                     )
  15019.                 )
  15020.                 ||
  15021.                 (
  15022.                     dumpConfigurazione.getRispostaUscita()!=null
  15023.                     &&
  15024.                     (
  15025.                             StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaUscita().getHeaders())
  15026.                             ||
  15027.                             (StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaUscita().getPayload())
  15028.                                     &&
  15029.                                     (
  15030.                                     StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaUscita().getBody())
  15031.                                     ||
  15032.                                     StatoFunzionalita.ABILITATO.equals(dumpConfigurazione.getRispostaUscita().getAttachments())
  15033.                                     )
  15034.                             )
  15035.                     )
  15036.                 )
  15037.                 ;
  15038.             if(richiesta && risposta) {
  15039.                 if(usePrefixDefault) {
  15040.                     labelDefault = CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT +" (abilitato)";
  15041.                 }
  15042.                 else {
  15043.                     labelDefault = "abilitato";
  15044.                 }
  15045.             }
  15046.             else if(richiesta) {
  15047.                 if(usePrefixDefault) {
  15048.                     labelDefault = CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT +" (abilitato richiesta)";
  15049.                 }
  15050.                 else {
  15051.                     labelDefault = "abilitato richiesta";
  15052.                 }
  15053.             }
  15054.             else if(risposta) {
  15055.                 if(usePrefixDefault) {
  15056.                     labelDefault = CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT +" (abilitato risposta)";
  15057.                 }
  15058.                 else {
  15059.                     labelDefault = "abilitato risposta";
  15060.                 }
  15061.             }
  15062.             else {
  15063.                 if(usePrefixDefault) {
  15064.                     labelDefault = CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT +" (disabilitato)";
  15065.                 }
  15066.                 else {
  15067.                     labelDefault = "disabilitato";
  15068.                 }
  15069.             }
  15070.            
  15071.         }
  15072.         return labelDefault;
  15073.     }
  15074.    
  15075.     public void addConfigurazioneDumpToDatiAsHidden(TipoOperazione tipoOperazione,List<DataElement> dati, boolean showStato, String statoDump, boolean showRealtime, String realtime, String statoDumpRichiesta, String statoDumpRisposta,
  15076.             String dumpRichiestaIngressoHeader, String dumpRichiestaIngressoPayload, String dumpRichiestaIngressoPayloadParsing, String dumpRichiestaIngressoBody, String dumpRichiestaIngressoAttachments,
  15077.             String dumpRichiestaUscitaHeader, String dumpRichiestaUscitaPayload, String dumpRichiestaUscitaPayloadParsing, String dumpRichiestaUscitaBody, String dumpRichiestaUscitaAttachments,
  15078.             String dumpRispostaIngressoHeader, String dumpRispostaIngressoPayload, String dumpRispostaIngressoPayloadParsing, String dumpRispostaIngressoBody , String dumpRispostaIngressoAttachments,
  15079.             String dumpRispostaUscitaHeader, String dumpRispostaUscitaPayload, String dumpRispostaUscitaPayloadParsing, String dumpRispostaUscitaBody, String dumpRispostaUscitaAttachments,
  15080.             boolean portaApplicativa) throws DriverControlStationException{
  15081.        
  15082.         // stato generale dump
  15083.         DataElement de = new DataElement();
  15084.         de.setName(CostantiControlStation.PARAMETRO_DUMP_STATO);
  15085.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO);
  15086.         de.setType(DataElementType.HIDDEN);
  15087.         de.setValue(statoDump);
  15088.         dati.add(de);
  15089.        
  15090.         // TipoPdD
  15091.         de = new DataElement();
  15092.         de.setName(CostantiControlStation.PARAMETRO_DUMP_TIPO_CONFIGURAZIONE);
  15093.         de.setType(DataElementType.HIDDEN);
  15094.         de.setValue(portaApplicativa ? TipoPdD.APPLICATIVA.getTipo() : TipoPdD.DELEGATA.getTipo());
  15095.         dati.add(de);
  15096.        
  15097.         if(!showStato || statoDump.equals(CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO)) {
  15098.        
  15099.             // Realtime
  15100.             de = new DataElement();
  15101.             de.setName(CostantiControlStation.PARAMETRO_DUMP_REALTIME);
  15102.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_REALTIME);
  15103.             de.setType(DataElementType.HIDDEN);
  15104.             de.setValue(realtime);
  15105.             dati.add(de);
  15106.            
  15107.             // Stato Dump Richiesta
  15108.             de = new DataElement();
  15109.             de.setName(CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_STATO);
  15110.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_STATO);
  15111.             de.setType(DataElementType.HIDDEN);
  15112.             de.setValue(statoDumpRichiesta);
  15113.             dati.add(de);
  15114.            
  15115.             if(statoDumpRichiesta.equals(StatoFunzionalita.ABILITATO.getValue())) {
  15116.                
  15117.                 // sotto sezione ingresso
  15118.                 addSottoSezioneDumpHidden(dati,
  15119.                         CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_INGRESSO_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_HEADERS,dumpRichiestaIngressoHeader,
  15120.                         CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD, dumpRichiestaIngressoPayload,
  15121.                         CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD_PARSING, dumpRichiestaIngressoPayloadParsing,
  15122.                         CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_INGRESSO_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_BODY, dumpRichiestaIngressoBody,
  15123.                         CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_INGRESSO_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_ATTACHMENTS, dumpRichiestaIngressoAttachments
  15124.                         );

  15125.                                
  15126.                 // sotto sezione uscita
  15127.                 addSottoSezioneDumpHidden(dati,
  15128.                         CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_USCITA_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_HEADERS,dumpRichiestaUscitaHeader,
  15129.                         CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD, dumpRichiestaUscitaPayload,
  15130.                         CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD_PARSING, dumpRichiestaUscitaPayloadParsing,
  15131.                         CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_USCITA_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_BODY, dumpRichiestaUscitaBody,
  15132.                         CostantiControlStation.PARAMETRO_DUMP_RICHIESTA_USCITA_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_ATTACHMENTS, dumpRichiestaUscitaAttachments
  15133.                         );
  15134.                
  15135.             }
  15136.            

  15137.             // Stato Dump Richiesta
  15138.             de = new DataElement();
  15139.             de.setName(CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_STATO);
  15140.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_STATO);
  15141.             de.setType(DataElementType.HIDDEN);
  15142.             de.setValue(statoDumpRisposta);
  15143.             dati.add(de);
  15144.            
  15145.             if(statoDumpRisposta.equals(StatoFunzionalita.ABILITATO.getValue())) {
  15146.                
  15147.                 // sotto sezione ingresso
  15148.                 addSottoSezioneDumpHidden(dati,
  15149.                         CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_INGRESSO_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_HEADERS,dumpRispostaIngressoHeader,
  15150.                         CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD, dumpRispostaIngressoPayload,
  15151.                         CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD_PARSING, dumpRispostaIngressoPayloadParsing,
  15152.                         CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_INGRESSO_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_BODY, dumpRispostaIngressoBody,
  15153.                         CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_INGRESSO_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_ATTACHMENTS, dumpRispostaIngressoAttachments
  15154.                         );

  15155.                                
  15156.                 // sotto sezione uscita
  15157.                 addSottoSezioneDumpHidden(dati,
  15158.                         CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_USCITA_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_HEADERS,dumpRispostaUscitaHeader,
  15159.                         CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD, dumpRispostaUscitaPayload,
  15160.                         CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD_PARSING, dumpRispostaUscitaPayloadParsing,
  15161.                         CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_USCITA_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_BODY, dumpRispostaUscitaBody,
  15162.                         CostantiControlStation.PARAMETRO_DUMP_RISPOSTA_USCITA_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_ATTACHMENTS, dumpRispostaUscitaAttachments
  15163.                         );

  15164.             }
  15165.         }
  15166.     }
  15167.    
  15168.     private void addSottoSezioneDumpHidden(List<DataElement> dati,
  15169.             String paramHeaders, String labelHeaders, String dumpHeader,
  15170.             String paramPayload, String labelPayload, String dumpPayload,
  15171.             String paramPayloadParsing, String labelPayloadParsing, String dumpPayloadParsing,
  15172.             String paramBody, String labelBody, String dumpBody,
  15173.             String paramAttachments, String labelAttachments, String dumpAttachments) {
  15174.        
  15175.         // header
  15176.         DataElement de = new DataElement();
  15177.         de.setName(paramHeaders);
  15178.         de.setLabel(labelHeaders);
  15179.         de.setType(DataElementType.HIDDEN);
  15180.         de.setValue(dumpHeader);
  15181.         dati.add(de);
  15182.        
  15183.         // payload
  15184.         de = new DataElement();
  15185.         de.setName(paramPayload);
  15186.         de.setLabel(labelPayload);
  15187.         de.setType(DataElementType.HIDDEN);
  15188.         de.setValue(dumpPayload);
  15189.         dati.add(de);
  15190.        
  15191.         // payload parsing
  15192.         de = new DataElement();
  15193.         de.setName(paramPayloadParsing);
  15194.         de.setLabel(labelPayloadParsing);
  15195.         de.setType(DataElementType.HIDDEN);
  15196.         de.setValue(dumpPayloadParsing);
  15197.         dati.add(de);
  15198.        
  15199.         // body
  15200.         de = new DataElement();
  15201.         de.setName(paramBody);
  15202.         de.setLabel(labelBody);
  15203.         de.setType(DataElementType.HIDDEN);
  15204.         de.setValue(dumpBody);
  15205.         dati.add(de);
  15206.        
  15207.         // attachments
  15208.         de = new DataElement();
  15209.         de.setName(paramAttachments);
  15210.         de.setLabel(labelAttachments);
  15211.         de.setType(DataElementType.HIDDEN);
  15212.         de.setValue(dumpAttachments);
  15213.         dati.add(de);
  15214.     }
  15215.    
  15216.     public boolean checkDataConfigurazioneDump(TipoOperazione tipoOperazione,boolean showStato, String statoDump, boolean showRealtime, String realtime, String statoDumpRichiesta, String statoDumpRisposta,
  15217.             String dumpRichiestaIngressoHeader, String dumpRichiestaIngressoPayload, String dumpRichiestaIngressoPayloadParsing, String dumpRichiestaIngressoBody, String dumpRichiestaIngressoAttachments,
  15218.             String dumpRichiestaUscitaHeader, String dumpRichiestaUscitaPayload, String dumpRichiestaUscitaPayloadParsing, String dumpRichiestaUscitaBody, String dumpRichiestaUscitaAttachments,
  15219.             String dumpRispostaIngressoHeader, String dumpRispostaIngressoPayload, String dumpRispostaIngressoPayloadParsing, String dumpRispostaIngressoBody , String dumpRispostaIngressoAttachments,
  15220.             String dumpRispostaUscitaHeader, String dumpRispostaUscitaPayload, String dumpRispostaUscitaPayloadParsing, String dumpRispostaUscitaBody, String dumpRispostaUscitaAttachments) throws DriverControlStationException{
  15221.        
  15222.         if(showStato) {
  15223.             if(StringUtils.isEmpty(statoDump) || !(statoDump.equals(CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_DEFAULT) || statoDump.equals(CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO))) {
  15224.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_NON_VALIDO, CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO));
  15225.                 return false;
  15226.             }
  15227.         }
  15228.        
  15229.         if(!showStato || statoDump.equals(CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO)) {
  15230.             // realtime
  15231.             if(StringUtils.isEmpty(realtime) || !(realtime.equals(StatoFunzionalita.ABILITATO.getValue()) || realtime.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15232.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_NON_VALIDO, CostantiControlStation.LABEL_PARAMETRO_DUMP_REALTIME));
  15233.                 return false;
  15234.             }
  15235.            
  15236.             // statoDumpRichiesta
  15237.             if(StringUtils.isEmpty(statoDumpRichiesta) || !(statoDumpRichiesta.equals(StatoFunzionalita.ABILITATO.getValue()) || statoDumpRichiesta.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15238.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_DELLA_YY_NON_VALIDO,
  15239.                         CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15240.                 return false;
  15241.             }
  15242.            
  15243.             if(statoDumpRichiesta.equals(StatoFunzionalita.ABILITATO.getValue())){
  15244.                
  15245.                 // dumpRichiestaIngressoHeader
  15246.                 if(StringUtils.isEmpty(dumpRichiestaIngressoHeader) || !(dumpRichiestaIngressoHeader.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRichiestaIngressoHeader.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15247.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15248.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15249.                     return false;
  15250.                 }
  15251.                 // dumpRichiestaIngressoPayload
  15252.                 if(StringUtils.isEmpty(dumpRichiestaIngressoPayload) || !(dumpRichiestaIngressoPayload.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRichiestaIngressoPayload.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15253.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15254.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15255.                     return false;
  15256.                 }
  15257.                 // dumpRichiestaIngressoPayloadParsing
  15258.                 if(StringUtils.isEmpty(dumpRichiestaIngressoPayloadParsing) || !(dumpRichiestaIngressoPayloadParsing.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRichiestaIngressoPayloadParsing.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15259.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15260.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15261.                     return false;
  15262.                 }
  15263.                 // dumpRichiestaIngressoBody
  15264.                 if(StringUtils.isEmpty(dumpRichiestaIngressoBody) || !(dumpRichiestaIngressoBody.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRichiestaIngressoBody.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15265.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15266.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15267.                     return false;
  15268.                 }
  15269.                 // dumpRichiestaIngressoAttachments
  15270.                 if(StringUtils.isEmpty(dumpRichiestaIngressoAttachments) || !(dumpRichiestaIngressoAttachments.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRichiestaIngressoAttachments.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15271.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15272.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_INGRESSO_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15273.                     return false;
  15274.                 }
  15275.                                
  15276.                
  15277.                 // dumpRichiestaUscitaHeader
  15278.                 if(StringUtils.isEmpty(dumpRichiestaUscitaHeader) || !(dumpRichiestaUscitaHeader.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRichiestaUscitaHeader.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15279.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15280.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15281.                     return false;
  15282.                 }
  15283.                 // dumpRichiestaUscitaPayload
  15284.                 if(StringUtils.isEmpty(dumpRichiestaUscitaPayload) || !(dumpRichiestaUscitaPayload.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRichiestaUscitaPayload.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15285.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15286.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15287.                     return false;
  15288.                 }  
  15289.                 // dumpRichiestaUscitaPayloadParsing
  15290.                 if(StringUtils.isEmpty(dumpRichiestaUscitaPayloadParsing) || !(dumpRichiestaUscitaPayloadParsing.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRichiestaUscitaPayloadParsing.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15291.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15292.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15293.                     return false;
  15294.                 }  
  15295.                 // dumpRichiestaUscitaBody
  15296.                 if(StringUtils.isEmpty(dumpRichiestaUscitaBody) || !(dumpRichiestaUscitaBody.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRichiestaUscitaBody.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15297.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15298.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15299.                     return false;
  15300.                 }              
  15301.                 // dumpRichiestaUscitaAttachments
  15302.                 if(StringUtils.isEmpty(dumpRichiestaUscitaAttachments) || !(dumpRichiestaUscitaAttachments.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRichiestaUscitaAttachments.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15303.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15304.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RICHIESTA_USCITA_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15305.                     return false;
  15306.                 }
  15307.                
  15308.                
  15309.                 // se e' abilitato il dump per la richiesta almeno una singola voce deve essere abilitata
  15310.                 if(dumpRichiestaIngressoHeader.equals(StatoFunzionalita.DISABILITATO.getValue()) && dumpRichiestaIngressoPayload.equals(StatoFunzionalita.DISABILITATO.getValue())
  15311.                     && dumpRichiestaUscitaHeader.equals(StatoFunzionalita.DISABILITATO.getValue()) && dumpRichiestaUscitaPayload.equals(StatoFunzionalita.DISABILITATO.getValue())
  15312.                     ) {
  15313.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMP_DATI_INCOMPLETI_E_NECESSARIO_ABILITARE_UNA_VOCE, CostantiControlStation.LABEL_PARAMETRO_RICHIESTA));
  15314.                     return false;
  15315.                 }
  15316.                 if(dumpRichiestaIngressoPayload.equals(StatoFunzionalita.ABILITATO.getValue()) && dumpRichiestaIngressoPayloadParsing.equals(StatoFunzionalita.ABILITATO.getValue())) {
  15317.                     if(dumpRichiestaIngressoBody.equals(StatoFunzionalita.DISABILITATO.getValue())
  15318.                             && dumpRichiestaIngressoAttachments.equals(StatoFunzionalita.DISABILITATO.getValue())
  15319.                     ) {
  15320.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMP_DATI_INCOMPLETI_E_NECESSARIO_ABILITARE_UNA_VOCE_PAYLOAD_PARSING,
  15321.                                 CostantiControlStation.LABEL_PARAMETRO_RICHIESTA+" "+CostantiControlStation.LABEL_PARAMETRO_INGRESSO));
  15322.                         return false;
  15323.                     }
  15324.                 }
  15325.                 if(dumpRichiestaUscitaPayload.equals(StatoFunzionalita.ABILITATO.getValue()) && dumpRichiestaUscitaPayloadParsing.equals(StatoFunzionalita.ABILITATO.getValue())) {
  15326.                     if(dumpRichiestaUscitaBody.equals(StatoFunzionalita.DISABILITATO.getValue())
  15327.                             && dumpRichiestaUscitaAttachments.equals(StatoFunzionalita.DISABILITATO.getValue())
  15328.                     ) {
  15329.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMP_DATI_INCOMPLETI_E_NECESSARIO_ABILITARE_UNA_VOCE_PAYLOAD_PARSING,
  15330.                                 CostantiControlStation.LABEL_PARAMETRO_RICHIESTA+" "+CostantiControlStation.LABEL_PARAMETRO_USCITA));
  15331.                         return false;
  15332.                     }
  15333.                 }
  15334.             }
  15335.            
  15336.             // statoDumpRisposta
  15337.             if(StringUtils.isEmpty(statoDumpRisposta) || !(statoDumpRisposta.equals(StatoFunzionalita.ABILITATO.getValue()) || statoDumpRisposta.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15338.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_DELLA_YY_NON_VALIDO,
  15339.                         CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15340.                 return false;
  15341.             }
  15342.            
  15343.             if(statoDumpRisposta.equals(StatoFunzionalita.ABILITATO.getValue())) {
  15344.                
  15345.                 // dumpRispostaIngressoHeader
  15346.                 if(StringUtils.isEmpty(dumpRispostaIngressoHeader) || !(dumpRispostaIngressoHeader.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRispostaIngressoHeader.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15347.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15348.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15349.                     return false;
  15350.                 }
  15351.                 // dumpRispostaIngressoPayload
  15352.                 if(StringUtils.isEmpty(dumpRispostaIngressoPayload) || !(dumpRispostaIngressoPayload.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRispostaIngressoPayload.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15353.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15354.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15355.                     return false;
  15356.                 }
  15357.                 // dumpRispostaIngressoPayloadParsing
  15358.                 if(StringUtils.isEmpty(dumpRispostaIngressoPayloadParsing) || !(dumpRispostaIngressoPayloadParsing.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRispostaIngressoPayloadParsing.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15359.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15360.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15361.                     return false;
  15362.                 }
  15363.                 // dumpRispostaIngressoBody
  15364.                 if(StringUtils.isEmpty(dumpRispostaIngressoBody) || !(dumpRispostaIngressoBody.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRispostaIngressoBody.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15365.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15366.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15367.                     return false;
  15368.                 }
  15369.                 // dumpRispostaIngressoAttachments
  15370.                 if(StringUtils.isEmpty(dumpRispostaIngressoAttachments) || !(dumpRispostaIngressoAttachments.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRispostaIngressoAttachments.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15371.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15372.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_INGRESSO_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_INGRESSO, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15373.                     return false;
  15374.                 }
  15375.                                
  15376.                
  15377.                 // dumpRispostaUscitaHeader
  15378.                 if(StringUtils.isEmpty(dumpRispostaUscitaHeader) || !(dumpRispostaUscitaHeader.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRispostaUscitaHeader.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15379.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15380.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_HEADERS, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15381.                     return false;
  15382.                 }
  15383.                 // dumpRispostaUscitaPayload
  15384.                 if(StringUtils.isEmpty(dumpRispostaUscitaPayload) || !(dumpRispostaUscitaPayload.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRispostaUscitaPayload.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15385.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15386.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15387.                     return false;
  15388.                 }  
  15389.                 // dumpRispostaUscitaPayloadParsing
  15390.                 if(StringUtils.isEmpty(dumpRispostaUscitaPayloadParsing) || !(dumpRispostaUscitaPayloadParsing.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRispostaUscitaPayloadParsing.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15391.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15392.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_PAYLOAD_PARSING, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15393.                     return false;
  15394.                 }  
  15395.                 // dumpRispostaUscitaBody
  15396.                 if(StringUtils.isEmpty(dumpRispostaUscitaBody) || !(dumpRispostaUscitaBody.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRispostaUscitaBody.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15397.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15398.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_BODY, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15399.                     return false;
  15400.                 }              
  15401.                 // dumpRispostaUscitaAttachments
  15402.                 if(StringUtils.isEmpty(dumpRispostaUscitaAttachments) || !(dumpRispostaUscitaAttachments.equals(StatoFunzionalita.ABILITATO.getValue()) || dumpRispostaUscitaAttachments.equals(StatoFunzionalita.DISABILITATO.getValue()))) {
  15403.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_YY_DELLA_ZZ_NON_VALIDO,
  15404.                             CostantiControlStation.LABEL_PARAMETRO_DUMP_RISPOSTA_USCITA_ATTACHMENTS, CostantiControlStation.LABEL_PARAMETRO_DUMP_SEZIONE_USCITA, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15405.                     return false;
  15406.                 }
  15407.                
  15408.                
  15409.                 // se e' abilitato il dump per la richiesta almeno una singola voce deve essere abilitata
  15410.                 if(dumpRispostaIngressoHeader.equals(StatoFunzionalita.DISABILITATO.getValue()) && dumpRispostaIngressoPayload.equals(StatoFunzionalita.DISABILITATO.getValue())
  15411.                     && dumpRispostaUscitaHeader.equals(StatoFunzionalita.DISABILITATO.getValue()) && dumpRispostaUscitaPayload.equals(StatoFunzionalita.DISABILITATO.getValue())
  15412.                     ) {
  15413.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMP_DATI_INCOMPLETI_E_NECESSARIO_ABILITARE_UNA_VOCE, CostantiControlStation.LABEL_PARAMETRO_RISPOSTA));
  15414.                     return false;
  15415.                 }
  15416.                 if(dumpRispostaIngressoPayload.equals(StatoFunzionalita.ABILITATO.getValue()) && dumpRispostaIngressoPayloadParsing.equals(StatoFunzionalita.ABILITATO.getValue())) {
  15417.                     if(dumpRispostaIngressoBody.equals(StatoFunzionalita.DISABILITATO.getValue())
  15418.                             && dumpRispostaIngressoAttachments.equals(StatoFunzionalita.DISABILITATO.getValue())
  15419.                     ) {
  15420.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMP_DATI_INCOMPLETI_E_NECESSARIO_ABILITARE_UNA_VOCE_PAYLOAD_PARSING,
  15421.                                 CostantiControlStation.LABEL_PARAMETRO_RISPOSTA+" "+CostantiControlStation.LABEL_PARAMETRO_INGRESSO));
  15422.                         return false;
  15423.                     }
  15424.                 }
  15425.                 if(dumpRispostaUscitaPayload.equals(StatoFunzionalita.ABILITATO.getValue()) && dumpRispostaUscitaPayloadParsing.equals(StatoFunzionalita.ABILITATO.getValue())) {
  15426.                     if(dumpRispostaUscitaBody.equals(StatoFunzionalita.DISABILITATO.getValue())
  15427.                             && dumpRispostaUscitaAttachments.equals(StatoFunzionalita.DISABILITATO.getValue())
  15428.                     ) {
  15429.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMP_DATI_INCOMPLETI_E_NECESSARIO_ABILITARE_UNA_VOCE_PAYLOAD_PARSING,
  15430.                                 CostantiControlStation.LABEL_PARAMETRO_RISPOSTA+" "+CostantiControlStation.LABEL_PARAMETRO_USCITA));
  15431.                         return false;
  15432.                     }
  15433.                 }
  15434.             }
  15435.            
  15436.             /*
  15437.              * Vorrei poterla ridefinire disabilitata
  15438.             if (!statoDumpRichiesta.equals(StatoFunzionalita.ABILITATO.getValue())  && !statoDumpRisposta.equals(StatoFunzionalita.ABILITATO.getValue())) {
  15439.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMP_DATI_INCOMPLETI_E_NECESSARIO_ABILITARE_UNA_VOCE_TRA_RICHIESTA_E_RISPOSTA);
  15440.                 return false;
  15441.             }
  15442.             */
  15443.         }
  15444.        
  15445.        
  15446.         return true;
  15447.     }
  15448.    
  15449.     public DumpConfigurazione getConfigurazioneDump(TipoOperazione tipoOperazione,boolean showStato, String statoDump, boolean showRealtime, String realtime, String statoDumpRichiesta, String statoDumpRisposta,
  15450.             String dumpRichiestaIngressoHeader, String dumpRichiestaIngressoPayload, String dumpRichiestaIngressoPayloadParsing, String dumpRichiestaIngressoBody, String dumpRichiestaIngressoAttachments,
  15451.             String dumpRichiestaUscitaHeader, String dumpRichiestaUscitaPayload, String dumpRichiestaUscitaPayloadParsing, String dumpRichiestaUscitaBody, String dumpRichiestaUscitaAttachments,
  15452.             String dumpRispostaIngressoHeader, String dumpRispostaIngressoPayload, String dumpRispostaIngressoPayloadParsing, String dumpRispostaIngressoBody , String dumpRispostaIngressoAttachments,
  15453.             String dumpRispostaUscitaHeader, String dumpRispostaUscitaPayload, String dumpRispostaUscitaPayloadParsing, String dumpRispostaUscitaBody, String dumpRispostaUscitaAttachments) throws DriverControlStationException{
  15454.        
  15455.         DumpConfigurazione newConfigurazione = null;
  15456.        
  15457.         if(showStato) {
  15458.             // impostazioni dump di default impostate nelle PD/PA
  15459.             if(statoDump.equals(CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_DEFAULT))
  15460.                 return newConfigurazione;
  15461.         }
  15462.        
  15463.         if(!showStato || statoDump.equals(CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO)) {
  15464.            
  15465.             newConfigurazione = new DumpConfigurazione();
  15466.             newConfigurazione.setRichiestaIngresso(new DumpConfigurazioneRegola());
  15467.             newConfigurazione.setRichiestaUscita(new DumpConfigurazioneRegola());
  15468.             newConfigurazione.setRispostaIngresso(new DumpConfigurazioneRegola());
  15469.             newConfigurazione.setRispostaUscita(new DumpConfigurazioneRegola());
  15470.            
  15471.             // realtime        
  15472.             newConfigurazione.setRealtimeRawEnumValue(realtime);

  15473.             if(statoDumpRichiesta.equals(StatoFunzionalita.ABILITATO.getValue())) {
  15474.                 newConfigurazione.getRichiestaIngresso().setHeadersRawEnumValue(dumpRichiestaIngressoHeader);
  15475.                 newConfigurazione.getRichiestaIngresso().setPayloadRawEnumValue(dumpRichiestaIngressoPayload);
  15476.                 if(StatoFunzionalita.ABILITATO.equals(newConfigurazione.getRichiestaIngresso().getPayload())){
  15477.                     newConfigurazione.getRichiestaIngresso().setPayloadParsingRawEnumValue(dumpRichiestaIngressoPayloadParsing);
  15478.                     if(StatoFunzionalita.ABILITATO.equals(newConfigurazione.getRichiestaIngresso().getPayloadParsing())){
  15479.                         newConfigurazione.getRichiestaIngresso().setBodyRawEnumValue(dumpRichiestaIngressoBody);
  15480.                         newConfigurazione.getRichiestaIngresso().setAttachmentsRawEnumValue(dumpRichiestaIngressoAttachments);
  15481.                     }
  15482.                     else {
  15483.                         newConfigurazione.getRichiestaIngresso().setBody(StatoFunzionalita.DISABILITATO);
  15484.                         newConfigurazione.getRichiestaIngresso().setAttachments(StatoFunzionalita.DISABILITATO);
  15485.                     }
  15486.                 }
  15487.                 else {
  15488.                     newConfigurazione.getRichiestaIngresso().setPayloadParsing(StatoFunzionalita.DISABILITATO);
  15489.                     newConfigurazione.getRichiestaIngresso().setBody(StatoFunzionalita.DISABILITATO);
  15490.                     newConfigurazione.getRichiestaIngresso().setAttachments(StatoFunzionalita.DISABILITATO);
  15491.                 }
  15492.                
  15493.                 newConfigurazione.getRichiestaUscita().setHeadersRawEnumValue(dumpRichiestaUscitaHeader);
  15494.                 newConfigurazione.getRichiestaUscita().setPayloadRawEnumValue(dumpRichiestaUscitaPayload);
  15495.                 if(StatoFunzionalita.ABILITATO.equals(newConfigurazione.getRichiestaUscita().getPayload())){
  15496.                     newConfigurazione.getRichiestaUscita().setPayloadParsingRawEnumValue(dumpRichiestaUscitaPayloadParsing);
  15497.                     if(StatoFunzionalita.ABILITATO.equals(newConfigurazione.getRichiestaUscita().getPayloadParsing())){
  15498.                         newConfigurazione.getRichiestaUscita().setBodyRawEnumValue(dumpRichiestaUscitaBody);
  15499.                         newConfigurazione.getRichiestaUscita().setAttachmentsRawEnumValue(dumpRichiestaUscitaAttachments);
  15500.                     }
  15501.                     else {
  15502.                         newConfigurazione.getRichiestaUscita().setBody(StatoFunzionalita.DISABILITATO);
  15503.                         newConfigurazione.getRichiestaUscita().setAttachments(StatoFunzionalita.DISABILITATO);
  15504.                     }
  15505.                 }
  15506.                 else {
  15507.                     newConfigurazione.getRichiestaUscita().setPayloadParsing(StatoFunzionalita.DISABILITATO);
  15508.                     newConfigurazione.getRichiestaUscita().setBody(StatoFunzionalita.DISABILITATO);
  15509.                     newConfigurazione.getRichiestaUscita().setAttachments(StatoFunzionalita.DISABILITATO);
  15510.                 }
  15511.             } else {
  15512.                 newConfigurazione.getRichiestaIngresso().setHeaders(StatoFunzionalita.DISABILITATO);
  15513.                 newConfigurazione.getRichiestaIngresso().setPayload(StatoFunzionalita.DISABILITATO);
  15514.                 newConfigurazione.getRichiestaIngresso().setPayloadParsing(StatoFunzionalita.DISABILITATO);
  15515.                 newConfigurazione.getRichiestaIngresso().setBody(StatoFunzionalita.DISABILITATO);
  15516.                 newConfigurazione.getRichiestaIngresso().setAttachments(StatoFunzionalita.DISABILITATO);
  15517.                 newConfigurazione.getRichiestaUscita().setHeaders(StatoFunzionalita.DISABILITATO);
  15518.                 newConfigurazione.getRichiestaUscita().setPayload(StatoFunzionalita.DISABILITATO);
  15519.                 newConfigurazione.getRichiestaUscita().setPayloadParsing(StatoFunzionalita.DISABILITATO);
  15520.                 newConfigurazione.getRichiestaUscita().setBody(StatoFunzionalita.DISABILITATO);
  15521.                 newConfigurazione.getRichiestaUscita().setAttachments(StatoFunzionalita.DISABILITATO);
  15522.             }
  15523.            
  15524.             if(statoDumpRisposta.equals(StatoFunzionalita.ABILITATO.getValue())) {
  15525.                 newConfigurazione.getRispostaIngresso().setHeadersRawEnumValue(dumpRispostaIngressoHeader);
  15526.                 newConfigurazione.getRispostaIngresso().setPayloadRawEnumValue(dumpRispostaIngressoPayload);
  15527.                 if(StatoFunzionalita.ABILITATO.equals(newConfigurazione.getRispostaIngresso().getPayload())){
  15528.                     newConfigurazione.getRispostaIngresso().setPayloadParsingRawEnumValue(dumpRispostaIngressoPayloadParsing);
  15529.                     if(StatoFunzionalita.ABILITATO.equals(newConfigurazione.getRispostaIngresso().getPayloadParsing())){
  15530.                         newConfigurazione.getRispostaIngresso().setBodyRawEnumValue(dumpRispostaIngressoBody);
  15531.                         newConfigurazione.getRispostaIngresso().setAttachmentsRawEnumValue(dumpRispostaIngressoAttachments);
  15532.                     }
  15533.                     else {
  15534.                         newConfigurazione.getRispostaIngresso().setBody(StatoFunzionalita.DISABILITATO);
  15535.                         newConfigurazione.getRispostaIngresso().setAttachments(StatoFunzionalita.DISABILITATO);
  15536.                     }
  15537.                 }
  15538.                 else {
  15539.                     newConfigurazione.getRispostaIngresso().setPayloadParsing(StatoFunzionalita.DISABILITATO);
  15540.                     newConfigurazione.getRispostaIngresso().setBody(StatoFunzionalita.DISABILITATO);
  15541.                     newConfigurazione.getRispostaIngresso().setAttachments(StatoFunzionalita.DISABILITATO);
  15542.                 }
  15543.                
  15544.                 newConfigurazione.getRispostaUscita().setHeadersRawEnumValue(dumpRispostaUscitaHeader);
  15545.                 newConfigurazione.getRispostaUscita().setPayloadRawEnumValue(dumpRispostaUscitaPayload);
  15546.                 if(StatoFunzionalita.ABILITATO.equals(newConfigurazione.getRispostaUscita().getPayload())){
  15547.                     newConfigurazione.getRispostaUscita().setPayloadParsingRawEnumValue(dumpRispostaUscitaPayloadParsing);
  15548.                     if(StatoFunzionalita.ABILITATO.equals(newConfigurazione.getRispostaUscita().getPayloadParsing())){
  15549.                         newConfigurazione.getRispostaUscita().setBodyRawEnumValue(dumpRispostaUscitaBody);
  15550.                         newConfigurazione.getRispostaUscita().setAttachmentsRawEnumValue(dumpRispostaUscitaAttachments);
  15551.                     }
  15552.                     else {
  15553.                         newConfigurazione.getRispostaUscita().setBody(StatoFunzionalita.DISABILITATO);
  15554.                         newConfigurazione.getRispostaUscita().setAttachments(StatoFunzionalita.DISABILITATO);
  15555.                     }
  15556.                 }
  15557.                 else {
  15558.                     newConfigurazione.getRispostaUscita().setPayloadParsing(StatoFunzionalita.DISABILITATO);
  15559.                     newConfigurazione.getRispostaUscita().setBody(StatoFunzionalita.DISABILITATO);
  15560.                     newConfigurazione.getRispostaUscita().setAttachments(StatoFunzionalita.DISABILITATO);
  15561.                 }
  15562.             } else {
  15563.                 newConfigurazione.getRispostaIngresso().setHeaders(StatoFunzionalita.DISABILITATO);
  15564.                 newConfigurazione.getRispostaIngresso().setPayload(StatoFunzionalita.DISABILITATO);
  15565.                 newConfigurazione.getRispostaIngresso().setPayloadParsing(StatoFunzionalita.DISABILITATO);
  15566.                 newConfigurazione.getRispostaIngresso().setBody(StatoFunzionalita.DISABILITATO);
  15567.                 newConfigurazione.getRispostaIngresso().setAttachments(StatoFunzionalita.DISABILITATO);
  15568.                 newConfigurazione.getRispostaUscita().setHeaders(StatoFunzionalita.DISABILITATO);
  15569.                 newConfigurazione.getRispostaUscita().setBody(StatoFunzionalita.DISABILITATO);
  15570.                 newConfigurazione.getRispostaUscita().setPayload(StatoFunzionalita.DISABILITATO);
  15571.                 newConfigurazione.getRispostaUscita().setPayloadParsing(StatoFunzionalita.DISABILITATO);
  15572.                 newConfigurazione.getRispostaUscita().setAttachments(StatoFunzionalita.DISABILITATO);
  15573.             }
  15574.         }
  15575.        
  15576.         return newConfigurazione;
  15577.     }
  15578.    
  15579.     public boolean isDumpConfigurazioneAbilitato(DumpConfigurazione configurazione, boolean isRisposta) {
  15580.         boolean abilitato = false;
  15581.        
  15582.         if(configurazione == null)
  15583.             return false;
  15584.        
  15585.         if(isRisposta) {
  15586.             DumpConfigurazioneRegola rispostaIngresso = configurazione.getRispostaIngresso();
  15587.            
  15588.             if(rispostaIngresso != null) {
  15589.                 if(rispostaIngresso.getHeaders().equals(StatoFunzionalita.ABILITATO))
  15590.                     return true;
  15591.                
  15592.                 if(rispostaIngresso.getPayload().equals(StatoFunzionalita.ABILITATO)) {
  15593.                     if(rispostaIngresso.getPayloadParsing().equals(StatoFunzionalita.ABILITATO)) {
  15594.                         if(rispostaIngresso.getBody().equals(StatoFunzionalita.ABILITATO))
  15595.                             return true;
  15596.                        
  15597.                         if(rispostaIngresso.getAttachments().equals(StatoFunzionalita.ABILITATO))
  15598.                             return true;        
  15599.                     }
  15600.                     else {
  15601.                         return true;
  15602.                     }
  15603.                 }
  15604.                
  15605.             }
  15606.            
  15607.             DumpConfigurazioneRegola rispostaUscita = configurazione.getRispostaUscita();
  15608.            
  15609.             if(rispostaUscita != null) {
  15610.                 if(rispostaUscita.getHeaders().equals(StatoFunzionalita.ABILITATO))
  15611.                     return true;
  15612.                
  15613.                 if(rispostaUscita.getPayload().equals(StatoFunzionalita.ABILITATO)) {
  15614.                     if(rispostaUscita.getPayloadParsing().equals(StatoFunzionalita.ABILITATO)) {
  15615.                         if(rispostaUscita.getBody().equals(StatoFunzionalita.ABILITATO))
  15616.                             return true;
  15617.                        
  15618.                         if(rispostaUscita.getAttachments().equals(StatoFunzionalita.ABILITATO))
  15619.                             return true;        
  15620.                     }
  15621.                     else {
  15622.                         return true;
  15623.                     }
  15624.                 }
  15625.             }
  15626.         } else {
  15627.             DumpConfigurazioneRegola richiestaIngresso = configurazione.getRichiestaIngresso();
  15628.            
  15629.             if(richiestaIngresso != null) {
  15630.                 if(richiestaIngresso.getHeaders().equals(StatoFunzionalita.ABILITATO))
  15631.                     return true;
  15632.                
  15633.                 if(richiestaIngresso.getPayload().equals(StatoFunzionalita.ABILITATO)) {
  15634.                     if(richiestaIngresso.getPayloadParsing().equals(StatoFunzionalita.ABILITATO)) {
  15635.                         if(richiestaIngresso.getBody().equals(StatoFunzionalita.ABILITATO))
  15636.                             return true;
  15637.                        
  15638.                         if(richiestaIngresso.getAttachments().equals(StatoFunzionalita.ABILITATO))
  15639.                             return true;        
  15640.                     }
  15641.                     else {
  15642.                         return true;
  15643.                     }
  15644.                 }
  15645.             }
  15646.            
  15647.             DumpConfigurazioneRegola richiestaUscita = configurazione.getRichiestaUscita();
  15648.            
  15649.             if(richiestaUscita != null) {
  15650.                 if(richiestaUscita.getHeaders().equals(StatoFunzionalita.ABILITATO))
  15651.                     return true;
  15652.                
  15653.                 if(richiestaUscita.getPayload().equals(StatoFunzionalita.ABILITATO)) {
  15654.                     if(richiestaUscita.getPayloadParsing().equals(StatoFunzionalita.ABILITATO)) {
  15655.                         if(richiestaUscita.getBody().equals(StatoFunzionalita.ABILITATO))
  15656.                             return true;
  15657.                        
  15658.                         if(richiestaUscita.getAttachments().equals(StatoFunzionalita.ABILITATO))
  15659.                             return true;        
  15660.                     }
  15661.                     else {
  15662.                         return true;
  15663.                     }
  15664.                 }
  15665.             }
  15666.         }
  15667.        
  15668.         return abilitato;
  15669.     }
  15670.    
  15671.     public boolean isDumpConfigurazioneAbilitato(DumpConfigurazione configurazione) {
  15672.         return isDumpConfigurazioneAbilitato(configurazione, true) || isDumpConfigurazioneAbilitato(configurazione, false);
  15673.     }

  15674.     /** Gestione Properties MVC */
  15675.    
  15676.     public void aggiornaConfigurazioneProperties(ConfigBean configurazione) throws DriverControlStationException {
  15677.         ConfigBean oldConfigurazione = ServletUtils.readConfigurazioneBeanFromSession(this.request, this.session, configurazione.getId());
  15678.        
  15679.         ExternalResources externalResources = new ExternalResources();
  15680.         externalResources.setLog(ControlStationCore.getLog());
  15681.         externalResources.setTipoDB(this.confCore.getTipoDatabase());
  15682.         Connection con = DBManager.getInstance().getConnection();
  15683.         try {
  15684.             externalResources.setConnection(con);
  15685.        
  15686.             for (String key : configurazione.getListakeys()) {
  15687.                 Boolean oldItemVisible = oldConfigurazione != null ? oldConfigurazione.getItem(key).getVisible() : null;
  15688.                
  15689.                 BaseItemBean<?> o = configurazione.getItem(key);
  15690.                 o.setOldVisible(oldItemVisible);
  15691.                 try {
  15692.                     String parameterValue = null;
  15693.                     if(ItemType.LOCK.equals(o.getItemType()) || ItemType.LOCK_HIDDEN.equals(o.getItemType())) {
  15694.                         parameterValue = this.getLockedParameter(key);
  15695.                     }
  15696.                     else {
  15697.                         parameterValue = this.getParameter(key);
  15698.                     }
  15699.                     o.setValueFromRequest(parameterValue, externalResources, this.confCore.getLockUtilities());
  15700.                 }catch(Exception e) {
  15701.                     throw new DriverControlStationException(e.getMessage(),e);
  15702.                 }
  15703.             }
  15704.            
  15705.         }finally {
  15706.             DBManager.getInstance().releaseConnection(con);
  15707.         }
  15708.     }
  15709.     public List<DataElement> addPropertiesConfigToDati(TipoOperazione tipoOperazione, List<DataElement> dati, String configName, ConfigBean configurazioneBean) throws DriverControlStationException {
  15710.         return addPropertiesConfigToDati(tipoOperazione, dati, configName, configurazioneBean, true);
  15711.     }
  15712.    
  15713.     public List<DataElement> addPropertiesConfigToDati(TipoOperazione tipoOperazione, List<DataElement> dati, String configName, ConfigBean configurazioneBean, boolean addHiddenConfigName) throws DriverControlStationException {
  15714.         if(addHiddenConfigName) {
  15715.             DataElement de = new DataElement();
  15716.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PROPERTIES_CONFIG_NAME);
  15717.             de.setValue(configName);
  15718.             de.setType(DataElementType.HIDDEN);
  15719.             de.setName(CostantiControlStation.PARAMETRO_PROPERTIES_CONFIG_NAME);
  15720.             dati.add(de);
  15721.         }
  15722.         if(configurazioneBean != null) {
  15723.             ExternalResources externalResources = new ExternalResources();
  15724.             externalResources.setLog(ControlStationCore.getLog());
  15725.             externalResources.setTipoDB(this.confCore.getTipoDatabase());
  15726.             Connection con = DBManager.getInstance().getConnection();
  15727.             try {
  15728.                 externalResources.setConnection(con);
  15729.                 Map<String, String> mapNameValue = new HashMap<>();
  15730.                 for (BaseItemBean<?> item : configurazioneBean.getListaItem()) {
  15731.                     if(item.isVisible()) {
  15732.                         try {
  15733.                             dati.add(item.toDataElement(configurazioneBean, mapNameValue, externalResources, this.confCore.getLockUtilities()));
  15734.                         }catch(Exception e) {
  15735.                             throw new DriverControlStationException(e.getMessage(),e);
  15736.                         }
  15737.                     }
  15738.                 }
  15739.             }finally {
  15740.                 DBManager.getInstance().releaseConnection(con);
  15741.             }
  15742.         }
  15743.        
  15744.         return dati;
  15745.     }
  15746.    
  15747.     public boolean checkPropertiesConfigurationData(TipoOperazione tipoOperazione,ConfigBean configurazioneBean, String nome, String descrizione, Config config) throws DriverControlStationException{
  15748.         // Controlli sui campi immessi
  15749.         try {
  15750.             ExternalResources externalResources = new ExternalResources();
  15751.             externalResources.setLog(ControlStationCore.getLog());
  15752.             externalResources.setTipoDB(this.confCore.getTipoDatabase());
  15753.             Connection con = DBManager.getInstance().getConnection();
  15754.             try {
  15755.                 externalResources.setConnection(con);
  15756.                 configurazioneBean.validazioneInputUtente(nome, descrizione, config, externalResources);
  15757.             }finally {
  15758.                 DBManager.getInstance().releaseConnection(con);
  15759.             }
  15760.             return true;
  15761.         }catch(UserInputValidationException e) {
  15762.             this.pd.setMessage(e.getMessage());  
  15763.             return false;
  15764.         } catch(ProviderException e) {
  15765.             this.pd.setMessage("Si &egrave; verificato un errore durante la validazione, impossibile utilizzare il plugin di validazione previsto dalla configurazione");
  15766.             return false;
  15767.         } catch(ProviderValidationException e) {
  15768.             this.pd.setMessage(e.getMessage());  
  15769.             return false;
  15770.         } catch (Throwable e) {
  15771.             this.pd.setMessage("Si &egrave; verificato un errore durante la validazione, impossibile caricare il plugin di validazione previsto dalla configurazione");
  15772.             return false;      
  15773.         }
  15774.     }
  15775.    
  15776.     public boolean isFirstTimeFromHttpParameters(String firstTimeParameter) throws DriverControlStationException{
  15777.        
  15778.         String tmp = this.getParameter(firstTimeParameter);
  15779.         if(tmp!=null && !"".equals(tmp.trim())){
  15780.             return "true".equals(tmp.trim());
  15781.         }
  15782.         return true;
  15783.        
  15784.     }
  15785.    
  15786.     public void addToDatiFirstTimeDisabled(List<DataElement> dati,String firstTimeParameter){
  15787.         DataElement de = new DataElement();
  15788.         de.setName(firstTimeParameter);
  15789.         de.setType(DataElementType.HIDDEN);
  15790.         de.setValue("false");
  15791.         dati.add(de);
  15792.     }
  15793.    
  15794.     public void addToDatiHiddenParameter(List<DataElement> dati,String name, String value){
  15795.         DataElement de = new DataElement();
  15796.         de.setName(name);
  15797.         de.setType(DataElementType.HIDDEN);
  15798.         de.setValue(value);
  15799.         dati.add(de);
  15800.     }
  15801.    
  15802.     public boolean hasOnlyPermessiDiagnosticaReportistica(User user) throws DriverControlStationException {
  15803.         PermessiUtente pu = user.getPermessi();
  15804.         Boolean singlePdD = ServletUtils.getObjectFromSession(this.request, this.session, Boolean.class, CostantiControlStation.SESSION_PARAMETRO_SINGLE_PDD);
  15805.         if(singlePdD==null) {
  15806.             singlePdD = this.core!=null ? this.core.isSinglePdD() : true;
  15807.         }

  15808.         String isServizi = (pu.isServizi() ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  15809.         String isDiagnostica = (pu.isDiagnostica() ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  15810.         String isReportistica = (pu.isReportistica() ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  15811.         String isSistema = (pu.isSistema() ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  15812.         String isMessaggi = (pu.isCodeMessaggi() ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  15813.         String isUtenti = (pu.isUtenti() ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  15814.         String isAuditing = (pu.isAuditing() ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  15815.         String isAccordiCooperazione = (pu.isAccordiCooperazione() ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  15816.        
  15817.         return this.hasOnlyPermessiDiagnosticaReportistica(isServizi, isDiagnostica, isReportistica, isSistema, isMessaggi, isUtenti, isAuditing, isAccordiCooperazione, singlePdD);

  15818.     }
  15819.    
  15820.     public boolean hasOnlyPermessiDiagnosticaReportistica(String isServizi,String isDiagnostica,String isReportistica,String isSistema,String isMessaggi,
  15821.             String isUtenti,String isAuditing, String isAccordiCooperazione,boolean singlePdD) {
  15822.         return (((isServizi == null) || !ServletUtils.isCheckBoxEnabled(isServizi)) &&
  15823.                 (
  15824.                         !singlePdD
  15825.                         ||
  15826.                         checkPermessiDiagnosticaReportistica(isDiagnostica, isReportistica, singlePdD)
  15827.                 ) &&
  15828.                 ((isSistema == null) || !ServletUtils.isCheckBoxEnabled(isSistema)) &&
  15829.                 ((isMessaggi == null) || !ServletUtils.isCheckBoxEnabled(isMessaggi)) &&
  15830.                 ((isUtenti != null) || !ServletUtils.isCheckBoxEnabled(isUtenti)) &&
  15831.                 ((isAuditing == null) || !ServletUtils.isCheckBoxEnabled(isAuditing)) &&
  15832.                 ((isAccordiCooperazione == null) || !ServletUtils.isCheckBoxEnabled(isAccordiCooperazione)));
  15833.     }

  15834.     private boolean checkPermessiDiagnosticaReportistica(String isDiagnostica, String isReportistica, boolean singlePdD) {
  15835.         return singlePdD
  15836.         &&
  15837.         (
  15838.                 (isDiagnostica == null) || ServletUtils.isCheckBoxEnabled(isDiagnostica)
  15839.         )
  15840.         ||
  15841.         (
  15842.                 (isReportistica == null) || ServletUtils.isCheckBoxEnabled(isReportistica)
  15843.         );
  15844.     }
  15845.    
  15846.     public String readConfigurazioneRegistrazioneEsitiFromHttpParameters(String configurazioneEsiti, boolean first) throws DriverControlStationException {
  15847.        
  15848.        
  15849.         StringBuilder bf = new StringBuilder();
  15850.         List<Integer> esitiCodes = null;
  15851.         try {
  15852.             EsitiProperties esiti = EsitiConfigUtils.getEsitiPropertiesForConfiguration(ControlStationCore.getLog());
  15853.             esitiCodes = esiti.getEsitiCode();
  15854.         }catch(Exception e) {
  15855.             throw new DriverControlStationException(e.getMessage(),e);
  15856.         }
  15857.         if(esitiCodes!=null){
  15858.             for (Integer esito : esitiCodes) {
  15859.                 String esitoParam = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO+esito);
  15860.                 boolean checked = ServletUtils.isCheckBoxEnabled(esitoParam);
  15861.                 if(checked){
  15862.                     if(bf.length()>0){
  15863.                         bf.append(",");
  15864.                     }
  15865.                     bf.append(esito);
  15866.                 }
  15867.             }
  15868.         }
  15869.         if(bf.length()>0){
  15870.             return bf.toString();
  15871.         }
  15872.         else{
  15873.             if(first==false){
  15874.                 return null;
  15875.             }
  15876.             else{
  15877.                 if(configurazioneEsiti == null || "".equals(configurazioneEsiti.trim())){
  15878.                     // creo un default composto da tutti ad eccezione dell'esito (CONTROLLO_TRAFFICO_MAX_THREADS), delle violazioni policy di rate limiting (CONTROLLO_TRAFFICO_POLICY_VIOLATA) e delle richieste CORS OPTIONS
  15879.                     this.getRegistrazioneEsiti(configurazioneEsiti, bf);
  15880.                     if(bf.length()>0){
  15881.                         return bf.toString();
  15882.                     }
  15883.                     else{
  15884.                         return null;
  15885.                     }
  15886.                 }
  15887.             }
  15888.         }
  15889.         return configurazioneEsiti;
  15890.     }
  15891.    
  15892.     public List<String> getRegistrazioneEsiti(String configurazioneEsiti, StringBuilder bf) throws DriverControlStationException{
  15893.        
  15894.         try {
  15895.             EsitiProperties esiti = EsitiConfigUtils.getEsitiPropertiesForConfiguration(ControlStationCore.getLog());
  15896.             return EsitiConfigUtils.getRegistrazioneEsiti(configurazioneEsiti, ControlStationCore.getLog(), bf, esiti);
  15897.         }catch(Exception e) {
  15898.             throw new DriverControlStationException(e.getMessage(),e);
  15899.         }
  15900.        
  15901.     }
  15902.    
  15903.     public boolean isCompleteEnabled(List<String> attivi, List<Integer> listCheck) {

  15904.         boolean all = true;
  15905.         for (int i = 0; i < listCheck.size(); i++) {
  15906.             String okString = listCheck.get(i).intValue()+"";
  15907.             if(attivi.contains(okString)==false) {
  15908.                 all = false;
  15909.                 break;
  15910.             }
  15911.         }
  15912.         return all;
  15913.     }
  15914.    
  15915.     public boolean isCompleteDisabled(List<String> attivi, List<Integer> listCheck) {

  15916.         for (int i = 0; i < listCheck.size(); i++) {
  15917.             String okString = listCheck.get(i).intValue()+"";
  15918.             if(attivi.contains(okString)) {
  15919.                 return false;
  15920.             }
  15921.         }
  15922.         return true;
  15923.     }
  15924.    
  15925.     public List<Integer> getListaEsitiFalliteSenza_RateLimiting_MaxThreads_Scartate(EsitiProperties esiti) throws ProtocolException{
  15926.         List<Integer> listFallite = esiti.getEsitiCodeKo_senzaFaultApplicativo();
  15927.        
  15928.         List<Integer> listDaScartare = new ArrayList<>();
  15929.         listDaScartare.addAll(esiti.getEsitiCodeRichiestaScartate());
  15930.         int esitoViolazioneRateLimiting = esiti.convertoToCode(EsitoTransazioneName.CONTROLLO_TRAFFICO_POLICY_VIOLATA);
  15931.         listDaScartare.add(esitoViolazioneRateLimiting);
  15932.         int esitoViolazione = esiti.convertoToCode(EsitoTransazioneName.CONTROLLO_TRAFFICO_MAX_THREADS);
  15933.         listDaScartare.add(esitoViolazione);
  15934.        
  15935.         List<Integer> listFalliteSenza_rateLimiting_e_max_e_scartate = new ArrayList<>();
  15936.         int i = 0;
  15937.         for (; i < listFallite.size(); i++) {
  15938.             boolean findDaScartare = false;
  15939.             for (Integer daScartare : listDaScartare) {
  15940.                 if(listFallite.get(i).intValue() == daScartare.intValue()) {
  15941.                     findDaScartare = true;
  15942.                     break;
  15943.                 }
  15944.             }
  15945.             if(!findDaScartare) {
  15946.                
  15947.                 boolean statiConsegnaMultipla = EsitoTransazioneName.isStatiConsegnaMultipla(esiti.getEsitoTransazioneName(listFallite.get(i)));
  15948.                 if(statiConsegnaMultipla) {
  15949.                     continue; // non vengono gestiti in questa configurazione
  15950.                 }
  15951.                
  15952.                 listFalliteSenza_rateLimiting_e_max_e_scartate.add(listFallite.get(i));
  15953.             }
  15954.         }
  15955.         return listFalliteSenza_rateLimiting_e_max_e_scartate;
  15956.     }
  15957.    
  15958.     public List<Integer> getListaEsitiOkSenzaCors(EsitiProperties esiti) throws ProtocolException{
  15959.         List<Integer> listOk = esiti.getEsitiCodeOk_senzaFaultApplicativo();
  15960.         int esitoCorsGateway = esiti.convertoToCode(EsitoTransazioneName.CORS_PREFLIGHT_REQUEST_VIA_GATEWAY);
  15961.         int esitoCorsTrasparente = esiti.convertoToCode(EsitoTransazioneName.CORS_PREFLIGHT_REQUEST_TRASPARENTE);
  15962.         List<Integer> listOkSenzaCors = new ArrayList<>();
  15963.         int i = 0;
  15964.         for (; i < listOk.size(); i++) {
  15965.            
  15966.             boolean statiConsegnaMultipla = EsitoTransazioneName.isStatiConsegnaMultipla(esiti.getEsitoTransazioneName(listOk.get(i)));
  15967.             if(statiConsegnaMultipla) {
  15968.                 continue; // non vengono gestiti in questa configurazione
  15969.             }
  15970.            
  15971.             if((listOk.get(i).intValue() != esitoCorsGateway) && (listOk.get(i).intValue() != esitoCorsTrasparente)) {
  15972.                 listOkSenzaCors.add(listOk.get(i));
  15973.             }
  15974.         }
  15975.         return listOkSenzaCors;
  15976.     }
  15977.    
  15978.     public List<Integer> getListaEsitiCors(EsitiProperties esiti) throws ProtocolException{
  15979.         int esitoCorsGateway = esiti.convertoToCode(EsitoTransazioneName.CORS_PREFLIGHT_REQUEST_VIA_GATEWAY);
  15980.         int esitoCorsTrasparente = esiti.convertoToCode(EsitoTransazioneName.CORS_PREFLIGHT_REQUEST_TRASPARENTE);
  15981.         List<Integer> listCors = new ArrayList<>();
  15982.         listCors.add(esitoCorsGateway);
  15983.         listCors.add(esitoCorsTrasparente);
  15984.         return listCors;
  15985.     }
  15986.        
  15987.     public void addToDatiTracciamentoTransazioni(List<DataElement> dati, TipoOperazione tipoOperazione,
  15988.             String tracciamentoStato,
  15989.             String servletName, List<Parameter> listParameter,
  15990.             String oldTracciamentoStato) {
  15991.        
  15992.         if(tipoOperazione!=null) {
  15993.             // nop
  15994.         }
  15995.        
  15996.         DataElement de = new DataElement();
  15997.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA);
  15998.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO);
  15999.         de.setType(DataElementType.TITLE);
  16000.         dati.add(de);
  16001.        
  16002.         de = new DataElement();
  16003.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO);
  16004.         de.setName(CostantiControlStation.PARAMETRO_PORTE_TRACCIAMENTO_STATO);
  16005.         de.setType(DataElementType.SELECT);
  16006.         String [] valuesStato = {CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_DEFAULT, CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO};
  16007.         String [] labelsStato = {CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT, CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_RIDEFINITO};
  16008.         de.setSelected(tracciamentoStato);
  16009.         de.setLabels(labelsStato);
  16010.         de.setValues(valuesStato);
  16011.         de.setPostBack_viaPOST(true);
  16012.         dati.add(de);
  16013.        
  16014.         if(CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO.equals(oldTracciamentoStato)) {
  16015.            
  16016.             de = new DataElement();
  16017.             de.setType(DataElementType.LINK);
  16018.             listParameter.add(new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE, ConfigurazioneCostanti.VALORE_PARAMETRO_CONFIGURAZIONE_TIPO_OPERAZIONE_TRACCIAMENTO_PORTA));
  16019.             de.setUrl(servletName,
  16020.                     listParameter.toArray(new Parameter[1]));
  16021.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_TRACCIAMENTO_CONFIGURAZIONE);
  16022.             dati.add(de);
  16023.            
  16024.         }
  16025.        
  16026.     }
  16027.    
  16028.     public void addToDatiRegistrazioneEsiti(List<DataElement> dati, TipoOperazione tipoOperazione,
  16029.             String nuovaConfigurazioneEsiti,
  16030.             boolean selectAll,
  16031.             String tracciamentoEsitiSelezionePersonalizzataOk, String tracciamentoEsitiSelezionePersonalizzataFault,
  16032.             String tracciamentoEsitiSelezionePersonalizzataFallite, String tracciamentoEsitiSelezionePersonalizzataScartate,
  16033.             String tracciamentoEsitiSelezionePersonalizzataRateLimiting, String tracciamentoEsitiSelezionePersonalizzataMax, String tracciamentoEsitiSelezionePersonalizzataCors,
  16034.             TracciamentoCompatibilitaFiltroEsiti tracciamentoCompatibilitaFiltroEsiti) throws DriverControlStationException {
  16035.        
  16036.         if(tipoOperazione!=null) {
  16037.             // nop
  16038.         }
  16039.        
  16040.         if(tracciamentoCompatibilitaFiltroEsiti!=null && !tracciamentoCompatibilitaFiltroEsiti.isTracciamentoEnabled()) {
  16041.             return;
  16042.         }
  16043.        
  16044.         boolean filterEnabled = tracciamentoCompatibilitaFiltroEsiti==null || tracciamentoCompatibilitaFiltroEsiti.isFilterEnabled();
  16045.         if(!filterEnabled){
  16046.             return;
  16047.         }
  16048.        
  16049.         DataElement de = new DataElement();
  16050.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI);
  16051.         de.setType(DataElementType.TITLE);
  16052.         dati.add(de);
  16053.                        
  16054.         de = new DataElement();
  16055.         de.setValue(ConfigurazioneCostanti.LABEL_NOTE_CONFIGURAZIONE_REGISTRAZIONE_ESITI);
  16056.         de.setType(DataElementType.NOTE);
  16057.         dati.add(de);
  16058.        
  16059.         if(tracciamentoCompatibilitaFiltroEsiti!=null) {
  16060.             String warningMsg = tracciamentoCompatibilitaFiltroEsiti.getWarningMessageFilter();
  16061.             if(warningMsg!=null && StringUtils.isNotEmpty(warningMsg)) {
  16062.                 de = new DataElement();
  16063.                 de.setValue(warningMsg);
  16064.                 de.setLabel("Nota");
  16065.                 de.setBold(true);
  16066.                 de.setType(DataElementType.NOTE);
  16067.                 dati.add(de);
  16068.             }
  16069.         }
  16070.        
  16071.         List<String> attivi = new ArrayList<>();
  16072.         if(nuovaConfigurazioneEsiti!=null){
  16073.             String [] tmp = nuovaConfigurazioneEsiti.split(",");
  16074.             if(tmp!=null){
  16075.                 for (int i = 0; i < tmp.length; i++) {
  16076.                     attivi.add(tmp[i].trim());
  16077.                 }
  16078.             }
  16079.         }
  16080.        
  16081.        
  16082.         EsitiProperties esiti = null;
  16083.         try {
  16084.             esiti = EsitiConfigUtils.getEsitiPropertiesForConfiguration(ControlStationCore.getLog());
  16085.         }catch(Exception e) {
  16086.             throw new DriverControlStationException(e.getMessage(),e);
  16087.         }
  16088.        
  16089.         List<String> values = new ArrayList<>();
  16090.         values.add(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO);
  16091.         values.add(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO);
  16092.         values.add(ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO);
  16093.        
  16094.         List<String> valuesSenzaPersonalizzato = new ArrayList<>();
  16095.         valuesSenzaPersonalizzato.add(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO);
  16096.         valuesSenzaPersonalizzato.add(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO);
  16097.        
  16098.        
  16099.         // select all
  16100.        
  16101.         de = new DataElement();
  16102.         de.setLabelRight(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_ALL);
  16103.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_ALL);
  16104.         de.setType(DataElementType.CHECKBOX);
  16105.         de.setSelected(selectAll);
  16106.         de.setPostBack_viaPOST(true);
  16107.         dati.add(de);
  16108.        
  16109.        
  16110.         // ok
  16111.        
  16112.         List<Integer> listOk = null;
  16113.         try {
  16114.             listOk = getListaEsitiOkSenzaCors(esiti);
  16115.         }catch(Exception e) {
  16116.             throw new DriverControlStationException(e.getMessage(),e);
  16117.         }
  16118.        
  16119.         if(!selectAll) {
  16120.             de = new DataElement();
  16121.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_OK);
  16122.             de.setType(DataElementType.SUBTITLE);
  16123.             dati.add(de);
  16124.         }
  16125.                
  16126.         de = new DataElement();
  16127.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO);
  16128.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_OK);
  16129.         if(!selectAll) {
  16130.             de.setType(DataElementType.SELECT);
  16131.             de.setValues(values);
  16132.             de.setLabels(values);
  16133.             de.setSelected(tracciamentoEsitiSelezionePersonalizzataOk);
  16134.             de.setPostBack_viaPOST(true);
  16135.         }
  16136.         else {
  16137.             de.setType(DataElementType.HIDDEN);
  16138.             de.setSelected(tracciamentoEsitiSelezionePersonalizzataOk);
  16139.         }
  16140.         dati.add(de);
  16141.                
  16142.         if(ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO.equals(tracciamentoEsitiSelezionePersonalizzataOk) ||
  16143.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(tracciamentoEsitiSelezionePersonalizzataOk) ||
  16144.                 selectAll) {
  16145.             for (Integer esito : listOk) {
  16146.                
  16147.                 try {
  16148.                     EsitoTransazioneName esitoTransactionName = esiti.getEsitoTransazioneName(esito);
  16149.                    
  16150.                     boolean statiConsegnaMultipla = EsitoTransazioneName.isStatiConsegnaMultipla(esitoTransactionName);
  16151.                     if(statiConsegnaMultipla) {
  16152.                         continue; // non vengono gestiti in questa configurazione
  16153.                     }
  16154.                    
  16155.                     boolean integrationManagerSpecific = EsitoTransazioneName.isIntegrationManagerSpecific(esitoTransactionName);      
  16156.                     boolean integrationManagerSavedInMessageBox = EsitoTransazioneName.isSavedInMessageBox(esitoTransactionName);      
  16157.                                        
  16158.                     de = new DataElement();
  16159.                     if(EsitoTransazioneName.CONSEGNA_MULTIPLA.equals(esitoTransactionName)) {
  16160.                         de.setLabelRight(EsitoUtils.LABEL_ESITO_CONSEGNA_MULTIPLA_SENZA_STATI);
  16161.                     }
  16162.                     else {
  16163.                         de.setLabelRight(esiti.getEsitoLabel(esito));
  16164.                     }
  16165.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO+esito);
  16166.                     if(!selectAll && ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO.equals(tracciamentoEsitiSelezionePersonalizzataOk)) {
  16167.                         if(
  16168.                                 (
  16169.                                         integrationManagerSpecific &&
  16170.                                         (this.isModalitaStandard() || !this.core.isIntegrationManagerTraceMessageBoxOperationEnabled())
  16171.                                 )
  16172.                                 ||
  16173.                                 (
  16174.                                         integrationManagerSavedInMessageBox && (!this.core.isIntegrationManagerEnabled())
  16175.                                 )
  16176.                         ) {
  16177.                             de.setType(DataElementType.HIDDEN);
  16178.                             de.setValue(attivi.contains((esito+""))+"");
  16179.                         }
  16180.                         else {
  16181.                             de.setType(DataElementType.CHECKBOX);
  16182.                             de.setSelected(attivi.contains((esito+"")));
  16183.                         }
  16184.                     }
  16185.                     else {
  16186.                         de.setType(DataElementType.HIDDEN);
  16187.                         de.setValue("true");
  16188.                     }
  16189.                     dati.add(de);
  16190.                 }catch(Exception e) {
  16191.                     throw new DriverControlStationException(e.getMessage(),e);
  16192.                 }
  16193.             }
  16194.         }
  16195.        
  16196.        
  16197.        
  16198.         // fault
  16199.        
  16200.         List<Integer> listFault = null;
  16201.         try {
  16202.             listFault = esiti.getEsitiCodeFaultApplicativo();
  16203.         }catch(Exception e) {
  16204.             throw new DriverControlStationException(e.getMessage(),e);
  16205.         }
  16206.        
  16207.         if(!selectAll) {
  16208.             de = new DataElement();
  16209.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_FAULT);
  16210.             de.setType(DataElementType.SUBTITLE);
  16211.             dati.add(de);
  16212.         }
  16213.                
  16214.         de = new DataElement();
  16215.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO);
  16216.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_FAULT);
  16217.         if(!selectAll) {
  16218.             de.setType(DataElementType.SELECT);
  16219.             if(listFault.size()>1) {
  16220.                 de.setValues(values);
  16221.                 de.setLabels(values);
  16222.             }
  16223.             else {
  16224.                 de.setValues(valuesSenzaPersonalizzato);
  16225.                 de.setLabels(valuesSenzaPersonalizzato);
  16226.             }
  16227.             de.setSelected(tracciamentoEsitiSelezionePersonalizzataFault);
  16228.             de.setPostBack_viaPOST(true);
  16229.         }
  16230.         else {
  16231.             de.setType(DataElementType.HIDDEN);
  16232.             de.setValue(tracciamentoEsitiSelezionePersonalizzataFault);
  16233.         }
  16234.         dati.add(de);
  16235.                
  16236.         if(ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO.equals(tracciamentoEsitiSelezionePersonalizzataFault) ||
  16237.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(tracciamentoEsitiSelezionePersonalizzataFault) ||
  16238.                 selectAll) {
  16239.             for (Integer esito : listFault) {
  16240.                 try {
  16241.                     de = new DataElement();
  16242.                     de.setLabelRight(esiti.getEsitoLabel(esito));
  16243.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO+esito);
  16244.                     if(!selectAll && ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO.equals(tracciamentoEsitiSelezionePersonalizzataFault)) {
  16245.                         de.setType(DataElementType.CHECKBOX);
  16246.                         de.setSelected(attivi.contains((esito+"")));
  16247.                     }
  16248.                     else {
  16249.                         de.setType(DataElementType.HIDDEN);
  16250.                         de.setValue("true");
  16251.                     }
  16252.                     dati.add(de);
  16253.                 }catch(Exception e) {
  16254.                     throw new DriverControlStationException(e.getMessage(),e);
  16255.                 }
  16256.             }
  16257.         }
  16258.        
  16259.        
  16260.        
  16261.         // fallite
  16262.        
  16263.         List<Integer> listFalliteSenzaMaxThreadsScartate = null;
  16264.         try {
  16265.             listFalliteSenzaMaxThreadsScartate = getListaEsitiFalliteSenza_RateLimiting_MaxThreads_Scartate(esiti);
  16266.         }catch(Exception e) {
  16267.             throw new DriverControlStationException(e.getMessage(),e);
  16268.         }
  16269.        
  16270.         if(!selectAll) {
  16271.             de = new DataElement();
  16272.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_FALLITE);
  16273.             de.setType(DataElementType.SUBTITLE);
  16274.             dati.add(de);
  16275.         }
  16276.                
  16277.         de = new DataElement();
  16278.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO);
  16279.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_FALLITE);
  16280.         if(!selectAll) {
  16281.             de.setType(DataElementType.SELECT);
  16282.             de.setValues(values);
  16283.             de.setLabels(values);
  16284.             de.setSelected(tracciamentoEsitiSelezionePersonalizzataFallite);
  16285.             de.setPostBack_viaPOST(true);
  16286.         }
  16287.         else {
  16288.             de.setType(DataElementType.HIDDEN);
  16289.             de.setValue(tracciamentoEsitiSelezionePersonalizzataFallite);
  16290.         }
  16291.         dati.add(de);
  16292.                
  16293.         if(ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO.equals(tracciamentoEsitiSelezionePersonalizzataFallite) ||
  16294.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(tracciamentoEsitiSelezionePersonalizzataFallite) ||
  16295.                 selectAll) {
  16296.             for (Integer esito : listFalliteSenzaMaxThreadsScartate) {
  16297.                
  16298.                 try {
  16299.                     EsitoTransazioneName esitoTransactionName = esiti.getEsitoTransazioneName(esito);
  16300.                    
  16301.                     boolean statiConsegnaMultipla = EsitoTransazioneName.isStatiConsegnaMultipla(esitoTransactionName);
  16302.                     if(statiConsegnaMultipla) {
  16303.                         continue; // non vengono gestiti in questa configurazione
  16304.                     }
  16305.                    
  16306.                     boolean integrationManagerSpecific = EsitoTransazioneName.isIntegrationManagerSpecific(esitoTransactionName);      
  16307.                    
  16308.                     de = new DataElement();
  16309.                     de.setLabelRight(esiti.getEsitoLabel(esito));
  16310.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO+esito);
  16311.                     if(!selectAll && ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO.equals(tracciamentoEsitiSelezionePersonalizzataFallite)) {
  16312.                         if(integrationManagerSpecific && (this.isModalitaStandard() || !this.core.isIntegrationManagerTraceMessageBoxOperationEnabled())) {
  16313.                             de.setType(DataElementType.HIDDEN);
  16314.                             de.setValue(attivi.contains((esito+""))+"");
  16315.                         }
  16316.                         else {
  16317.                             de.setType(DataElementType.CHECKBOX);
  16318.                             de.setSelected(attivi.contains((esito+"")));
  16319.                         }
  16320.                     }
  16321.                     else {
  16322.                         de.setType(DataElementType.HIDDEN);
  16323.                         de.setValue("true");
  16324.                     }
  16325.                     dati.add(de);
  16326.                 }catch(Exception e) {
  16327.                     throw new DriverControlStationException(e.getMessage(),e);
  16328.                 }
  16329.                
  16330.             }
  16331.         }
  16332.        
  16333.        
  16334.        
  16335.         // Scartate
  16336.        
  16337.         List<Integer> listScartate = null;
  16338.         try {
  16339.             listScartate = esiti.getEsitiCodeRichiestaScartate();
  16340.         }catch(Exception e) {
  16341.             throw new DriverControlStationException(e.getMessage(),e);
  16342.         }
  16343.        
  16344.         if(!selectAll) {
  16345.             de = new DataElement();
  16346.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_SCARTATE);
  16347.             de.setType(DataElementType.SUBTITLE);
  16348.             dati.add(de);
  16349.         }
  16350.                
  16351.         de = new DataElement();
  16352.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO);
  16353.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_SCARTATE);
  16354.         if(!selectAll) {
  16355.             de.setType(DataElementType.SELECT);
  16356.             de.setValues(values);
  16357.             de.setLabels(values);
  16358.             de.setSelected(tracciamentoEsitiSelezionePersonalizzataScartate);
  16359.             de.setPostBack_viaPOST(true);
  16360.         }
  16361.         else {
  16362.             de.setType(DataElementType.HIDDEN);
  16363.             de.setValue(tracciamentoEsitiSelezionePersonalizzataScartate);
  16364.         }
  16365.         dati.add(de);
  16366.                
  16367.         if(ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO.equals(tracciamentoEsitiSelezionePersonalizzataScartate) ||
  16368.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(tracciamentoEsitiSelezionePersonalizzataScartate) ||
  16369.                 selectAll) {
  16370.             for (Integer esito : listScartate) {
  16371.                
  16372.                 try {
  16373.                
  16374.                     EsitoTransazioneName esitoTransactionName = esiti.getEsitoTransazioneName(esito);
  16375.                    
  16376.                     boolean statiConsegnaMultipla = EsitoTransazioneName.isStatiConsegnaMultipla(esitoTransactionName);
  16377.                     if(statiConsegnaMultipla) {
  16378.                         continue; // non vengono gestiti in questa configurazione
  16379.                     }
  16380.                    
  16381.                     boolean integrationManagerSpecific = EsitoTransazioneName.isIntegrationManagerSpecific(esitoTransactionName);      
  16382.                    
  16383.                     de = new DataElement();
  16384.                     de.setLabelRight(esiti.getEsitoLabel(esito));
  16385.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO+esito);
  16386.                     if(!selectAll && ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO.equals(tracciamentoEsitiSelezionePersonalizzataScartate)) {
  16387.                         if(integrationManagerSpecific && (this.isModalitaStandard() || !this.core.isIntegrationManagerTraceMessageBoxOperationEnabled())) {
  16388.                             de.setType(DataElementType.HIDDEN);
  16389.                             de.setValue(attivi.contains((esito+""))+"");
  16390.                         }
  16391.                         else {
  16392.                             de.setType(DataElementType.CHECKBOX);
  16393.                             de.setSelected(attivi.contains((esito+"")));
  16394.                         }
  16395.                     }
  16396.                     else {
  16397.                         de.setType(DataElementType.HIDDEN);
  16398.                         de.setValue("true");
  16399.                     }
  16400.                     dati.add(de);
  16401.                    
  16402.                 }catch(Exception e) {
  16403.                     throw new DriverControlStationException(e.getMessage(),e);
  16404.                 }
  16405.             }
  16406.         }
  16407.                
  16408.        
  16409.        
  16410.        
  16411.         // rate limiting
  16412.        
  16413.         if(!selectAll) {
  16414.             de = new DataElement();
  16415.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_RATE_LIMITING);
  16416.             de.setType(DataElementType.SUBTITLE);
  16417.             dati.add(de);
  16418.         }
  16419.        
  16420.         String esitoViolazioneRateLimitingAsString = null;
  16421.         try {
  16422.             esitoViolazioneRateLimitingAsString = esiti.convertoToCode(EsitoTransazioneName.CONTROLLO_TRAFFICO_POLICY_VIOLATA) + "";
  16423.         }catch(Exception e) {
  16424.             throw new DriverControlStationException(e.getMessage(),e);
  16425.         }
  16426.        
  16427.         de = new DataElement();
  16428.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO);
  16429.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_RATE_LIMITING);
  16430.         if(!selectAll) {
  16431.             de.setType(DataElementType.SELECT);
  16432.             de.setValues(valuesSenzaPersonalizzato);
  16433.             de.setLabels(valuesSenzaPersonalizzato);
  16434.             de.setSelected(tracciamentoEsitiSelezionePersonalizzataRateLimiting);
  16435.             de.setPostBack_viaPOST(true);
  16436.         }
  16437.         else {
  16438.             de.setType(DataElementType.HIDDEN);
  16439.             de.setValue(tracciamentoEsitiSelezionePersonalizzataRateLimiting);
  16440.         }
  16441.         dati.add(de);
  16442.        
  16443.         if(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(tracciamentoEsitiSelezionePersonalizzataRateLimiting) ||
  16444.                 selectAll) {
  16445.             de = new DataElement();
  16446.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO+esitoViolazioneRateLimitingAsString);
  16447.             de.setType(DataElementType.HIDDEN);
  16448.             de.setValue("true");
  16449.             dati.add(de);
  16450.         }
  16451.        
  16452.        
  16453.        
  16454.        
  16455.        
  16456.         // max
  16457.        
  16458.         if(!selectAll) {
  16459.             de = new DataElement();
  16460.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_MAX_REQUESTS);
  16461.             de.setType(DataElementType.SUBTITLE);
  16462.             dati.add(de);
  16463.         }
  16464.        
  16465.         String esitoViolazioneAsString = null;
  16466.         try{
  16467.             esitoViolazioneAsString = esiti.convertoToCode(EsitoTransazioneName.CONTROLLO_TRAFFICO_MAX_THREADS) + "";
  16468.         }catch(Exception e) {
  16469.             throw new DriverControlStationException(e.getMessage(),e);
  16470.         }
  16471.        
  16472.         de = new DataElement();
  16473.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO);
  16474.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_MAX_REQUEST);
  16475.         if(!selectAll) {
  16476.             de.setType(DataElementType.SELECT);
  16477.             de.setValues(valuesSenzaPersonalizzato);
  16478.             de.setLabels(valuesSenzaPersonalizzato);
  16479.             de.setSelected(tracciamentoEsitiSelezionePersonalizzataMax);
  16480.             de.setPostBack_viaPOST(true);
  16481.         }
  16482.         else {
  16483.             de.setType(DataElementType.HIDDEN);
  16484.             de.setValue(tracciamentoEsitiSelezionePersonalizzataMax);
  16485.         }
  16486.         dati.add(de);
  16487.        
  16488.         if(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(tracciamentoEsitiSelezionePersonalizzataMax) ||
  16489.                 selectAll) {
  16490.             de = new DataElement();
  16491.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO+esitoViolazioneAsString);
  16492.             de.setType(DataElementType.HIDDEN);
  16493.             de.setValue("true");
  16494.             dati.add(de);
  16495.         }
  16496.        
  16497.        
  16498.        
  16499.        
  16500.         // cors
  16501.        
  16502.         if(!selectAll) {
  16503.             de = new DataElement();
  16504.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_CORS);
  16505.             de.setType(DataElementType.SUBTITLE);
  16506.             dati.add(de);
  16507.         }
  16508.        
  16509.         de = new DataElement();
  16510.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO);
  16511.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_CORS);
  16512.         if(!selectAll) {
  16513.             de.setType(DataElementType.SELECT);
  16514.             de.setValues(values);
  16515.             de.setLabels(values);
  16516.             de.setSelected(tracciamentoEsitiSelezionePersonalizzataCors);
  16517.             de.setPostBack_viaPOST(true);
  16518.         }
  16519.         else {
  16520.             de.setType(DataElementType.HIDDEN);
  16521.             de.setValue(tracciamentoEsitiSelezionePersonalizzataCors);
  16522.         }
  16523.         dati.add(de);
  16524.                
  16525.         if(ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO.equals(tracciamentoEsitiSelezionePersonalizzataCors) ||
  16526.                 ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(tracciamentoEsitiSelezionePersonalizzataCors) ||
  16527.                 selectAll) {
  16528.            
  16529.             try {
  16530.            
  16531.                 List<Integer> listCors = this.getListaEsitiCors(esiti);
  16532.                
  16533.                 for (Integer esito : listCors) {
  16534.                    
  16535.                     EsitoTransazioneName esitoTransactionName = esiti.getEsitoTransazioneName(esito);
  16536.                     boolean integrationManagerSpecific = EsitoTransazioneName.isIntegrationManagerSpecific(esitoTransactionName);      
  16537.                    
  16538.                     de = new DataElement();
  16539.                     de.setLabelRight(esiti.getEsitoLabel(esito));
  16540.                     de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO+esito);
  16541.                     if(!selectAll && ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO.equals(tracciamentoEsitiSelezionePersonalizzataCors)) {
  16542.                         if(integrationManagerSpecific && (this.isModalitaStandard() || !this.core.isIntegrationManagerTraceMessageBoxOperationEnabled())) {
  16543.                             de.setType(DataElementType.HIDDEN);
  16544.                             de.setValue(attivi.contains((esito+""))+"");
  16545.                         }
  16546.                         else {
  16547.                             de.setType(DataElementType.CHECKBOX);
  16548.                             de.setSelected(attivi.contains((esito+"")));
  16549.                         }
  16550.                     }
  16551.                     else {
  16552.                         de.setType(DataElementType.HIDDEN);
  16553.                         de.setValue("true");
  16554.                     }
  16555.                     dati.add(de);
  16556.                 }
  16557.                
  16558.             }catch(Exception e) {
  16559.                 throw new DriverControlStationException(e.getMessage(),e);
  16560.             }
  16561.         }

  16562.     }
  16563.    
  16564.     public void addToDatiRegistrazioneTransazione(List<DataElement> dati, TipoOperazione tipoOperazione,
  16565.             String transazioniTempiElaborazione, String transazioniToken) throws DriverControlStationException {
  16566.        
  16567.         if(!this.isModalitaStandard()) {
  16568.            
  16569.             DataElement de = new DataElement();
  16570.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_INFORMAZIONI_TRANSAZIONE);
  16571.             de.setType(DataElementType.TITLE);
  16572.             dati.add(de);
  16573.            
  16574.         }
  16575.            
  16576.         List<String> values = new ArrayList<>();
  16577.         values.add(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO);
  16578.         values.add(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO);
  16579.            
  16580.         DataElement de = new DataElement();
  16581.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_INFORMAZIONI_TRANSAZIONE_TEMPI_ELABORAZIONE);
  16582.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_TRANSAZIONE_TEMPI);
  16583.         if(!this.isModalitaStandard()) {
  16584.             de.setType(DataElementType.SELECT);
  16585.             de.setValues(values);
  16586.             de.setLabels(values);
  16587.             de.setSelected(transazioniTempiElaborazione);
  16588.         }
  16589.         else {
  16590.             de.setType(DataElementType.HIDDEN);
  16591.             de.setValue(transazioniTempiElaborazione);
  16592.         }
  16593.         dati.add(de);  
  16594.        
  16595.         de = new DataElement();
  16596.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_INFORMAZIONI_TRANSAZIONE_TOKEN);
  16597.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_REGISTRAZIONE_TRANSAZIONE_TOKEN);
  16598.         if(!this.isModalitaStandard()) {
  16599.             de.setType(DataElementType.SELECT);
  16600.             de.setValues(values);
  16601.             de.setLabels(values);
  16602.             de.setSelected(transazioniToken);
  16603.         }
  16604.         else {
  16605.             de.setType(DataElementType.HIDDEN);
  16606.             de.setValue(transazioniToken);
  16607.         }
  16608.         dati.add(de);  
  16609.        
  16610.     }
  16611.    
  16612.    
  16613.     public void addToDatiRegistrazioneConfigurazioneFileTrace(List<DataElement> dati,
  16614.             String fileTraceStato, String fileTraceConfigFile,
  16615.             String fileTraceClient, String fileTraceClientHdr, String fileTraceClientBody,
  16616.             String fileTraceServer, String fileTraceServerHdr, String fileTraceServerBody,
  16617.             TracciamentoCompatibilitaFiltroEsiti tracciamentoCompatibilitaFiltroEsiti) {
  16618.        
  16619.         if(!tracciamentoCompatibilitaFiltroEsiti.isTracciamentoFileTraceEnabled()) {
  16620.             return;
  16621.         }
  16622.         if(!tracciamentoCompatibilitaFiltroEsiti.isTracciamentoFileTraceEnabled() || tracciamentoCompatibilitaFiltroEsiti.isTracciamentoFileTraceEnabledByExternalProperties() ) {
  16623.             return;
  16624.         }
  16625.        
  16626.         DataElement de = new DataElement();
  16627.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE);
  16628.         de.setType(DataElementType.TITLE);
  16629.         dati.add(de);
  16630.            
  16631.        
  16632.         de = new DataElement();
  16633.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE_STATO);
  16634.         de.setName(ConfigurazioneCostanti.PARAMETRO_FILETRACE_STATO);
  16635.         de.setType(DataElementType.SELECT);
  16636.         String [] valuesStato = {CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_DEFAULT, CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO};
  16637.         String [] labelsStato = {CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT, CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_RIDEFINITO};
  16638.         de.setSelected(fileTraceStato);
  16639.         de.setLabels(labelsStato);
  16640.         de.setValues(valuesStato);
  16641.         de.setPostBack_viaPOST(true);
  16642.         dati.add(de);
  16643.        
  16644.         boolean ridefinito = CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO.equals(fileTraceStato);
  16645.        
  16646.         de = new DataElement();
  16647.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE_CONFIGURAZIONE);
  16648.         de.setName(ConfigurazioneCostanti.PARAMETRO_FILETRACE_CONFIGURAZIONE);
  16649.         de.setValue(fileTraceConfigFile);
  16650.         if(ridefinito) {
  16651.             de.setType(DataElementType.TEXT_AREA);
  16652.             de.setRows(2);
  16653.         }
  16654.         else {
  16655.             de.setType(DataElementType.HIDDEN);
  16656.         }
  16657.         dati.add(de);  
  16658.        
  16659.        
  16660.         if(ridefinito) {
  16661.             de = new DataElement();
  16662.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE_REGISTRAZIONE_MESSAGGI);
  16663.             de.setType(DataElementType.SUBTITLE);
  16664.             dati.add(de);
  16665.            
  16666.             de = new DataElement();
  16667.             de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE_REGISTRAZIONE_MESSAGGI_NOTE);
  16668.             de.setType(DataElementType.NOTE);
  16669.             dati.add(de);  
  16670.         }
  16671.        
  16672.        
  16673.         List<String> values = new ArrayList<>();
  16674.         values.add(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO);
  16675.         values.add(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO);
  16676.            
  16677.        
  16678.        
  16679.         de = new DataElement();
  16680.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE_CLIENT);
  16681.         de.setName(ConfigurazioneCostanti.PARAMETRO_FILETRACE_CLIENT);
  16682.         if(ridefinito) {
  16683.             de.setType(DataElementType.SELECT);
  16684.             de.setValues(values);
  16685.             de.setLabels(values);
  16686.             de.setSelected(fileTraceClient);
  16687.             de.setPostBack_viaPOST(true);
  16688.         }
  16689.         else {
  16690.             de.setType(DataElementType.HIDDEN);
  16691.             de.setValue(fileTraceClient);
  16692.         }
  16693.         dati.add(de);  
  16694.        
  16695.         de = new DataElement();
  16696.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE_HEADER);
  16697.         de.setName(ConfigurazioneCostanti.PARAMETRO_FILETRACE_CLIENT_HEADER);
  16698.         if(ridefinito && ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(fileTraceClient)) {
  16699.             de.setType(DataElementType.SELECT);
  16700.             de.setValues(values);
  16701.             de.setLabels(values);
  16702.             de.setSelected(fileTraceClientHdr);
  16703.         }
  16704.         else {
  16705.             de.setType(DataElementType.HIDDEN);
  16706.             de.setValue(fileTraceClientHdr);
  16707.         }
  16708.         dati.add(de);  
  16709.        
  16710.         de = new DataElement();
  16711.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE_PAYLOAD);
  16712.         de.setName(ConfigurazioneCostanti.PARAMETRO_FILETRACE_CLIENT_PAYLOAD);
  16713.         if(ridefinito && ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(fileTraceClient)) {
  16714.             de.setType(DataElementType.SELECT);
  16715.             de.setValues(values);
  16716.             de.setLabels(values);
  16717.             de.setSelected(fileTraceClientBody);
  16718.         }
  16719.         else {
  16720.             de.setType(DataElementType.HIDDEN);
  16721.             de.setValue(fileTraceClientBody);
  16722.         }
  16723.         dati.add(de);  
  16724.        
  16725.        
  16726.        
  16727.        
  16728.         de = new DataElement();
  16729.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE_SERVER);
  16730.         de.setName(ConfigurazioneCostanti.PARAMETRO_FILETRACE_SERVER);
  16731.         if(ridefinito) {
  16732.             de.setType(DataElementType.SELECT);
  16733.             de.setValues(values);
  16734.             de.setLabels(values);
  16735.             de.setSelected(fileTraceServer);
  16736.             de.setPostBack_viaPOST(true);
  16737.         }
  16738.         else {
  16739.             de.setType(DataElementType.HIDDEN);
  16740.             de.setValue(fileTraceServer);
  16741.         }
  16742.         dati.add(de);  
  16743.        
  16744.         de = new DataElement();
  16745.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE_HEADER);
  16746.         de.setName(ConfigurazioneCostanti.PARAMETRO_FILETRACE_SERVER_HEADER);
  16747.         if(ridefinito && ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(fileTraceServer)) {
  16748.             de.setType(DataElementType.SELECT);
  16749.             de.setValues(values);
  16750.             de.setLabels(values);
  16751.             de.setSelected(fileTraceServerHdr);
  16752.         }
  16753.         else {
  16754.             de.setType(DataElementType.HIDDEN);
  16755.             de.setValue(fileTraceServerHdr);
  16756.         }
  16757.         dati.add(de);  
  16758.        
  16759.         de = new DataElement();
  16760.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_FILETRACE_PAYLOAD);
  16761.         de.setName(ConfigurazioneCostanti.PARAMETRO_FILETRACE_SERVER_PAYLOAD);
  16762.         if(ridefinito && ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO.equals(fileTraceServer)) {
  16763.             de.setType(DataElementType.SELECT);
  16764.             de.setValues(values);
  16765.             de.setLabels(values);
  16766.             de.setSelected(fileTraceServerBody);
  16767.         }
  16768.         else {
  16769.             de.setType(DataElementType.HIDDEN);
  16770.             de.setValue(fileTraceServerBody);
  16771.         }
  16772.         dati.add(de);  
  16773.     }
  16774.    
  16775.    
  16776.     public void addToDatiConfigurazioneAvanzataTracciamento(List<DataElement> dati, TipoOperazione tipoOperazione,
  16777.             String dbStato,
  16778.             String dbStatoReqIn, String dbStatoReqOut, String dbStatoResOut, String dbStatoResOutComplete,
  16779.             boolean dbFiltroEsiti,
  16780.             String fsStato,
  16781.             String fsStatoReqIn, String fsStatoReqOut, String fsStatoResOut, String fsStatoResOutComplete,
  16782.             boolean fsFiltroEsiti,
  16783.             boolean porta) {
  16784.                            

  16785.         DataElement de = new DataElement();
  16786.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA);
  16787.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO);
  16788.         de.setType(DataElementType.TITLE);
  16789.         dati.add(de);
  16790.        
  16791.        
  16792.         // DATABASE
  16793.        
  16794.         de = new DataElement();
  16795.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_DATABASE);
  16796.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE);
  16797.         de.setType(DataElementType.SUBTITLE);
  16798.         /**de.setStatoAperturaSezioni(STATO_APERTURA_SEZIONI.CHIUSO);*/
  16799.         dati.add(de);
  16800.        
  16801.         // stato abilitazione
  16802.         addTransazioniStatoElement(dati, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_DATABASE_STATO,
  16803.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO,
  16804.                 false,
  16805.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO,
  16806.                 dbStato,
  16807.                 true,
  16808.                 true,
  16809.                 false);
  16810.         addTransazioniStatoElementBloccante(dati, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_DATABASE_STATO_REQ_IN,
  16811.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO_REQ_IN,
  16812.                 !StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(dbStato), // hidden
  16813.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO_REQ_IN,
  16814.                 dbStatoReqIn,
  16815.                 true);
  16816.         addTransazioniStatoElementBloccante(dati, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_DATABASE_STATO_REQ_OUT,
  16817.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO_REQ_OUT,
  16818.                 !StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(dbStato), // hidden
  16819.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO_REQ_OUT,
  16820.                 dbStatoReqOut,
  16821.                 true);
  16822.         addTransazioniStatoElementBloccante(dati, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_DATABASE_STATO_RES_OUT,
  16823.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO_RES_OUT,
  16824.                 !StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(dbStato), // hidden
  16825.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO_RES_OUT,
  16826.                 dbStatoResOut,
  16827.                 true);
  16828.         if(this.core.isTracciamentoDatabaseRispostaConsegnataSelectEnabled()) {
  16829.             addTransazioniStatoElement(dati, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_DATABASE_STATO_RES_OUT_COMPLETE,
  16830.                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO_RES_OUT_COMPLETE,
  16831.                     !StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(dbStato), // hidden
  16832.                     ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO_RES_OUT_COMPLETE,
  16833.                     dbStatoResOutComplete,
  16834.                     false);
  16835.         }
  16836.         else {
  16837.             de = new DataElement();
  16838.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_DATABASE_STATO_RES_OUT_COMPLETE);
  16839.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_STATO_RES_OUT_COMPLETE);
  16840.             boolean hidden = !StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(dbStato);
  16841.             if(StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(dbStato)) {
  16842.                 dbStatoResOutComplete = org.openspcoop2.core.config.constants.StatoFunzionalita.ABILITATO.getValue();
  16843.             }
  16844.             if(hidden) {
  16845.                 de.setType(DataElementType.HIDDEN);
  16846.             }
  16847.             else {
  16848.                 de.setType(DataElementType.TEXT);
  16849.             }
  16850.             de.setValue(dbStatoResOutComplete);
  16851.             dati.add(de);
  16852.         }
  16853.        
  16854.         de = new DataElement();
  16855.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_DATABASE_FILTRA_ESITI);
  16856.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_FILTRA_ESITI);
  16857.         if(StatoFunzionalitaConPersonalizzazione.DISABILITATO.getValue().equals(dbStato) ||
  16858.                 (StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(dbStato) &&
  16859.                         (StatoFunzionalitaBloccante.ABILITATO.getValue().equals(dbStatoReqIn) || StatoFunzionalitaBloccante.NON_BLOCCANTE.getValue().equals(dbStatoReqIn)))) {
  16860.             de.setType(DataElementType.HIDDEN);
  16861.             de.setValue(null);
  16862.         }
  16863.         else {
  16864.             de.setType(DataElementType.CHECKBOX);
  16865.             de.setValoreDefaultCheckbox(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE_FILTRA_ESITI);
  16866.             de.setSelected(dbFiltroEsiti);
  16867.         }
  16868.         de.setPostBack_viaPOST(true);
  16869.         dati.add(de);
  16870.        
  16871.         /**this.impostaAperturaTitle(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_DATABASE);*/
  16872.        
  16873.        
  16874.         // FILETRACE
  16875.        
  16876.         de = new DataElement();
  16877.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_FILETRACE);
  16878.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE);
  16879.         de.setType(DataElementType.SUBTITLE);
  16880.         /**de.setStatoAperturaSezioni(STATO_APERTURA_SEZIONI.CHIUSO);*/
  16881.         dati.add(de);
  16882.        
  16883.         // stato abilitazione
  16884.         addTransazioniStatoElement(dati, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_FILETRACE_STATO,
  16885.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_STATO,
  16886.                 false,
  16887.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_STATO,
  16888.                 fsStato,
  16889.                 true,
  16890.                 true,
  16891.                 !porta);
  16892.         addTransazioniStatoElementBloccante(dati, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_FILETRACE_STATO_REQ_IN,
  16893.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_STATO_REQ_IN,
  16894.                 !StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(fsStato), // hidden
  16895.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_STATO_REQ_IN,
  16896.                 fsStatoReqIn,
  16897.                 true);
  16898.         addTransazioniStatoElementBloccante(dati, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_FILETRACE_STATO_REQ_OUT,
  16899.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_STATO_REQ_OUT,
  16900.                 !StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(fsStato), // hidden
  16901.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_STATO_REQ_OUT,
  16902.                 fsStatoReqOut,
  16903.                 true);
  16904.         addTransazioniStatoElementBloccante(dati, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_FILETRACE_STATO_RES_OUT,
  16905.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_STATO_RES_OUT,
  16906.                 !StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(fsStato), // hidden
  16907.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_STATO_RES_OUT,
  16908.                 fsStatoResOut,
  16909.                 true);
  16910.         addTransazioniStatoElement(dati, ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_FILETRACE_STATO_RES_OUT_COMPLETE,
  16911.                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_STATO_RES_OUT_COMPLETE,
  16912.                 !StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(fsStato), // hidden
  16913.                 ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_STATO_RES_OUT_COMPLETE,
  16914.                 fsStatoResOutComplete,
  16915.                 false);
  16916.        
  16917.         de = new DataElement();
  16918.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_AVANZATA_FILETRACE_FILTRA_ESITI);
  16919.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_FILTRA_ESITI);
  16920.         if(StatoFunzionalitaConPersonalizzazione.DISABILITATO.getValue().equals(fsStato) ||
  16921.                 (StatoFunzionalitaConPersonalizzazione.PERSONALIZZATO.getValue().equals(fsStato) &&
  16922.                         (StatoFunzionalitaBloccante.ABILITATO.getValue().equals(fsStatoReqIn) || StatoFunzionalitaBloccante.NON_BLOCCANTE.getValue().equals(fsStatoReqIn)))) {
  16923.             de.setType(DataElementType.HIDDEN);
  16924.             de.setValue(null);
  16925.         }
  16926.         else {
  16927.             de.setType(DataElementType.CHECKBOX);
  16928.             de.setValoreDefaultCheckbox(ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE_FILTRA_ESITI);
  16929.             de.setSelected(fsFiltroEsiti);
  16930.         }
  16931.         de.setPostBack_viaPOST(true);
  16932.         dati.add(de);
  16933.        
  16934.         /**this.impostaAperturaTitle(dati, ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_AVANZATA_TRACCIAMENTO_FILETRACE);*/
  16935.     }
  16936.     private void addTransazioniStatoElement(List<DataElement> dati, String label, String name, boolean hidden, String defaultValue, String value, boolean postback) {
  16937.         addTransazioniStatoElement(dati, label, name, hidden, defaultValue, value, postback, false, false, false);
  16938.     }
  16939.     private void addTransazioniStatoElementBloccante(List<DataElement> dati, String label, String name, boolean hidden, String defaultValue, String value, boolean postback) {
  16940.         addTransazioniStatoElement(dati, label, name, hidden, defaultValue, value, postback, false, false, true);
  16941.     }
  16942.     private void addTransazioniStatoElement(List<DataElement> dati, String label, String name, boolean hidden, String defaultValue, String value, boolean postback,
  16943.             boolean personalizzato, boolean configurazioneEsterna) {
  16944.         addTransazioniStatoElement(dati, label, name, hidden, defaultValue, value, postback,
  16945.                 personalizzato, configurazioneEsterna, false);
  16946.     }
  16947.     private void addTransazioniStatoElement(List<DataElement> dati, String label, String name, boolean hidden, String defaultValue, String value, boolean postback,
  16948.             boolean personalizzato, boolean configurazioneEsterna, boolean bloccante) {
  16949.        
  16950.         List<String> values = new ArrayList<>();
  16951.         values.add(ConfigurazioneCostanti.DEFAULT_VALUE_ABILITATO);
  16952.         if(bloccante) {
  16953.             values.add(ConfigurazioneCostanti.DEFAULT_VALUE_NON_BLOCCANTE);
  16954.         }
  16955.         values.add(ConfigurazioneCostanti.DEFAULT_VALUE_DISABILITATO);  
  16956.         if(personalizzato) {
  16957.             values.add(ConfigurazioneCostanti.TRACCIAMENTO_ESITI_PERSONALIZZATO);
  16958.         }
  16959.         if(configurazioneEsterna) {
  16960.             values.add(ConfigurazioneCostanti.TRACCIAMENTO_ESITI_CONFIGURAZIONE_ESTERNA);
  16961.         }
  16962.        
  16963.         List<String> labels = null;
  16964.         if(bloccante) {
  16965.             labels = new ArrayList<>();
  16966.             labels.add(CostantiLabel.LABEL_ABILITATO_BLOCCANTE);
  16967.             labels.add(CostantiLabel.LABEL_ABILITATO_NON_BLOCCANTE);
  16968.             labels.add(CostantiLabel.LABEL_DISABILITATO);
  16969.         }
  16970.        
  16971.         DataElement de = new DataElement();
  16972.         de.setLabel(label);
  16973.         de.setName(name);
  16974.         if(hidden) {
  16975.             de.setType(DataElementType.HIDDEN);
  16976.             de.setValue(value);
  16977.         }
  16978.         else {
  16979.             de.setType(DataElementType.SELECT);
  16980.             de.setValues(values);
  16981.             if(labels!=null) {
  16982.                 de.setLabels(labels);
  16983.             }
  16984.             de.setValoreDefaultSelect(defaultValue);
  16985.             de.setPostBack_viaPOST(postback);
  16986.             de.setSelected(value);
  16987.         }
  16988.         dati.add(de);
  16989.     }
  16990.    
  16991.     public void addSeveritaMessaggiDiagnosticiToDati(String severita, String severita_log4j, List<DataElement> dati) {
  16992.        
  16993.         DataElement de;
  16994.         de = new DataElement();
  16995.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MESSAGGI_DIAGNOSTICI);
  16996.         de.setType(DataElementType.TITLE);
  16997.         dati.add(de);

  16998.         //                  String[] tipoMsg = { "off", "fatalOpenspcoop", "errorSpcoop", "errorOpenspcoop", "infoSpcoop", "infoOpenspcoop",
  16999.         //                          "debugLow", "debugMedium", "debugHigh", "all" };
  17000.         String[] tipoMsg = { LogLevels.LIVELLO_OFF, LogLevels.LIVELLO_FATAL, LogLevels.LIVELLO_ERROR_PROTOCOL, LogLevels.LIVELLO_ERROR_INTEGRATION,
  17001.                 LogLevels.LIVELLO_INFO_PROTOCOL, LogLevels.LIVELLO_INFO_INTEGRATION,
  17002.                 LogLevels.LIVELLO_DEBUG_LOW, LogLevels.LIVELLO_DEBUG_MEDIUM, LogLevels.LIVELLO_DEBUG_HIGH,
  17003.                 LogLevels.LIVELLO_ALL};
  17004.         de = new DataElement();
  17005.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA);
  17006.         //      de.setLabel("Livello Severita");
  17007.         de.setType(DataElementType.SELECT);
  17008.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA);
  17009.         de.setValues(tipoMsg);
  17010.         de.setSelected(severita);
  17011.         dati.add(de);

  17012.         de = new DataElement();
  17013.         //      de.setLabel("Livello Severita Log4J");
  17014.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA_LOG4J);
  17015.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA_LOG4J);
  17016.         if(this.core.isVisualizzazioneConfigurazioneDiagnosticaLog4J()){
  17017.             de.setType(DataElementType.SELECT);
  17018.             de.setValues(tipoMsg);
  17019.             de.setSelected(severita_log4j);
  17020.         }
  17021.         else{
  17022.             de.setType(DataElementType.HIDDEN);
  17023.             de.setValue(severita_log4j);
  17024.         }
  17025.         dati.add(de);
  17026.        
  17027.     }
  17028.    
  17029.     public void addPortaSeveritaMessaggiDiagnosticiToDati(String stato, String severita, List<DataElement> dati) {
  17030.        
  17031.         DataElement de;
  17032.         de = new DataElement();
  17033.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_MESSAGGI_DIAGNOSTICI);
  17034.         de.setType(DataElementType.TITLE);
  17035.         dati.add(de);

  17036.         de = new DataElement();
  17037.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_REGISTRAZIONE_ESITI_STATO);
  17038.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA_RIDEFINITO);
  17039.         de.setType(DataElementType.SELECT);
  17040.         String valuesStato [] = {CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_DEFAULT, CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO};
  17041.         String labelsStato [] = {CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_DEFAULT, CostantiControlStation.LABEL_PARAMETRO_DUMP_STATO_RIDEFINITO};
  17042.         de.setSelected(stato);
  17043.         de.setLabels(labelsStato);
  17044.         de.setValues(valuesStato);
  17045.         de.setPostBack(true);
  17046.         dati.add(de);
  17047.        
  17048.         //                  String[] tipoMsg = { "off", "fatalOpenspcoop", "errorSpcoop", "errorOpenspcoop", "infoSpcoop", "infoOpenspcoop",
  17049.         //                          "debugLow", "debugMedium", "debugHigh", "all" };
  17050.         if(CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO.equals(stato)) {
  17051.             String[] tipoMsg = { LogLevels.LIVELLO_OFF, LogLevels.LIVELLO_FATAL, LogLevels.LIVELLO_ERROR_PROTOCOL, LogLevels.LIVELLO_ERROR_INTEGRATION,
  17052.                     LogLevels.LIVELLO_INFO_PROTOCOL, LogLevels.LIVELLO_INFO_INTEGRATION,
  17053.                     LogLevels.LIVELLO_DEBUG_LOW, LogLevels.LIVELLO_DEBUG_MEDIUM, LogLevels.LIVELLO_DEBUG_HIGH,
  17054.                     LogLevels.LIVELLO_ALL};
  17055.             de = new DataElement();
  17056.             de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA);
  17057.             //      de.setLabel("Livello Severita");
  17058.             de.setType(DataElementType.SELECT);
  17059.             de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_LIVELLO_SEVERITA);
  17060.             de.setValues(tipoMsg);
  17061.             de.setSelected(severita);
  17062.             dati.add(de);
  17063.         }
  17064.        
  17065.     }

  17066.     public List<DataElement> configurazioneCambiaNome(List<DataElement> dati, TipoOperazione other, String nomeGruppo,boolean isPortaDelegata) throws DriverControlStationException{
  17067.          
  17068.         DataElement de = new DataElement();
  17069.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_NOME_GRUPPO);
  17070.         de.setType(DataElementType.TITLE);
  17071.         dati.add(de);
  17072.        
  17073.         // Azione
  17074.         de = new DataElement();
  17075.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  17076.         de.setType(DataElementType.TEXT_EDIT);
  17077.         de.setName(CostantiControlStation.PARAMETRO_NOME_GRUPPO);
  17078.         de.setValue(nomeGruppo);  
  17079.         de.setRequired(true);
  17080.         dati.add(de);
  17081.        
  17082.         return dati;
  17083.     }
  17084.    
  17085.     public boolean configurazioneCambiaNomeCheck(TipoOperazione other, String nomeGruppo, List<String> listaNomiGruppiOccupati,boolean isPortaDelegata) throws DriverControlStationException{
  17086.         if(StringUtils.isEmpty(nomeGruppo)) {
  17087.             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NOME_GRUPPO_NON_PUO_ESSERE_VUOTA);
  17088.             return false;
  17089.         }
  17090.        
  17091.         for (String nomeOccupato : listaNomiGruppiOccupati) {
  17092.             if(nomeOccupato.equalsIgnoreCase(nomeGruppo)) {
  17093.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NOME_GRUPPO_GIA_PRESENTE);
  17094.                 return false;          
  17095.             }
  17096.         }
  17097.        
  17098.         return true;
  17099.     }

  17100.     public DataElement getDataElementNotCorrelazioneApplicativa() {
  17101.         DataElement de = new DataElement();
  17102.         de.setLabel(CostantiControlStation.LABEL_PORTE_CORRELAZIONE_APPLICATIVA_ATTENZIONE);
  17103.         de.setBold(true);
  17104.         de.setValue(CostantiControlStation.getLABEL_PORTE_CORRELAZIONE_APPLICATIVA_ATTENZIONE_MESSAGGIO(this.core.getPortaCorrelazioneApplicativaMaxLength()));
  17105.         de.setType(DataElementType.NOTE);
  17106.         return de;
  17107.     }

  17108.    
  17109.     public static String normalizeLabel(String label, int maxWidth) {
  17110.         if(label.length() > maxWidth) {
  17111.             return label.substring(0, maxWidth - 3) + "...";
  17112.         }
  17113.         return label;
  17114.     }
  17115.    
  17116.     public void addConfigurazioneCorsPorteToDati(TipoOperazione tipoOperazione,List<DataElement> dati, boolean showStato, String statoCorsPorta, boolean corsStato, TipoGestioneCORS corsTipo,
  17117.             boolean corsAllAllowOrigins, boolean corsAllAllowHeaders, boolean corsAllAllowMethods,
  17118.             String corsAllowHeaders, String corsAllowOrigins, String corsAllowMethods,
  17119.             boolean corsAllowCredential, String corsExposeHeaders, boolean corsMaxAge, int corsMaxAgeSeconds) throws DriverControlStationException {
  17120.        
  17121.         if(showStato) {
  17122.             DataElement de = new DataElement();
  17123.             de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_CORS);
  17124.             de.setType(DataElementType.TITLE);
  17125.             dati.add(de);
  17126.         }
  17127.        
  17128.         // stato generale cors
  17129.         DataElement de = new DataElement();
  17130.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_STATO_PORTA);
  17131.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CORS_STATO_PORTA);
  17132.         if(showStato) {
  17133.             try {
  17134.                 de.setType(DataElementType.SELECT);
  17135.                 String valuesStato [] = {CostantiControlStation.VALUE_PARAMETRO_CORS_STATO_DEFAULT, CostantiControlStation.VALUE_PARAMETRO_CORS_STATO_RIDEFINITO};
  17136.                 String labelsStato [] = { this.getGestioneCorsLabelDefault(true), CostantiControlStation.LABEL_PARAMETRO_CORS_STATO_PORTA_RIDEFINITO};
  17137.                 de.setSelected(statoCorsPorta);
  17138.                 de.setLabels(labelsStato);
  17139.                 de.setValues(valuesStato);
  17140.                 de.setPostBack(true);
  17141.             }catch(Exception e) {
  17142.                 throw new DriverControlStationException(e.getMessage(),e);
  17143.             }
  17144.         } else {
  17145.             de.setType(DataElementType.HIDDEN);
  17146.             de.setValue(statoCorsPorta);
  17147.         }
  17148.         dati.add(de);
  17149.        
  17150.         if(!showStato || statoCorsPorta.equals(CostantiControlStation.VALUE_PARAMETRO_CORS_STATO_RIDEFINITO)) {
  17151.             this.addConfigurazioneCorsToDati(dati, corsStato, corsTipo,
  17152.                     corsAllAllowOrigins, corsAllAllowHeaders, corsAllAllowMethods,
  17153.                     corsAllowHeaders, corsAllowOrigins, corsAllowMethods,
  17154.                     corsAllowCredential, corsExposeHeaders, corsMaxAge, corsMaxAgeSeconds,
  17155.                     false,
  17156.                     false);
  17157.         }
  17158.     }
  17159.            
  17160.    
  17161.     // CORS
  17162.     public void addConfigurazioneCorsToDati(List<DataElement> dati, boolean corsStato, TipoGestioneCORS corsTipo,
  17163.             boolean corsAllAllowOrigins, boolean corsAllAllowHeaders, boolean corsAllAllowMethods,
  17164.             String corsAllowHeaders, String corsAllowOrigins, String corsAllowMethods,
  17165.             boolean corsAllowCredential, String corsExposeHeaders, boolean corsMaxAge, int corsMaxAgeSeconds,
  17166.             boolean addTitle,
  17167.             boolean allHidden) {
  17168.        
  17169.         DataElement de;
  17170.         if(!allHidden && addTitle) {
  17171.             de = new DataElement();
  17172.             de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_CORS);
  17173.             de.setType(DataElementType.TITLE);
  17174.             dati.add(de);
  17175.         }
  17176.        
  17177.         de = new DataElement();
  17178.         de.setLabel(addTitle ? CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_STATO : "");
  17179.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_STATO);
  17180.         if(allHidden) {
  17181.             de.setType(DataElementType.HIDDEN);
  17182.         }
  17183.         else {
  17184.             de.setType(DataElementType.SELECT);
  17185.             de.setPostBack(true);
  17186.             de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA);
  17187.             de.setSelected(corsStato ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue());
  17188.         }
  17189.         de.setValue(corsStato ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue());
  17190.         dati.add(de);
  17191.        
  17192.         if(corsStato) {
  17193.            
  17194.             de = new DataElement();
  17195.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_TIPO);
  17196.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_TIPO);
  17197.             de.setValue(corsTipo.getValue());
  17198.             if(allHidden) {
  17199.                 de.setType(DataElementType.HIDDEN);
  17200.             }
  17201.             else if(
  17202.                     TipoGestioneCORS.TRASPARENTE.equals(corsTipo) // impostato in avanzato
  17203.                     ||
  17204.                     !this.isModalitaStandard()
  17205.                     ) {
  17206.            
  17207.                 String [] corsTipiValues = new String [] { TipoGestioneCORS.GATEWAY.getValue(), TipoGestioneCORS.TRASPARENTE.getValue()};
  17208.                 String [] corsTipiLabels = new String [] {
  17209.                         CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_TIPO_GESTITO_GATEWAY,
  17210.                         CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_TIPO_GESTITO_APPLICATIVO
  17211.                         };
  17212.                 de.setType(DataElementType.SELECT);
  17213.                 de.setPostBack(true);
  17214.                 de.setValues(corsTipiValues);
  17215.                 de.setLabels(corsTipiLabels);
  17216.                 de.setSelected(corsTipo.getValue());
  17217.             }
  17218.             else {
  17219.                 de.setType(DataElementType.HIDDEN);
  17220.             }
  17221.             dati.add(de);
  17222.            
  17223.             if(TipoGestioneCORS.GATEWAY.equals(corsTipo)) {
  17224.                
  17225.                 if(!allHidden) {
  17226.                     de = new DataElement();
  17227.                     de.setType(DataElementType.SUBTITLE);
  17228.                     de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_CORS_ACCESS_CONTROL);
  17229.                     dati.add(de);
  17230.                 }
  17231.                
  17232.                
  17233.                 de = new DataElement();
  17234.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_ORIGINS);
  17235.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_ORIGINS);
  17236.                 if(allHidden) {
  17237.                     de.setType(DataElementType.HIDDEN);
  17238.                 }
  17239.                 else {
  17240.                     de.setType(DataElementType.CHECKBOX);
  17241.                     de.setSelected(corsAllAllowOrigins);
  17242.                     de.setPostBack(true);
  17243.                 }
  17244.                 de.setValue(corsAllAllowOrigins+"");
  17245.                 dati.add(de);
  17246.                
  17247.                 if(!corsAllAllowOrigins) {
  17248.                     de = new DataElement();
  17249.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_ORIGINS);
  17250.                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_ORIGINS);
  17251.                     if(allHidden) {
  17252.                         de.setType(DataElementType.HIDDEN);
  17253.                     }else {
  17254.                         de.setType(DataElementType.TEXT_EDIT);
  17255.                         de.setRequired(true);
  17256.                         de.enableTags();
  17257.                     }
  17258.                     de.setValue(corsAllowOrigins);
  17259.                     dati.add(de);
  17260.                 }
  17261.                 else {
  17262.                     corsAllAllowMethods = false;
  17263.                     corsAllAllowHeaders = false;
  17264.                 }
  17265.                                        
  17266.                 de = new DataElement();
  17267.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_METHODS);
  17268.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_METHODS);
  17269.                 if(allHidden || corsAllAllowOrigins) {
  17270.                     de.setType(DataElementType.HIDDEN);
  17271.                 }
  17272.                 else {
  17273.                     de.setType(DataElementType.CHECKBOX);
  17274.                     de.setSelected(corsAllAllowMethods);
  17275.                     de.setPostBack(true);
  17276.                 }
  17277.                 de.setValue(corsAllAllowMethods+"");
  17278.                 dati.add(de);
  17279.                
  17280.                 if(!corsAllAllowMethods || corsAllAllowOrigins) {
  17281.                     de = new DataElement();
  17282.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_METHODS);
  17283.                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_METHODS);
  17284.                     if(allHidden) {
  17285.                         de.setType(DataElementType.HIDDEN);
  17286.                     }else {
  17287.                         de.setType(DataElementType.TEXT_EDIT);
  17288.                         de.setRequired(true);
  17289.                         de.enableTags();
  17290.                     }
  17291.                     de.setValue(corsAllowMethods);
  17292.                     dati.add(de);
  17293.                 }
  17294.                            
  17295.                 de = new DataElement();
  17296.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_HEADERS);
  17297.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_HEADERS);
  17298.                 if(allHidden || corsAllAllowOrigins) {
  17299.                     de.setType(DataElementType.HIDDEN);
  17300.                 }
  17301.                 else {
  17302.                     de.setType(DataElementType.CHECKBOX);
  17303.                     de.setSelected(corsAllAllowHeaders);
  17304.                     de.setPostBack(true);
  17305.                 }
  17306.                 de.setValue(corsAllAllowHeaders+"");
  17307.                 dati.add(de);
  17308.                
  17309.                 if(!corsAllAllowHeaders || corsAllAllowOrigins) {
  17310.                     de = new DataElement();
  17311.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_HEADERS);
  17312.                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_HEADERS);
  17313.                     if(allHidden) {
  17314.                         de.setType(DataElementType.HIDDEN);
  17315.                     }else {
  17316.                         de.setType(DataElementType.TEXT_EDIT);
  17317.                         de.setRequired(true);
  17318.                         de.enableTags();
  17319.                     }
  17320.                     de.setValue(corsAllowHeaders);
  17321.                     dati.add(de);
  17322.                 }
  17323.                
  17324.                 de = new DataElement();
  17325.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_CREDENTIALS);
  17326.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_CREDENTIALS);
  17327.                 if(allHidden) {
  17328.                     de.setType(DataElementType.HIDDEN);
  17329.                 }else {
  17330.                     de.setType(DataElementType.CHECKBOX);
  17331.                     de.setSelected(corsAllowCredential);
  17332.                 }
  17333.                 de.setValue(corsAllowCredential+"");
  17334.                 dati.add(de);
  17335.                
  17336.                 de = new DataElement();
  17337.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_EXPOSE_HEADERS);
  17338.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_EXPOSE_HEADERS);
  17339.                 if(allHidden) {
  17340.                     de.setType(DataElementType.HIDDEN);
  17341.                 }else {
  17342.                     de.setType(DataElementType.TEXT_EDIT);
  17343.                     de.enableTags();
  17344.                 }
  17345.                 de.setValue(corsExposeHeaders);
  17346.                 dati.add(de);
  17347.                
  17348.                
  17349.                 de = new DataElement();
  17350.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_MAX_AGE);
  17351.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_MAX_AGE);
  17352.                 //if(allHidden || this.isModalitaStandard()) {
  17353.                 if(allHidden) {
  17354.                     de.setType(DataElementType.HIDDEN);
  17355.                 }else {
  17356.                     de.setType(DataElementType.CHECKBOX);
  17357.                     de.setSelected(corsMaxAge);
  17358.                     de.setPostBack(true);
  17359.                 }
  17360.                 de.setValue(corsMaxAge+"");
  17361.                 dati.add(de);
  17362.                
  17363.                 if(corsMaxAge) {
  17364.                     de = new DataElement();
  17365.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_MAX_AGE_SECONDS);
  17366.                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_MAX_AGE_SECONDS);
  17367.                     de.setValue(corsMaxAgeSeconds+"");
  17368.                     //if(allHidden || this.isModalitaStandard()) {
  17369.                     if(allHidden) {
  17370.                         de.setType(DataElementType.HIDDEN);
  17371.                     }else {
  17372.                         de.setType(DataElementType.NUMBER);
  17373.                         de.setMinValue(-1);
  17374.                         de.setMaxValue(Integer.MAX_VALUE);
  17375.                         de.setNote(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_MAX_AGE_SECONDS_NOTE);
  17376.                     }
  17377.                     dati.add(de);
  17378.                 }
  17379.             }
  17380.         }
  17381.     }
  17382.    
  17383.     public CorsConfigurazione getGestioneCors(boolean corsStato, TipoGestioneCORS corsTipo,
  17384.             boolean corsAllAllowOrigins, boolean corsAllAllowHeaders, boolean corsAllAllowMethods,
  17385.             String corsAllowHeaders, String corsAllowOrigins, String corsAllowMethods, boolean corsAllowCredential,
  17386.             String corsExposeHeaders, boolean corsMaxAge, int corsMaxAgeSeconds) {
  17387.         CorsConfigurazione gestioneCors = new CorsConfigurazione();
  17388.         gestioneCors.setStato(corsStato ? StatoFunzionalita.ABILITATO : StatoFunzionalita.DISABILITATO);
  17389.         if(corsStato) {
  17390.             gestioneCors.setTipo(corsTipo);

  17391.             if(corsTipo.equals(TipoGestioneCORS.GATEWAY)) {
  17392.                 gestioneCors.setAccessControlAllAllowOrigins(corsAllAllowOrigins ? StatoFunzionalita.ABILITATO : StatoFunzionalita.DISABILITATO);
  17393.                 if(!corsAllAllowOrigins) {
  17394.                     CorsConfigurazioneOrigin accessControlAllowOrigins = new CorsConfigurazioneOrigin();
  17395.                     accessControlAllowOrigins.setOriginList(Arrays.asList(corsAllowOrigins.split(",")));
  17396.                     gestioneCors.setAccessControlAllowOrigins(accessControlAllowOrigins );
  17397.                 }

  17398.                 gestioneCors.setAccessControlAllAllowHeaders(corsAllAllowHeaders ? StatoFunzionalita.ABILITATO : StatoFunzionalita.DISABILITATO);
  17399.                 if(!corsAllAllowHeaders) {
  17400.                     CorsConfigurazioneHeaders accessControlAllowHeaders = new CorsConfigurazioneHeaders();
  17401.                     accessControlAllowHeaders.setHeaderList(Arrays.asList(corsAllowHeaders.split(",")));
  17402.                     gestioneCors.setAccessControlAllowHeaders(accessControlAllowHeaders);
  17403.                 }
  17404.                
  17405.                 gestioneCors.setAccessControlAllAllowMethods(corsAllAllowMethods ? StatoFunzionalita.ABILITATO : StatoFunzionalita.DISABILITATO);
  17406.                 if(!corsAllAllowMethods) {
  17407.                     CorsConfigurazioneMethods accessControlAllowMethods = new CorsConfigurazioneMethods();
  17408.                     accessControlAllowMethods.setMethodList(Arrays.asList(corsAllowMethods.split(",")));
  17409.                     gestioneCors.setAccessControlAllowMethods(accessControlAllowMethods);
  17410.                 }

  17411.                 gestioneCors.setAccessControlAllowCredentials(corsAllowCredential ? StatoFunzionalita.ABILITATO : StatoFunzionalita.DISABILITATO);

  17412.                 CorsConfigurazioneHeaders accessControlExposeHeaders = new CorsConfigurazioneHeaders();
  17413.                 accessControlExposeHeaders.setHeaderList(Arrays.asList(corsExposeHeaders.split(",")));
  17414.                 gestioneCors.setAccessControlExposeHeaders(accessControlExposeHeaders );

  17415.                 gestioneCors.setAccessControlMaxAge(corsMaxAge ? corsMaxAgeSeconds : null);
  17416.             }
  17417.         }
  17418.         return gestioneCors;
  17419.     }
  17420.    
  17421.     public boolean checkDataConfigurazioneCorsPorta(TipoOperazione tipoOperazione,boolean showStato, String statoCorsPorta) throws DriverControlStationException{
  17422.        
  17423.         if(showStato) {
  17424.             if(StringUtils.isEmpty(statoCorsPorta) || !(statoCorsPorta.equals(CostantiControlStation.VALUE_PARAMETRO_CORS_STATO_DEFAULT) || statoCorsPorta.equals(CostantiControlStation.VALUE_PARAMETRO_CORS_STATO_RIDEFINITO))) {
  17425.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_NON_VALIDO, CostantiControlStation.LABEL_PARAMETRO_CORS_STATO_PORTA));
  17426.                 return false;
  17427.             }
  17428.         }
  17429.        
  17430.         if(!showStato || statoCorsPorta.equals(CostantiControlStation.VALUE_PARAMETRO_DUMP_STATO_RIDEFINITO)) {
  17431.             return this.checkDataCors();
  17432.         }
  17433.        
  17434.         return true;
  17435.     }
  17436.    
  17437.     public boolean checkDataURLInvocazione() throws DriverControlStationException {
  17438.        
  17439.         String urlInvocazionePA = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PA);
  17440.        
  17441.         if(StringUtils.isEmpty(urlInvocazionePA)){
  17442.             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PA));
  17443.             return false;
  17444.         }
  17445.        
  17446.         if(urlInvocazionePA.contains(" ")) {
  17447.             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_SPAZI_BIANCHI_NON_AMMESSI, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PA));  
  17448.             return false;
  17449.         }
  17450.        
  17451.         if(!this.checkLength(urlInvocazionePA, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PA, 1, 255)) {
  17452.             return false;
  17453.         }
  17454.        
  17455.         try{
  17456.             org.openspcoop2.utils.regexp.RegExpUtilities.validateUrl(urlInvocazionePA);
  17457.         }catch(Exception e){
  17458.             this.pd.setMessage(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PA + " non correttamente formata: "+e.getMessage());
  17459.             return false;
  17460.         }
  17461.        
  17462.         String urlInvocazionePD = this.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PD);
  17463.        
  17464.         /*
  17465.         if(StringUtils.isEmpty(urlInvocazionePD)){
  17466.             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PD));
  17467.             return false;
  17468.         }
  17469.         */
  17470.         if(!StringUtils.isEmpty(urlInvocazionePD)){
  17471.             if(urlInvocazionePD.contains(" ")) {
  17472.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_SPAZI_BIANCHI_NON_AMMESSI, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PD));  
  17473.                 return false;
  17474.             }
  17475.            
  17476.             if(!this.checkLength(urlInvocazionePD, ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PD, 1, 255)) {
  17477.                 return false;
  17478.             }
  17479.        
  17480.             try{
  17481.                 org.openspcoop2.utils.regexp.RegExpUtilities.validateUrl(urlInvocazionePD);
  17482.             }catch(Exception e){
  17483.                 this.pd.setMessage(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_PROTOCOLLO_PREFIX_URL_INVOCAZIONE_PD + " non correttamente formata: "+e.getMessage());
  17484.                 return false;
  17485.             }
  17486.         }
  17487.            
  17488.         return true;
  17489.     }
  17490.    
  17491.     public boolean checkDataCors() throws DriverControlStationException {
  17492.         String corsStatoTmp = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_STATO);
  17493.         boolean corsStato = ServletUtils.isCheckBoxEnabled(corsStatoTmp);
  17494.         if(corsStato) {
  17495.             String corsTipoTmp = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_TIPO);
  17496.             TipoGestioneCORS corsTipo = corsTipoTmp != null ? TipoGestioneCORS.toEnumConstant(corsTipoTmp) : TipoGestioneCORS.GATEWAY;
  17497.             if(corsTipo.equals(TipoGestioneCORS.GATEWAY)) {
  17498.                 String corsAllAllowOriginsTmp = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_ORIGINS);
  17499.                 boolean corsAllAllowOrigins = ServletUtils.isCheckBoxEnabled(corsAllAllowOriginsTmp);
  17500.                 if(!corsAllAllowOrigins) {
  17501.                     String corsAllowOrigins =  this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_ORIGINS);
  17502.                     if(StringUtils.isNotEmpty(corsAllowOrigins)) {
  17503.                         List<String> asList = Arrays.asList(corsAllowOrigins.split(","));
  17504.                         for (String string : asList) {
  17505.                             if(string.contains(" ")) {
  17506.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_SPAZI_BIANCHI_NON_AMMESSI, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_ORIGINS));  
  17507.                                 return false;
  17508.                             }
  17509.                         }
  17510.                     } else {
  17511.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_CAMPO_OBBLIGATORIO, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_ORIGINS));  
  17512.                         return false;
  17513.                     }
  17514.                 }
  17515.                
  17516.                 String corsAllAllowHeadersTmp = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_HEADERS);
  17517.                 boolean corsAllAllowHeaders = ServletUtils.isCheckBoxEnabled(corsAllAllowHeadersTmp);
  17518.                 if(corsAllAllowHeaders && corsAllAllowOrigins) {
  17519.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_DIPENDENZA,
  17520.                             CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_ORIGINS,
  17521.                             CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_HEADERS));  
  17522.                     return false;
  17523.                 }
  17524.                 if(!corsAllAllowHeaders) {
  17525.                     String corsAllowHeaders =  this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_HEADERS);
  17526.                     if(StringUtils.isNotEmpty(corsAllowHeaders)) {
  17527.                         List<String> asList = Arrays.asList(corsAllowHeaders.split(","));
  17528.                         for (String string : asList) {
  17529.                             if(string.contains(" ")) {
  17530.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_SPAZI_BIANCHI_NON_AMMESSI, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_HEADERS));  
  17531.                                 return false;
  17532.                             }
  17533.                         }
  17534.                     } else {
  17535.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_CAMPO_OBBLIGATORIO, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_HEADERS));  
  17536.                         return false;
  17537.                     }
  17538.                 }
  17539.                
  17540.                 String corsAllAllowMethodsTmp = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_METHODS);
  17541.                 boolean corsAllAllowMethods = ServletUtils.isCheckBoxEnabled(corsAllAllowMethodsTmp);
  17542.                 if(corsAllAllowMethods && corsAllAllowOrigins) {
  17543.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_DIPENDENZA,
  17544.                             CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_ORIGINS,
  17545.                             CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALL_ALLOW_METHODS));  
  17546.                     return false;
  17547.                 }
  17548.                 if(!corsAllAllowMethods) {
  17549.                     String corsAllowMethods =  this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_METHODS);
  17550.                     if(StringUtils.isNotEmpty(corsAllowMethods)) {
  17551.                         List<String> asList = Arrays.asList(corsAllowMethods.split(","));
  17552.                         for (String string : asList) {
  17553.                             if(string.contains(" ")) {
  17554.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_SPAZI_BIANCHI_NON_AMMESSI, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_METHODS));  
  17555.                                 return false;
  17556.                             }
  17557.                            
  17558.                             try {
  17559.                                 // check che HTTP-Method sia supportato
  17560.                                 Enum.valueOf(HttpRequestMethod.class, string.toUpperCase());
  17561.                             } catch(Exception e) {
  17562.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_ALLOW_METHOD_NON_VALIDO, string, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_METHODS));  
  17563.                                 return false;
  17564.                             }
  17565.                         }
  17566.                     }else {
  17567.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_CAMPO_OBBLIGATORIO, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_METHODS));  
  17568.                         return false;
  17569.                     }
  17570.                 }
  17571.                
  17572. //              String corsAllowCredentialTmp = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_ALLOW_CREDENTIALS);
  17573. //              boolean corsAllowCredential =  ServletUtils.isCheckBoxEnabled(corsAllowCredentialTmp);
  17574.                
  17575.                 String corsExposeHeaders = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_EXPOSE_HEADERS);
  17576.                 if(StringUtils.isNotEmpty(corsExposeHeaders)) {
  17577.                     List<String> asList = Arrays.asList(corsExposeHeaders.split(","));
  17578.                     for (String string : asList) {
  17579.                         if(string.contains(" ")) {
  17580.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_SPAZI_BIANCHI_NON_AMMESSI, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CORS_EXPOSE_HEADERS));  
  17581.                             return false;
  17582.                         }
  17583.                     }
  17584.                 }
  17585.                
  17586.                
  17587. //              String corsMaxAgeTmp = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_MAX_AGE);
  17588. //              boolean corsMaxAge =  ServletUtils.isCheckBoxEnabled(corsMaxAgeTmp);
  17589. //              if(corsMaxAge) {
  17590. //                  String corsMaxAgeSecondsTmp = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CORS_MAX_AGE_SECONDS);
  17591. //                  int corsMaxAgeSeconds = -1;
  17592. //                  if(corsMaxAgeSecondsTmp != null) {
  17593. //                      try {
  17594. //                          corsMaxAgeSeconds = Integer.parseInt(corsMaxAgeSecondsTmp);
  17595. //                      }catch(Exception e) {}
  17596. //                  }
  17597. //              }
  17598.             }
  17599.         }
  17600.         return true;
  17601.     }
  17602.    
  17603.     public void addDescrizioneVerificaConnettoreToDati(List<DataElement> dati, String server, String labelConnettore,
  17604.             Connettore connettore, boolean registro, String aliasConnettore) throws DriverControlStationException {
  17605.        
  17606.         List<Parameter> downloadCertServerParameters = new ArrayList<>();
  17607.        
  17608.         downloadCertServerParameters.add(new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_CERTIFICATI_SERVER_ID_CONNETTORE, connettore.getId().longValue()+""));
  17609.        
  17610.         this.addDescrizioneVerificaConnettivitaToDati(dati, connettore,
  17611.                 server, false, aliasConnettore,
  17612.                 downloadCertServerParameters,
  17613.                 false, false);
  17614.        
  17615.     }
  17616.    
  17617.     public void addVerificaConnettoreSceltaAlias(List<String> aliases,List<DataElement> dati) throws DriverControlStationException {
  17618.        
  17619.         DataElement de = new DataElement();
  17620.         de.setType(DataElementType.SELECT);
  17621.         List<String> values = new ArrayList<>();
  17622.         List<String> labels = new ArrayList<>();
  17623.         values.add(CostantiControlStation.LABEL_VERIFICA_CONNETTORE_TUTTI_I_NODI);
  17624.         labels.add(CostantiControlStation.LABEL_VERIFICA_CONNETTORE_TUTTI_I_NODI);
  17625.         values.addAll(this.confCore.getJmxPdDAliases());
  17626.         for (String alias : this.confCore.getJmxPdDAliases()) {
  17627.             try {
  17628.                 labels.add(this.confCore.getJmxPdDDescrizione(alias));
  17629.             }catch(Exception e) {
  17630.                 throw new DriverControlStationException(e.getMessage(),e);
  17631.             }
  17632.         }
  17633.         de.setValues(values);
  17634.         de.setLabels(labels);
  17635.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER);
  17636.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER);
  17637.         de.setSize(this.getSize());
  17638.         //de.setPostBack(true);
  17639.         dati.add(de);
  17640.        
  17641.     }
  17642.    
  17643.     public void addVerificaConnettoreHidden(List<DataElement> dati,
  17644.             String id, String idsogg,  String idAsps, String idFruizione,
  17645.             long idConnettore, boolean accessoDaGruppi, boolean connettoreRegistro) throws DriverControlStationException {

  17646.         DataElement de = new DataElement();
  17647.         de.setType(DataElementType.HIDDEN);
  17648.         de.setName(CostantiControlStation.PARAMETRO_ID);
  17649.         de.setValue(id);
  17650.         dati.add(de);
  17651.        
  17652.         de = new DataElement();
  17653.         de.setType(DataElementType.HIDDEN);
  17654.         de.setName(CostantiControlStation.PARAMETRO_ID_SOGGETTO);
  17655.         de.setValue(idsogg);
  17656.         dati.add(de);
  17657.        
  17658.         de = new DataElement();
  17659.         de.setType(DataElementType.HIDDEN);
  17660.         de.setName(CostantiControlStation.PARAMETRO_ID_ASPS);
  17661.         de.setValue(idAsps);
  17662.         dati.add(de);
  17663.        
  17664.         de = new DataElement();
  17665.         de.setType(DataElementType.HIDDEN);
  17666.         de.setName(CostantiControlStation.PARAMETRO_ID_FRUIZIONE);
  17667.         de.setValue(idFruizione);
  17668.         dati.add(de);
  17669.        
  17670.         de = new DataElement();
  17671.         de.setType(DataElementType.HIDDEN);
  17672.         de.setName(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ID);
  17673.         de.setValue(idConnettore+"");
  17674.         dati.add(de);
  17675.        
  17676.         de = new DataElement();
  17677.         de.setType(DataElementType.HIDDEN);
  17678.         de.setName(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_GRUPPI);
  17679.         de.setValue(accessoDaGruppi+"");
  17680.         dati.add(de);
  17681.        
  17682.         de = new DataElement();
  17683.         de.setType(DataElementType.HIDDEN);
  17684.         de.setName(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_REGISTRO);
  17685.         de.setValue(connettoreRegistro+"");
  17686.         dati.add(de);
  17687.        
  17688.     }
  17689.    
  17690.     public boolean isConnettoreRidefinito(PortaApplicativa paDefault,   PortaApplicativaServizioApplicativo paSADefault,
  17691.             PortaApplicativa paCurrent, PortaApplicativaServizioApplicativo paSACurrent,
  17692.             List<PortaApplicativaServizioApplicativo> list_paSACurrent) throws DriverControlStationException {
  17693.        
  17694.         if(paDefault==null) {
  17695.             throw new DriverControlStationException("Param paDefault is null");
  17696.         }
  17697.         if(paCurrent==null) {
  17698.             throw new DriverControlStationException("Param paCurrent is null");
  17699.         }
  17700.        
  17701.         boolean connettoreRidefinito = (
  17702.                 (
  17703.                     paDefault.getServizioApplicativoDefault() == null && (paCurrent.getServizioApplicativoDefault() != null || paSACurrent.getNome().equals(paCurrent.getNome()))
  17704.                 ) || (
  17705.                     paDefault.getServizioApplicativoDefault() != null &&
  17706.                         (
  17707.                             paCurrent.getServizioApplicativoDefault() == null
  17708.                             ||
  17709.                             !paDefault.getServizioApplicativoDefault().equals(paCurrent.getServizioApplicativoDefault())
  17710.                             ||
  17711.                             paDefault.sizeServizioApplicativoList()!=paCurrent.sizeServizioApplicativoList()
  17712.                             ||
  17713.                             (paDefault.sizeServizioApplicativoList()==1 && paCurrent.sizeServizioApplicativoList()==1 && !paDefault.getServizioApplicativo(0).getNome().equals(paCurrent.getServizioApplicativo(0).getNome()))
  17714.                         )
  17715.                     //!paSADefault.getNome().equals(paSACurrent.getNome()))
  17716.                 )
  17717.             );
  17718.         if(!connettoreRidefinito) {
  17719.             boolean connettoreMultiploEnabled = paCurrent.getBehaviour() != null;
  17720.             if(connettoreMultiploEnabled && paDefault.getServizioApplicativoDefault() == null && paCurrent.getServizioApplicativoDefault() == null) {
  17721.                 if(list_paSACurrent!=null && !list_paSACurrent.isEmpty() && list_paSACurrent.size()>1) { // se uguale a 1 si rientra nel primo caso sopra, altrimenti l'ordine potrebbe cambiare e non essere alla posizione 0 quello di default
  17722.                     for (PortaApplicativaServizioApplicativo portaApplicativaServizioApplicativo : list_paSACurrent) {
  17723.                         if(portaApplicativaServizioApplicativo.getNome().equals(paCurrent.getNome())){
  17724.                             connettoreRidefinito = true;
  17725.                             break;
  17726.                         }
  17727.                     }
  17728.                 }
  17729.             }
  17730.         }
  17731.         return connettoreRidefinito;
  17732.     }
  17733.    
  17734.     public String getTooltipConnettore(ServizioApplicativo sa, org.openspcoop2.core.config.InvocazioneServizio is, boolean addExtInfo) throws DriverControlStationException {
  17735.        
  17736.         if(sa==null) {
  17737.             throw new DriverControlStationException("Param sa is null");
  17738.         }
  17739.        
  17740.         StringBuilder sbCon = new StringBuilder();
  17741.         if(ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(sa.getTipo())) {
  17742.             sbCon.append(ConnettoriCostanti.LABEL_SERVER);
  17743.             sbCon.append(": ");
  17744.             sbCon.append(sa.getNome());
  17745.             sbCon.append(CostantiControlStation.TOOLTIP_BREAK_LINE);
  17746.         }
  17747.         sbCon.append(this.getLabelConnettore(is, addExtInfo, true));
  17748.         return sbCon.toString();
  17749.     }
  17750.    
  17751.     public String getClipBoardUrlConnettore(ServizioApplicativo sa, org.openspcoop2.core.config.InvocazioneServizio is) throws DriverControlStationException {
  17752.        
  17753.         if(sa==null) {
  17754.             throw new DriverControlStationException("Param sa is null");
  17755.         }
  17756.        
  17757.         StringBuilder sbCon = new StringBuilder();
  17758.         sbCon.append(this.getClipBoardUrlConnettore(is));
  17759.         return sbCon.toString();
  17760.     }
  17761.    
  17762.     public String getClipBoardUrlConnettore(org.openspcoop2.core.config.InvocazioneServizio is) throws DriverControlStationException {
  17763.        
  17764.         if(is==null) {
  17765.             throw new DriverControlStationException("Param is is null");
  17766.         }
  17767.        
  17768.         // la parte che aggiungeva MessageBox e' stata eliminata
  17769.         return this.getLabelConnettoreInternal(is.getConnettore(), false, false, false);
  17770.     }
  17771.     public String getClipBoardUrlConnettore(org.openspcoop2.core.registry.Connettore connettore) throws DriverControlStationException {
  17772.        
  17773.         if(connettore==null) {
  17774.             throw new DriverControlStationException("Param connettore is null");
  17775.         }
  17776.        
  17777.         return this.getLabelConnettoreInternal(connettore.mappingIntoConnettoreConfigurazione(), false, false, false);
  17778.     }
  17779.    
  17780.     public String getLabelConnettore(ServizioApplicativo sa, org.openspcoop2.core.config.InvocazioneServizio is, boolean addExtInfo) throws DriverControlStationException {
  17781.        
  17782.         if(sa==null) {
  17783.             throw new DriverControlStationException("Param sa is null");
  17784.         }
  17785.        
  17786.         StringBuilder sbCon = new StringBuilder();
  17787. //      if(ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(sa.getTipo())) {
  17788. //          //sbCon.append(sa.getNome());
  17789. //          //sbCon.append(" ");
  17790. //      }
  17791.         sbCon.append(this.getLabelConnettore(is, addExtInfo, false));
  17792.         return sbCon.toString();
  17793.     }
  17794.    
  17795.     public String getLabelConnettore(org.openspcoop2.core.config.InvocazioneServizio is, boolean addExtInfo, boolean tooltip) throws DriverControlStationException {
  17796.        
  17797.         if(is==null) {
  17798.             throw new DriverControlStationException("Param is is null");
  17799.         }
  17800.        
  17801.         String urlConnettore = this.getLabelConnettore(is.getConnettore(), addExtInfo, tooltip);
  17802.        
  17803.         if(is.getGetMessage()!=null && StatoFunzionalita.ABILITATO.equals(is.getGetMessage())) {
  17804.             urlConnettore = urlConnettore + " [MessageBox]";
  17805.         }
  17806.        
  17807.         return urlConnettore;
  17808.     }
  17809.     public String getLabelConnettore(org.openspcoop2.core.registry.Connettore connettore, boolean addExtInfo, boolean tooltip) throws DriverControlStationException {
  17810.        
  17811.         if(connettore==null) {
  17812.             throw new DriverControlStationException("Param connettore is null");
  17813.         }
  17814.        
  17815.         return this.getLabelConnettore(connettore.mappingIntoConnettoreConfigurazione(), addExtInfo, tooltip);
  17816.     }
  17817.     public String getLabelConnettore(org.openspcoop2.core.config.Connettore connettore, boolean addExtInfo, boolean tooltip) throws DriverControlStationException {
  17818.         return getLabelConnettoreInternal(connettore, addExtInfo, tooltip, true);
  17819.     }
  17820.     private String getLabelConnettoreInternal(org.openspcoop2.core.config.Connettore connettore, boolean addExtInfo, boolean tooltip, boolean addPrefix) throws DriverControlStationException {
  17821.        
  17822.         if(connettore==null) {
  17823.             throw new DriverControlStationException("Param connettore is null");
  17824.         }
  17825.        
  17826.         String urlConnettore = "";
  17827.        
  17828.         List<org.openspcoop2.core.config.Property> cp = connettore.getPropertyList();
  17829.        
  17830.         //TipiConnettore.HTTP.getNome() e anche TipiConnettore.HTTPS.getNome() -> location
  17831.         //TipiConnettore.DISABILITATO.getNome() ci scrivi "disabilitato"
  17832.         //TipiConnettore.FILE.getNome() CostantiConnettori.CONNETTORE_FILE_REQUEST_OUTPUT_FILE
  17833.         //TipiConnettore.JMS.compareTo() CostantiConnettori.CONNETTORE_LOCATION
  17834. //          TipiConnettore.NULL
  17835. //          TipiConnettore.CUSTOM -> connettore custom
  17836.         String tipo = connettore.getTipo();
  17837.        
  17838.         TipiConnettore tipoC = TipiConnettore.toEnumFromName(connettore.getTipo());
  17839.         String labelC = connettore.getTipo();
  17840.         if(tipoC!=null) {
  17841.             labelC = tipoC.getLabel();
  17842.         }
  17843.         String tipoLabel = addPrefix ? "[" + labelC + "] " : "";
  17844.         if ((connettore.getCustom()!=null && connettore.getCustom()) &&
  17845.                 !connettore.getTipo().equals(CostantiDB.CONNETTORE_TIPO_HTTPS) &&
  17846.                 !connettore.getTipo().equals(CostantiDB.CONNETTORE_TIPO_FILE) &&
  17847.                 !connettore.getTipo().equals(CostantiDB.CONNETTORE_TIPO_STATUS)) {
  17848.             tipo = ConnettoriCostanti.DEFAULT_CONNETTORE_TYPE_CUSTOM;
  17849.         }  

  17850.         if(tipo.equals(ConnettoriCostanti.DEFAULT_CONNETTORE_TYPE_CUSTOM)) {
  17851.             if(this.connettoriCore.isConfigurazionePluginsEnabled()) {
  17852.                 tipoLabel = addPrefix ? "[" + TipiConnettore.CUSTOM.getLabel() + "] " : "";
  17853.                 Plugin plugin = null;
  17854.                 try {
  17855.                     plugin = this.confCore.getPlugin(TipoPlugin.CONNETTORE,connettore.getTipo(), false);
  17856.                 }catch(Throwable e) {
  17857.                     // ignore
  17858.                 }
  17859.                 if(plugin!=null) {
  17860.                     urlConnettore = tipoLabel + plugin.getLabel();
  17861.                 }
  17862.                 else {
  17863.                     // backward compatibility
  17864.                     urlConnettore = tipoLabel + connettore.getTipo();
  17865.                 }
  17866.             }
  17867.             else {
  17868.                 urlConnettore = tipoLabel + ConnettoriCostanti.LABEL_CONNETTORE_CUSTOM;
  17869.             }
  17870.         } else  if(tipo.equals(TipiConnettore.DISABILITATO.getNome())) {
  17871.             urlConnettore = CostantiControlStation.DEFAULT_VALUE_DISABILITATO;
  17872.         } else if(tipo.equals(TipiConnettore.NULL.getNome())) {
  17873.             urlConnettore = tipoLabel + ConnettoreNULL.LOCATION;
  17874.         } else if(tipo.equals(TipiConnettore.NULLECHO.getNome())) {
  17875.             urlConnettore = tipoLabel + ConnettoreNULLEcho.LOCATION;
  17876.         } else if(tipo.equals(TipiConnettore.STATUS.getNome())) {
  17877.             urlConnettore = tipoLabel + ConnettoreStatus.LOCATION;
  17878.         } else {  
  17879.             String propertyName = CostantiConnettori.CONNETTORE_LOCATION;
  17880.             if(tipo.equals(TipiConnettore.FILE.getNome()))
  17881.                 propertyName = CostantiConnettori.CONNETTORE_FILE_REQUEST_OUTPUT_FILE;
  17882.        
  17883.             // Prefix token
  17884.             String token = "";
  17885.             if(addExtInfo) {
  17886.                 if(tipo.equals(TipiConnettore.HTTP.getNome()) || tipo.equals(TipiConnettore.HTTPS.getNome())) {
  17887.                     for (int i = 0; i < connettore.sizePropertyList(); i++) {
  17888.                         org.openspcoop2.core.config.Property singlecp = cp.get(i);
  17889.                         if (singlecp.getNome().equals(CostantiConnettori.CONNETTORE_TOKEN_POLICY) &&
  17890.                                 singlecp.getValore()!=null && StringUtils.isNotEmpty(singlecp.getValore())) {
  17891.                             if(tooltip) {
  17892.                                 token = "[token: "+singlecp.getValore()+"]\n";
  17893.                             }
  17894.                             else {
  17895.                                 token = "[token] ";
  17896.                             }
  17897.                         }
  17898.                     }
  17899.                 }
  17900.             }
  17901.            
  17902.             for (int i = 0; i < connettore.sizePropertyList(); i++) {
  17903.                 org.openspcoop2.core.config.Property singlecp = cp.get(i);
  17904.                 if (singlecp.getNome().equals(propertyName)) {
  17905.                     if(!tipo.equals(TipiConnettore.HTTP.getNome()) && !tipo.equals(TipiConnettore.HTTPS.getNome())) {
  17906.                         urlConnettore = tipoLabel + singlecp.getValore();
  17907.                     }
  17908.                     else {
  17909.                         urlConnettore = token + singlecp.getValore();
  17910.                     }
  17911.                    
  17912.                     break;
  17913.                 }
  17914.             }
  17915.         }
  17916.         return urlConnettore;
  17917.     }
  17918.    
  17919.     public void addConfigurazioneResponseCachingPorteToDati(TipoOperazione tipoOperazione,List<DataElement> dati, boolean showStato, String statoResponseCachingPorta, boolean responseCachingEnabled, int responseCachingSeconds,
  17920.             boolean responseCachingMaxResponseSize, long responseCachingMaxResponseSizeBytes,
  17921.             boolean responseCachingDigestUrlInvocazione, boolean responseCachingDigestHeaders,
  17922.             boolean responseCachingDigestPayload, String responseCachingDigestHeadersNomiHeaders, StatoFunzionalitaCacheDigestQueryParameter responseCachingDigestQueryParameter, String responseCachingDigestNomiParametriQuery,
  17923.             boolean responseCachingCacheControlNoCache, boolean responseCachingCacheControlMaxAge, boolean responseCachingCacheControlNoStore, boolean visualizzaLinkConfigurazioneRegola,
  17924.             String servletResponseCachingConfigurazioneRegolaList, List<Parameter> paramsResponseCachingConfigurazioneRegolaList, int numeroResponseCachingConfigurazioneRegola) throws DriverControlStationException {
  17925.        
  17926.         if(showStato) {
  17927.             DataElement de = new DataElement();
  17928.             de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_RESPONSE_CACHING);
  17929.             de.setType(DataElementType.TITLE);
  17930.             dati.add(de);
  17931.         }
  17932.        
  17933.         // stato generale cors
  17934.         DataElement de = new DataElement();
  17935.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_STATO_PORTA);
  17936.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RESPONSE_CACHING_STATO_PORTA);
  17937.         if(showStato) {
  17938.             try {
  17939.                 de.setType(DataElementType.SELECT);
  17940.                 String valuesStato [] = {CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_DEFAULT, CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_RIDEFINITO};
  17941.                 String labelsStato [] = { this.getResponseCachingLabelDefault(true), CostantiControlStation.LABEL_PARAMETRO_RESPONSE_CACHING_STATO_PORTA_RIDEFINITO};
  17942.                 de.setSelected(statoResponseCachingPorta);
  17943.                 de.setLabels(labelsStato);
  17944.                 de.setValues(valuesStato);
  17945.                 de.setPostBack(true);
  17946.             }catch(Exception e) {
  17947.                 throw new DriverControlStationException(e.getMessage(),e);
  17948.             }
  17949.         } else {
  17950.             de.setType(DataElementType.HIDDEN);
  17951.             de.setValue(statoResponseCachingPorta);
  17952.         }
  17953.         dati.add(de);
  17954.        
  17955.         if(!showStato || statoResponseCachingPorta.equals(CostantiControlStation.VALUE_PARAMETRO_CORS_STATO_RIDEFINITO)) {
  17956.             this.addResponseCachingToDati(dati, responseCachingEnabled, responseCachingSeconds, responseCachingMaxResponseSize,
  17957.                     responseCachingMaxResponseSizeBytes, responseCachingDigestUrlInvocazione, responseCachingDigestHeaders, responseCachingDigestPayload, false, responseCachingDigestHeadersNomiHeaders, responseCachingDigestQueryParameter, responseCachingDigestNomiParametriQuery,
  17958.                     responseCachingCacheControlNoCache, responseCachingCacheControlMaxAge, responseCachingCacheControlNoStore, visualizzaLinkConfigurazioneRegola,
  17959.                     servletResponseCachingConfigurazioneRegolaList, paramsResponseCachingConfigurazioneRegolaList, numeroResponseCachingConfigurazioneRegola,
  17960.                     false);
  17961.         }
  17962.     }
  17963.    
  17964.     public void addResponseCachingToDati(List<DataElement> dati, boolean responseCachingEnabled, int responseCachingSeconds,
  17965.             boolean responseCachingMaxResponseSize, long responseCachingMaxResponseSizeBytes,
  17966.             boolean responseCachingDigestUrlInvocazione, boolean responseCachingDigestHeaders,
  17967.             boolean responseCachingDigestPayload, boolean addTitle, String responseCachingDigestHeadersNomiHeaders, StatoFunzionalitaCacheDigestQueryParameter responseCachingDigestQueryParameter, String responseCachingDigestNomiParametriQuery,  
  17968.             boolean responseCachingCacheControlNoCache, boolean responseCachingCacheControlMaxAge, boolean responseCachingCacheControlNoStore, boolean visualizzaLinkConfigurazioneRegola,
  17969.             String servletResponseCachingConfigurazioneRegolaList, List<Parameter> paramsResponseCachingConfigurazioneRegolaList, int numeroResponseCachingConfigurazioneRegola,
  17970.             boolean allHidden) {
  17971.         DataElement de;
  17972.         if(!allHidden && addTitle) {
  17973.             de = new DataElement();
  17974.             de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_RESPONSE_CACHING);
  17975.             de.setType(DataElementType.TITLE);
  17976.             dati.add(de);
  17977.         }
  17978.        
  17979.         de = new DataElement();
  17980.         de.setLabel(addTitle ?  CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_STATO : "");
  17981.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_STATO);
  17982.         if(allHidden) {
  17983.             de.setType(DataElementType.HIDDEN);
  17984.         }
  17985.         else {
  17986.             de.setType(DataElementType.SELECT);
  17987.             de.setPostBack(true);
  17988.             de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA);
  17989.             de.setSelected(responseCachingEnabled ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue());
  17990.         }
  17991.         de.setValue(responseCachingEnabled ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue());
  17992.         dati.add(de);
  17993.        
  17994.         if(responseCachingEnabled) {
  17995.             de = new DataElement();
  17996.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_TIMEOUT);
  17997.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_TIMEOUT);
  17998.             de.setValue(responseCachingSeconds+"");
  17999.             if(allHidden) {
  18000.                 de.setType(DataElementType.HIDDEN);
  18001.             }
  18002.             else {
  18003.                 de.setType(DataElementType.NUMBER);
  18004.                 de.setMinValue(1);
  18005.                 de.setMaxValue(Integer.MAX_VALUE);
  18006.             }
  18007.             dati.add(de);
  18008.            
  18009.            
  18010.             de = new DataElement();
  18011.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_MAX_RESPONSE_SIZE);
  18012.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_MAX_RESPONSE_SIZE);
  18013.             if(allHidden) {
  18014.                 de.setType(DataElementType.HIDDEN);
  18015.             }
  18016.             else {
  18017.                 de.setType(DataElementType.CHECKBOX);
  18018.                 de.setSelected(responseCachingMaxResponseSize);
  18019.                 de.setPostBack(true);
  18020.             }
  18021.             de.setValue(responseCachingMaxResponseSize+"");
  18022.             dati.add(de);
  18023.            
  18024.             if(responseCachingMaxResponseSize) {
  18025.                 de = new DataElement();
  18026.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_MAX_RESPONSE_SIZE_BYTES);
  18027.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_MAX_RESPONSE_SIZE_BYTES);
  18028.                 de.setValue(responseCachingMaxResponseSizeBytes+"");
  18029.                 if(allHidden) {
  18030.                     de.setType(DataElementType.HIDDEN);
  18031.                 }
  18032.                 else {
  18033.                     de.setType(DataElementType.NUMBER);
  18034.                     de.setMinValue(1);
  18035.                     de.setMaxValue(Integer.MAX_VALUE);
  18036.                 }
  18037.                 dati.add(de);
  18038.             }
  18039.            
  18040.             if(!allHidden) {
  18041.                 de = new DataElement();
  18042.                 de.setType(DataElementType.SUBTITLE);
  18043.                 de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_RESPONSE_CACHING_GENERAZIONE_HASH);
  18044.                 dati.add(de);
  18045.             }
  18046.            
  18047.             de = new DataElement();
  18048.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_URI_INVOCAZIONE);
  18049.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_URI_INVOCAZIONE);
  18050.             if(allHidden) {
  18051.                 de.setType(DataElementType.HIDDEN);
  18052.             }
  18053.             else {
  18054.                 de.setType(DataElementType.SELECT);
  18055.                 de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA);
  18056.                 de.setSelected(responseCachingDigestUrlInvocazione ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue());
  18057.             }
  18058.             de.setValue(responseCachingDigestUrlInvocazione ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue());
  18059.             dati.add(de);
  18060.            
  18061.             de = new DataElement();
  18062.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS);
  18063.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS);
  18064.             if(allHidden) {
  18065.                 de.setType(DataElementType.HIDDEN);
  18066.             }
  18067.             else {
  18068.                 de.setType(DataElementType.SELECT);
  18069.                 de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA_RESPONSE_CACHING_DIGEST_QUERY_PARAMETERS);
  18070.                 if(responseCachingDigestQueryParameter!=null) {
  18071.                     de.setSelected(responseCachingDigestQueryParameter.getValue());
  18072.                 }
  18073.                 de.setPostBack(true);
  18074.             }
  18075.             if(responseCachingDigestQueryParameter!=null) {
  18076.                 de.setValue(responseCachingDigestQueryParameter.getValue());
  18077.             }
  18078.             dati.add(de);
  18079.            
  18080.             if(StatoFunzionalitaCacheDigestQueryParameter.SELEZIONE_PUNTUALE.equals(responseCachingDigestQueryParameter)) {
  18081.                 de = new DataElement();
  18082. //              de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS_NOMI);
  18083.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS_NOMI);
  18084.                 if(allHidden) {
  18085.                     de.setType(DataElementType.HIDDEN);
  18086.                 }
  18087.                 else {
  18088.                     de.setType(DataElementType.TEXT_EDIT);
  18089.                     de.enableTags();
  18090.                     de.setNote(CostantiControlStation.NOTE_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS_NOMI);
  18091. //                  de.setRequired(true);
  18092.                 }
  18093.                 de.setValue(responseCachingDigestNomiParametriQuery);
  18094.                 dati.add(de);
  18095.             }
  18096.            
  18097.             de = new DataElement();
  18098.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_PAYLOAD);
  18099.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_PAYLOAD);
  18100.             if(allHidden) {
  18101.                 de.setType(DataElementType.HIDDEN);
  18102.             }
  18103.             else {
  18104.                 de.setType(DataElementType.SELECT);
  18105.                 de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA);
  18106.                 de.setSelected(responseCachingDigestPayload ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue());
  18107.             }
  18108.             de.setValue(responseCachingDigestPayload ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue());
  18109.             dati.add(de);
  18110.            
  18111.             de = new DataElement();
  18112.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS);
  18113.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS);
  18114.             if(allHidden) {
  18115.                 de.setType(DataElementType.HIDDEN);
  18116.             }
  18117.             else {
  18118.                 de.setType(DataElementType.SELECT);
  18119.                 de.setValues(CostantiControlStation.SELECT_VALUES_STATO_FUNZIONALITA);
  18120.                 de.setSelected(responseCachingDigestHeaders ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue());
  18121.                 de.setPostBack(true);
  18122.             }
  18123.             de.setValue(responseCachingDigestHeaders ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue());
  18124.             dati.add(de);
  18125.            
  18126.             if(responseCachingDigestHeaders) {
  18127.                 de = new DataElement();
  18128. //              de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS_NOMI_HEADERS);
  18129.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS_NOMI_HEADERS);
  18130.                 if(allHidden) {
  18131.                     de.setType(DataElementType.HIDDEN);
  18132.                 }
  18133.                 else {
  18134.                     de.setType(DataElementType.TEXT_EDIT);
  18135.                     de.enableTags();
  18136.                     de.setNote(CostantiControlStation.NOTE_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS_NOMI_HEADERS);
  18137. //                  de.setRequired(true);
  18138.                 }
  18139.                 de.setValue(responseCachingDigestHeadersNomiHeaders);
  18140.                 dati.add(de);
  18141.             }
  18142.            
  18143.             if(!allHidden) {
  18144.                 de = new DataElement();
  18145.                 de.setType(DataElementType.SUBTITLE);
  18146.                 de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_RESPONSE_CACHING_CACHE_CONTROL);
  18147.                 dati.add(de);
  18148.             }
  18149.            
  18150.             de = new DataElement();
  18151.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CACHE_CONTROL_NO_CACHE);
  18152.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CACHE_CONTROL_NO_CACHE);
  18153.             if(allHidden) {
  18154.                 de.setType(DataElementType.HIDDEN);
  18155.             }
  18156.             else {
  18157.                 de.setType(DataElementType.CHECKBOX);
  18158.                 de.setSelected(responseCachingCacheControlNoCache);
  18159.             }
  18160.             de.setValue(responseCachingCacheControlNoCache+"");
  18161.             dati.add(de);
  18162.            
  18163.             de = new DataElement();
  18164.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CACHE_CONTROL_MAX_AGE);
  18165.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CACHE_CONTROL_MAX_AGE);
  18166.             if(allHidden) {
  18167.                 de.setType(DataElementType.HIDDEN);
  18168.             }
  18169.             else {
  18170.                 de.setType(DataElementType.CHECKBOX);
  18171.                 de.setSelected(responseCachingCacheControlMaxAge);
  18172.             }
  18173.             de.setValue(responseCachingCacheControlMaxAge+"");
  18174.             dati.add(de);
  18175.            
  18176.             de = new DataElement();
  18177.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CACHE_CONTROL_NO_STORE);
  18178.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CACHE_CONTROL_NO_STORE);
  18179.             if(allHidden) {
  18180.                 de.setType(DataElementType.HIDDEN);
  18181.             }
  18182.             else {
  18183.                 de.setType(DataElementType.CHECKBOX);
  18184.                 de.setSelected(responseCachingCacheControlNoStore);
  18185.             }
  18186.             de.setValue(responseCachingCacheControlNoStore+"");
  18187.             dati.add(de);
  18188.            
  18189.            
  18190.                        
  18191.             if(!allHidden && visualizzaLinkConfigurazioneRegola) {
  18192.                
  18193.                 de = new DataElement();
  18194.                 de.setType(DataElementType.SUBTITLE);
  18195.                 de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIOME_AVANZATA);
  18196.                 dati.add(de);
  18197.                
  18198.                 de = new DataElement();
  18199.                 de.setType(DataElementType.LINK);
  18200.                 boolean contaListeFromSession = ServletUtils.getContaListeFromSession(this.session) != null ? ServletUtils.getContaListeFromSession(this.session) : false;
  18201.                 if (contaListeFromSession)
  18202.                     de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLE+" (" + numeroResponseCachingConfigurazioneRegola + ")");
  18203.                 else
  18204.                     de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLE);
  18205.                 de.setUrl(servletResponseCachingConfigurazioneRegolaList, paramsResponseCachingConfigurazioneRegolaList.toArray(new Parameter[paramsResponseCachingConfigurazioneRegolaList.size()]));
  18206.                 dati.add(de);
  18207.             }
  18208.         }
  18209.     }
  18210.    
  18211.     public ResponseCachingConfigurazione getResponseCaching(boolean responseCachingEnabled, int responseCachingSeconds, boolean responseCachingMaxResponseSize, long responseCachingMaxResponseSizeBytes,
  18212.             boolean responseCachingDigestUrlInvocazione, boolean responseCachingDigestHeaders,  boolean responseCachingDigestPayload, String responseCachingDigestHeadersNomiHeaders, StatoFunzionalitaCacheDigestQueryParameter responseCachingDigestQueryParameter, String responseCachingDigestNomiParametriQuery,
  18213.             boolean responseCachingCacheControlNoCache, boolean responseCachingCacheControlMaxAge, boolean responseCachingCacheControlNoStore,List<ResponseCachingConfigurazioneRegola> listaRegoleCachingConfigurazione) {
  18214.        
  18215.         ResponseCachingConfigurazione responseCaching  = new ResponseCachingConfigurazione();
  18216.        
  18217.         responseCaching.setStato(responseCachingEnabled ? StatoFunzionalita.ABILITATO : StatoFunzionalita.DISABILITATO);
  18218.         if(responseCachingEnabled) {
  18219.             responseCaching.setCacheTimeoutSeconds(responseCachingSeconds);
  18220.            
  18221.             if(responseCachingMaxResponseSize) {
  18222.                 responseCaching.setMaxMessageSize(responseCachingMaxResponseSizeBytes);
  18223.             }
  18224.            
  18225.             if(responseCachingDigestUrlInvocazione || responseCachingDigestHeaders || responseCachingDigestPayload) {
  18226.                 ResponseCachingConfigurazioneHashGenerator hashGenerator = new ResponseCachingConfigurazioneHashGenerator();
  18227.                
  18228.                 hashGenerator.setPayload(responseCachingDigestPayload ? StatoFunzionalita.ABILITATO : StatoFunzionalita.DISABILITATO);
  18229.                 hashGenerator.setRequestUri(responseCachingDigestUrlInvocazione ? StatoFunzionalita.ABILITATO : StatoFunzionalita.DISABILITATO);
  18230.                 hashGenerator.setQueryParameters(responseCachingDigestQueryParameter);
  18231.                 if(StringUtils.isNotEmpty(responseCachingDigestNomiParametriQuery)) {
  18232.                     hashGenerator.setQueryParameterList(Arrays.asList(responseCachingDigestNomiParametriQuery.split(",")));
  18233.                 }
  18234.                 hashGenerator.setHeaders(responseCachingDigestHeaders ? StatoFunzionalita.ABILITATO : StatoFunzionalita.DISABILITATO);
  18235.                 if(StringUtils.isNotEmpty(responseCachingDigestHeadersNomiHeaders)) {
  18236.                     hashGenerator.setHeaderList(Arrays.asList(responseCachingDigestHeadersNomiHeaders.split(",")));
  18237.                 }
  18238.                
  18239.                 responseCaching.setHashGenerator(hashGenerator);
  18240.             }
  18241.            
  18242.             ResponseCachingConfigurazioneControl control = new ResponseCachingConfigurazioneControl();
  18243.            
  18244.             control.setNoCache(responseCachingCacheControlNoCache);
  18245.             control.setMaxAge(responseCachingCacheControlMaxAge);
  18246.             control.setNoStore(responseCachingCacheControlNoStore);
  18247.            
  18248.             responseCaching.setControl(control);
  18249.            
  18250.             if(listaRegoleCachingConfigurazione!= null) {
  18251.                 for (ResponseCachingConfigurazioneRegola regola : listaRegoleCachingConfigurazione) {
  18252.                     responseCaching.addRegola(regola);
  18253.                 }
  18254.             }
  18255.         }
  18256.        
  18257.         return responseCaching;
  18258.     }
  18259.    
  18260.     public boolean isResponseCachingAbilitato(ResponseCachingConfigurazione configurazione) {
  18261.         boolean abilitato = false;
  18262.        
  18263.         if(configurazione == null)
  18264.             return false;
  18265.        
  18266.         if(configurazione.getStato().equals(StatoFunzionalita.ABILITATO))
  18267.             return true;
  18268.        
  18269.        
  18270.         return abilitato;
  18271.     }
  18272.    
  18273.     public int numeroRegoleResponseCaching(ResponseCachingConfigurazione configurazione) {
  18274.         if(configurazione == null)
  18275.             return 0;
  18276.        
  18277.         if(configurazione.getStato().equals(StatoFunzionalita.ABILITATO))
  18278.             return configurazione.sizeRegolaList();
  18279.        
  18280.         return 0;
  18281.     }
  18282.    
  18283.     public int numeroRegoleProxyPass(ConfigurazioneUrlInvocazione configurazione) {
  18284.         if(configurazione == null)
  18285.             return 0;
  18286.        
  18287.         return configurazione.sizeRegolaList();
  18288.     }
  18289.    
  18290.     public int numeroPluginsRegistroArchivi()  throws DriverControlStationException {
  18291.         try {
  18292.             return this.confCore.numeroPluginsArchiviList();
  18293.         }catch(Exception e) {
  18294.             throw new DriverControlStationException(e.getMessage(),e);
  18295.         }
  18296.     }
  18297.    
  18298.     public int numeroPluginsRegistroClassi() throws DriverControlStationException {
  18299.         try {
  18300.             return this.confCore.numeroPluginsClassiList();
  18301.         }catch(Exception e) {
  18302.             throw new DriverControlStationException(e.getMessage(),e);
  18303.         }
  18304.     }
  18305.    
  18306.     public boolean isCorsAbilitato(CorsConfigurazione configurazione) {
  18307.         boolean abilitato = false;
  18308.        
  18309.         if(configurazione == null)
  18310.             return false;
  18311.        
  18312.         if(configurazione.getStato().equals(StatoFunzionalita.ABILITATO))
  18313.             return true;
  18314.        
  18315.        
  18316.         return abilitato;
  18317.     }
  18318.    
  18319.     public int numeroCanali(CanaliConfigurazione configurazione) {
  18320.         if(configurazione == null || configurazione.getStato() == null)
  18321.             return 0;
  18322.        
  18323.         if(configurazione.getStato().equals(StatoFunzionalita.ABILITATO))
  18324.             return configurazione.sizeCanaleList();
  18325.        
  18326.         return 0;
  18327.     }
  18328.    
  18329.     public int numeroNodi(CanaliConfigurazione configurazione) {
  18330.         if(configurazione == null || configurazione.getStato() == null)
  18331.             return 0;
  18332.        
  18333.         if(configurazione.getStato().equals(StatoFunzionalita.ABILITATO))
  18334.             return configurazione.sizeNodoList();
  18335.        
  18336.         return 0;
  18337.     }
  18338.    
  18339.     public boolean checkDataConfigurazioneResponseCachingPorta(TipoOperazione tipoOperazione,boolean showStato, String statoResponseCachingPorta) throws DriverControlStationException{
  18340.        
  18341.         if(showStato) {
  18342.             if(StringUtils.isEmpty(statoResponseCachingPorta) ||
  18343.                     !(statoResponseCachingPorta.equals(CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_DEFAULT) || statoResponseCachingPorta.equals(CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_RIDEFINITO))) {
  18344.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CONFIGURAZIONE_DUMPO_VALORE_DEL_CAMPO_XX_NON_VALIDO, CostantiControlStation.LABEL_PARAMETRO_RESPONSE_CACHING_STATO_PORTA));
  18345.                 return false;
  18346.             }
  18347.         }
  18348.        
  18349.         if(!showStato || statoResponseCachingPorta.equals(CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_RIDEFINITO)) {
  18350.             return this.checkDataResponseCaching();
  18351.         }
  18352.        
  18353.         return true;
  18354.     }
  18355.    
  18356.     public boolean checkDataResponseCaching() throws DriverControlStationException {
  18357.        
  18358.         String responseCachingDigestQueryTmp = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS);
  18359.         StatoFunzionalitaCacheDigestQueryParameter stato = null;
  18360.         if(responseCachingDigestQueryTmp!=null) {
  18361.             try {
  18362.                 stato = StatoFunzionalitaCacheDigestQueryParameter.toEnumConstant(responseCachingDigestQueryTmp, true);
  18363.             }catch(Exception e) {
  18364.                 throw new DriverControlStationException(e.getMessage(),e);
  18365.             }
  18366.         }
  18367.         if(StatoFunzionalitaCacheDigestQueryParameter.SELEZIONE_PUNTUALE.equals(stato)) {
  18368.             // se e' abilitato il salvataggio dei parametri della query bisogna indicare quali si vuole salvare
  18369.             String responseCachingDigestNomiQueryParameters =  this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS_NOMI);
  18370.             if(StringUtils.isNotEmpty(responseCachingDigestNomiQueryParameters)) {
  18371.                 List<String> asList = Arrays.asList(responseCachingDigestNomiQueryParameters.split(","));
  18372.                 for (String string : asList) {
  18373.                     if(string.contains(" ")) {
  18374.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_SPAZI_BIANCHI_NON_AMMESSI, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS_NOMI));  
  18375.                         return false;
  18376.                     }
  18377.                 }
  18378.             } else {
  18379.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_CAMPO_OBBLIGATORIO, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS_NOMI));  
  18380.                 return false;
  18381.             }
  18382.         }
  18383.        
  18384.         String responseCachingDigestHeadersTmp = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS);
  18385.         boolean responseCachingDigestHeaders = ServletUtils.isCheckBoxEnabled(responseCachingDigestHeadersTmp);
  18386.         if(responseCachingDigestHeaders) {
  18387.             // se e' abilitato il salvataggio degli headers bisogna indicare quali si vuole salvare
  18388.             String responseCachingDigestHeadersNomiHeaders =  this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS_NOMI_HEADERS);
  18389.             if(StringUtils.isNotEmpty(responseCachingDigestHeadersNomiHeaders)) {
  18390.                 List<String> asList = Arrays.asList(responseCachingDigestHeadersNomiHeaders.split(","));
  18391.                 for (String string : asList) {
  18392.                     if(string.contains(" ")) {
  18393.                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_SPAZI_BIANCHI_NON_AMMESSI, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS_NOMI_HEADERS));  
  18394.                         return false;
  18395.                     }
  18396.                 }
  18397.             } else {
  18398.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_CORS_CAMPO_OBBLIGATORIO, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS_NOMI_HEADERS));  
  18399.                 return false;
  18400.             }
  18401.         }
  18402.        
  18403.         return true;
  18404.     }
  18405.    
  18406.     public boolean checkRegolaResponseCaching() throws DriverControlStationException {
  18407.        
  18408.         String returnCode = getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE);
  18409.         String statusMinS = getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MIN);
  18410.         String statusMaxS = getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MAX);
  18411.         @SuppressWarnings("unused")
  18412.         String faultS = getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_FAULT);
  18413.         String cacheSecondsS = getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_CACHE_TIMEOUT_SECONDS);
  18414.        
  18415.         if(_checkReturnCode(returnCode, statusMinS, statusMaxS,
  18416.                 CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE,
  18417.                 CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MIN,
  18418.                 CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MAX)==false) {
  18419.             return false;
  18420.         }
  18421.        
  18422.         Integer cacheSeconds = null;
  18423.         if(StringUtils.isNotEmpty(cacheSecondsS)) {
  18424.             try {
  18425.                 cacheSeconds = Integer.parseInt(cacheSecondsS);
  18426.                
  18427.                 if(cacheSeconds < 1) {
  18428.                     this.pd.setMessage("Il valore inserito nel campo "+ CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_CACHE_TIMEOUT_SECONDS + " non &egrave; valido, sono ammessi valori compresi tra 1 e 999.");
  18429.                     return false;
  18430.                 }
  18431.             }catch(Exception e) {
  18432.                 this.pd.setMessage("Il formato del campo "+ CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_CACHE_TIMEOUT_SECONDS + " non &egrave; valido.");
  18433.                 return false;
  18434.             }
  18435.         }
  18436.        
  18437.         return true;
  18438.     }
  18439.    
  18440.     public boolean _checkReturnCode(String returnCode, String statusMinS, String statusMaxS,
  18441.             String labelReturnCode, String labelReturnCodeMin, String labelReturnCodeMax) throws DriverControlStationException {
  18442.        
  18443.         Integer statusMin = null;
  18444.         Integer statusMax = null;
  18445.        
  18446.         if(!returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_QUALSIASI)) {
  18447.            
  18448.             if(returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_ESATTO)) {
  18449.                 if(StringUtils.isEmpty(statusMinS)) {
  18450.                     this.pd.setMessage("Il campo "+ labelReturnCode + " &egrave; obbligatorio.");
  18451.                     return false;
  18452.                 }
  18453.             }
  18454.            
  18455.             if(returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_INTERVALLO)) {
  18456.                 if(StringUtils.isEmpty(statusMinS) || StringUtils.isEmpty(statusMaxS)) {
  18457.                     this.pd.setMessage("Tutt gli intervalli del campo "+ labelReturnCode + " sono obbligatori.");
  18458.                     return false;
  18459.                 }
  18460.             }
  18461.            
  18462.             if(StringUtils.isNotEmpty(statusMinS)) {
  18463.                 try {
  18464.                     statusMin = Integer.parseInt(statusMinS);
  18465.                    
  18466.                     if(statusMin < 200 || statusMin > 599) {
  18467.                         if(returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_ESATTO)) {
  18468.                             this.pd.setMessage("Il valore inserito nel campo "+ labelReturnCode + " non &egrave; valido, sono ammessi valori compresi tra 200 e 599.");
  18469.                         }
  18470.                         else {
  18471.                             this.pd.setMessage("Il valore inserito nell'intervallo sinistro non &egrave; valido, sono ammessi valori compresi tra 200 e 599.");
  18472.                         }
  18473.                         return false;
  18474.                     }
  18475.                     // return code esatto, ho salvato lo stesso valore nel campo return code;
  18476.                     if(returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_ESATTO))
  18477.                         statusMax = statusMin;
  18478.                 }catch(Exception e) {
  18479.                     this.pd.setMessage("Il formato del campo "+ labelReturnCodeMin + " non &egrave; valido.");
  18480.                     return false;
  18481.                 }
  18482.             }
  18483.            
  18484.             if(returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_INTERVALLO)) {
  18485.                 if(StringUtils.isNotEmpty(statusMaxS)) {
  18486.                     try {
  18487.                         statusMax = Integer.parseInt(statusMaxS);
  18488.                        
  18489.                         if(statusMax < 200 || statusMax > 599) {
  18490.                             this.pd.setMessage("Il valore inserito nell'intervallo destro non &egrave; valido, sono ammessi valori compresi tra 200 e 599.");
  18491.                             return false;
  18492.                         }
  18493.                     }catch(Exception e) {
  18494.                         this.pd.setMessage("Il formato del campo "+ labelReturnCodeMax + " non &egrave; valido.");
  18495.                         return false;
  18496.                     }
  18497.                 }
  18498.             }
  18499.            
  18500.             if(returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_INTERVALLO)) {
  18501.                 if(statusMax!=null && statusMin!=null) {
  18502.                     if(statusMin>=statusMax) {
  18503.                         this.pd.setMessage("Il valore inserito nell'intervallo sinistro deve essere minore del valore inserito nell'intervallo destro.");
  18504.                         return false;
  18505.                     }
  18506.                 }
  18507.             }
  18508.         }
  18509.        
  18510.         return true;
  18511.     }
  18512.    
  18513.     public List<DataElement> addResponseCachingConfigurazioneRegola(TipoOperazione tipoOP, String returnCode, String statusMin, String statusMax, String fault, String cacheSeconds, List<DataElement> dati) {
  18514.        
  18515.         DataElement dataElement = new DataElement();
  18516.         dataElement.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA);
  18517.         dataElement.setType(DataElementType.TITLE);
  18518.         dati.add(dataElement);
  18519.        
  18520.         DataElement de = new DataElement();
  18521.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE);
  18522.         de.setLabels(CostantiControlStation.SELECT_LABELS_CONFIGURAZIONE_RETURN_CODE);
  18523.         de.setValues(CostantiControlStation.SELECT_VALUES_CONFIGURAZIONE_RETURN_CODE);
  18524.         de.setType(DataElementType.SELECT);
  18525.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE);
  18526.         de.setPostBack(true);
  18527.         de.setSelected(returnCode);
  18528.         dati.add(de);
  18529.        
  18530.         if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_QUALSIASI.equals(returnCode)) {
  18531.             if(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_ESATTO.equals(returnCode)) {
  18532.                 de = this.getHttpReturnCodeDataElement(CostantiControlStation.LABEL_EMPTY,
  18533.                         CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MIN,
  18534.                         statusMin, true);
  18535.                 dati.add(de);
  18536.             }
  18537.            
  18538.             if(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_INTERVALLO.equals(returnCode)) {
  18539.                 de = getHttpReturnCodeIntervallDataElement(CostantiControlStation.LABEL_EMPTY,
  18540.                         CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MIN,
  18541.                         CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MAX,
  18542.                         statusMin,
  18543.                         statusMax,
  18544.                         true);
  18545.                 dati.add(de);
  18546.             }
  18547.         }
  18548.        
  18549.         de = new DataElement();
  18550.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_CACHE_TIMEOUT_SECONDS);
  18551.         de.setValue(cacheSeconds+ "");
  18552.         de.setType(DataElementType.NUMBER);
  18553.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_CACHE_TIMEOUT_SECONDS);
  18554.         de.setSize( getSize());
  18555.         de.setMinValue(1);
  18556.         de.reloadMinValue(false);
  18557.         dati.add(de);
  18558.        
  18559.         de = new DataElement();
  18560.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_FAULT);
  18561.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_FAULT);
  18562.         de.setType(DataElementType.CHECKBOX);
  18563.         de.setSelected(fault);
  18564.         de.setValue(fault+"");
  18565.         dati.add(de);

  18566.         return dati;
  18567.     }
  18568.    
  18569.     public List<DataElement> addTrasformazioneRispostaToDatiOpAdd(String protocollo, List<DataElement> dati, String idTrasformazione,
  18570.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding,
  18571.             String nome, String returnCode, String statusMin, String statusMax, String pattern, String contentType) throws DriverControlStationException {
  18572.         return addTrasformazioneRispostaToDati(TipoOperazione.ADD, protocollo, dati, 0, null, false, idTrasformazione, null,
  18573.                 serviceBinding,
  18574.                 nome, returnCode, statusMin, statusMax, pattern, contentType,
  18575.                 null, null, 0,
  18576.                 false,false,false,
  18577.                 false,null,
  18578.                 null,null,null,null,
  18579.                 null,
  18580.                 false,null,
  18581.                 null,null,null);
  18582.     }
  18583.    
  18584.     public List<DataElement> addTrasformazioneRispostaToDati(TipoOperazione tipoOP, String protocollo, List<DataElement> dati, long idPorta, TrasformazioneRegolaRisposta risposta, boolean isPortaDelegata, String idTrasformazione, String idTrasformazioneRisposta,
  18585.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBindingParam,
  18586.             String nome, String returnCode, String statusMin, String statusMax, String pattern, String contentType,
  18587.             String servletTrasformazioniRispostaHeadersList, List<Parameter> parametriInvocazioneServletTrasformazioniRispostaHeaders, int numeroTrasformazioniRispostaHeaders,
  18588.             boolean trasformazioneContenutoRichiestaAbilitato, boolean trasformazioneRichiestaRestAbilitato, boolean trasformazioneRichiestaSoapAbilitato,
  18589.             boolean trasformazioneContenutoRispostaAbilitato, org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneContenutoRispostaTipo,
  18590.             BinaryParameter trasformazioneContenutoRispostaTemplate, String trasformazioneContenutoRispostaTipoCheck, String trasformazioneContenutoRispostaContentType, String trasformazioneContenutoRispostaReturnCode,
  18591.             ServiceBinding serviceBindingMessage,
  18592.             boolean trasformazioneRispostaSoapAbilitatoParam, String trasformazioneRispostaSoapEnvelope,  
  18593.             org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneRispostaSoapEnvelopeTipo, BinaryParameter trasformazioneRispostaSoapEnvelopeTemplate, String trasformazioneRispostaSoapEnvelopeTipoCheck
  18594.            
  18595.             ) throws DriverControlStationException {
  18596.        
  18597.        
  18598.         org.openspcoop2.core.registry.constants.ServiceBinding infoServiceBinding = serviceBindingParam;
  18599.         if(trasformazioneRichiestaRestAbilitato) {
  18600.             infoServiceBinding = org.openspcoop2.core.registry.constants.ServiceBinding.REST;
  18601.         }
  18602.         else if(trasformazioneRichiestaSoapAbilitato){
  18603.             infoServiceBinding = org.openspcoop2.core.registry.constants.ServiceBinding.SOAP;
  18604.         }
  18605.        
  18606.         DataElementInfo dInfoPatternTrasporto = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_VALORE);
  18607.         dInfoPatternTrasporto.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TRASPORTO);
  18608.         if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(infoServiceBinding)) {
  18609.             dInfoPatternTrasporto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_REST_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  18610.         }
  18611.         else {
  18612.             dInfoPatternTrasporto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_SOAP_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  18613.         }
  18614.        
  18615.         DataElement de = new DataElement();
  18616.         de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_TRASFORMAZIONE);
  18617.         de.setType(DataElementType.TITLE);
  18618.         dati.add(de);
  18619.        
  18620.         // Nome
  18621.         de = new DataElement();
  18622.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_NOME);
  18623.         de.setValue(nome);
  18624.         de.setType(DataElementType.TEXT_EDIT);
  18625.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_NOME);
  18626.         de.setRequired(true);
  18627.         dati.add(de);
  18628.        
  18629.         de = new DataElement();
  18630.         de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA);
  18631.         de.setType(DataElementType.SUBTITLE);
  18632.         dati.add(de);
  18633.        
  18634.         // Id trasformazione hidden
  18635.         de = new DataElement();
  18636.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  18637.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  18638.         de.setType(DataElementType.HIDDEN);
  18639.         de.setValue(idTrasformazione);
  18640.         dati.add(de);
  18641.        
  18642.         // First
  18643.         de = new DataElement();
  18644.         de.setValue("first");
  18645.         de.setType(DataElementType.HIDDEN);
  18646.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_FIRST);
  18647.         dati.add(de);
  18648.        
  18649.         de = new DataElement();
  18650.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  18651.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE_RISPOSTA);
  18652.         de.setType(DataElementType.HIDDEN);
  18653.         de.setValue(idTrasformazioneRisposta);
  18654.         dati.add(de);
  18655.        
  18656.         de = new DataElement();
  18657.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS);
  18658.         de.setLabels(CostantiControlStation.SELECT_LABELS_CONFIGURAZIONE_RETURN_CODE);
  18659.         de.setValues(CostantiControlStation.SELECT_VALUES_CONFIGURAZIONE_RETURN_CODE);
  18660.         de.setType(DataElementType.SELECT);
  18661.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS);
  18662.         de.setPostBack(true);
  18663.         de.setSelected(returnCode);
  18664.         dati.add(de);
  18665.        
  18666.         if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_QUALSIASI.equals(returnCode)) {
  18667.             if(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_ESATTO.equals(returnCode)) {
  18668.                 de = this.getHttpReturnCodeDataElement(CostantiControlStation.LABEL_EMPTY,
  18669.                         CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS_MIN,
  18670.                         statusMin, true);
  18671.                 dati.add(de);
  18672.             }
  18673.            
  18674.             if(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_INTERVALLO.equals(returnCode)) {
  18675.                 de = getHttpReturnCodeIntervallDataElement(CostantiControlStation.LABEL_EMPTY,
  18676.                         CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS_MIN,
  18677.                         CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS_MAX,
  18678.                         statusMin,
  18679.                         statusMax,
  18680.                         true);
  18681.                 dati.add(de);
  18682.             }
  18683.         }
  18684.                
  18685.         // Content-type
  18686.         de = new DataElement();
  18687.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_CT);
  18688.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_CT);
  18689.         de.setType(DataElementType.TEXT_EDIT);
  18690.         de.setValue(contentType);
  18691.         de.enableTags();
  18692. //      de.setRequired(true);
  18693.         DataElementInfo dInfoCT = new DataElementInfo(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA+" - "+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_CT);
  18694.         dInfoCT.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_INFO_CONTENT_TYPE);
  18695.         dInfoCT.setListBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_INFO_CONTENT_TYPE_VALORI);
  18696.         de.setInfo(dInfoCT);
  18697.         dati.add(de);
  18698.        
  18699.         // Pattern
  18700.         de = new DataElement();
  18701.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_PATTERN);
  18702.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_PATTERN);
  18703.         de.setType(DataElementType.TEXT_AREA);
  18704.         de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  18705.         de.setSize(this.getSize());
  18706.         de.setValue(pattern);
  18707. //      de.setRequired(true);
  18708.         DataElementInfo dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA+" - "+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_PATTERN);
  18709.         if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(infoServiceBinding)) {
  18710.             dInfoPattern.setHeaderBody(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_INFO_PATTERN_REST_RISPOSTA);
  18711.             dInfoPattern.setListBody(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_INFO_PATTERN_VALORI_REST);
  18712.         }
  18713.         else {
  18714.             dInfoPattern.setBody(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_INFO_PATTERN_SOAP_RISPOSTA);
  18715.         }
  18716.         de.setInfo(dInfoPattern);
  18717.         dati.add(de);
  18718.        
  18719.        
  18720.         // in edit faccio vedere i link per configurare la richiesta e le risposte
  18721.                
  18722.         if(tipoOP.equals(TipoOperazione.CHANGE)) {
  18723.            
  18724.             String postbackElement = this.getPostBackElementName();
  18725.            
  18726.             boolean old_trasformazioneRispostaContenutoTemplate = false;
  18727.             boolean old_trasformazioneRispostaSoapEnvelopeTemplate = false;
  18728.            
  18729.             de = new DataElement();
  18730.             de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_REGOLE_TRASFORMAZIONE);
  18731.             de.setType(DataElementType.TITLE);
  18732.             dati.add(de);
  18733.            
  18734.             // sezione trasporto
  18735.             de = new DataElement();
  18736.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_TRASPORTO);
  18737.             de.setType(DataElementType.SUBTITLE);
  18738.             dati.add(de);
  18739.            
  18740.             // Return Code e Header Risposta
  18741.            
  18742.             /*
  18743.             de = this.getHttpReturnCodeDataElement(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_RETURN_CODE,
  18744.                     CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_RETURN_CODE,
  18745.                     trasformazioneContenutoRispostaReturnCode, false);
  18746.                     */
  18747.             de = new DataElement();
  18748.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_RETURN_CODE);
  18749.             de.setValue(trasformazioneContenutoRispostaReturnCode);
  18750.             de.setType(DataElementType.TEXT_EDIT);
  18751.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_RETURN_CODE);
  18752.             de.setSize(getSize());
  18753.             de.setInfo(dInfoPatternTrasporto);
  18754.             de.setRequired(false);
  18755.             dati.add(de);
  18756.            
  18757.             de = new DataElement();
  18758.             de.setType(DataElementType.LINK);
  18759.             boolean contaListeFromSession = ServletUtils.getContaListeFromSession(this.session) != null ? ServletUtils.getContaListeFromSession(this.session) : false;
  18760.             if (contaListeFromSession)
  18761.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADERS+" (" + numeroTrasformazioniRispostaHeaders + ")");
  18762.             else
  18763.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADERS);
  18764.             de.setUrl(servletTrasformazioniRispostaHeadersList, parametriInvocazioneServletTrasformazioniRispostaHeaders.toArray(new Parameter[parametriInvocazioneServletTrasformazioniRispostaHeaders.size()]));
  18765.             dati.add(de);
  18766.            
  18767.             // sezione contenuto
  18768.             de = new DataElement();
  18769.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONTENUTO);
  18770.             de.setType(DataElementType.SUBTITLE);
  18771.             dati.add(de);
  18772.            
  18773.             // abilitato
  18774.             de = new DataElement();
  18775.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_ENABLED);
  18776.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_ENABLED);
  18777.             //if(!trasformazioneContenutoRichiestaAbilitato) {
  18778.             de.setType(DataElementType.CHECKBOX);
  18779.             de.setSelected(trasformazioneContenutoRispostaAbilitato);
  18780.             de.setPostBack(true);
  18781.             //} else {
  18782.             //de.setType(DataElementType.HIDDEN);
  18783.             //}
  18784.             de.setValue(trasformazioneContenutoRispostaAbilitato+"");
  18785.             dati.add(de);
  18786.            
  18787.             if(trasformazioneContenutoRispostaAbilitato) {
  18788.                 // tipo
  18789.                 de = new DataElement();
  18790.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TIPO);
  18791.                 de.setLabels(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toLabelList(serviceBindingMessage, false));
  18792.                 de.setValues(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toStringList(serviceBindingMessage, false));
  18793.                 de.setType(DataElementType.SELECT);
  18794.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TIPO);
  18795.                 de.setPostBack(true);
  18796.                 de.setSelected(trasformazioneContenutoRispostaTipo.getValue());
  18797.                 setTemplateInfo(de, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TIPO, trasformazioneContenutoRispostaTipo, infoServiceBinding, true,
  18798.                         protocollo, isPortaDelegata);
  18799.                 dati.add(de);
  18800.                
  18801.                 if(trasformazioneContenutoRispostaTipo.isTemplateRequired()) {  
  18802.                    
  18803.                     // richiesta null in add
  18804.                     boolean templateRequired = true;
  18805.                    
  18806.                     if(risposta!=null){
  18807.                         old_trasformazioneRispostaContenutoTemplate = risposta.getConversioneTemplate() != null && risposta.getConversioneTemplate().length > 0;
  18808.                         TipoTrasformazione oldTrasformazioneRispostaContenutoTipo = StringUtils.isNotEmpty(risposta.getConversioneTipo())
  18809.                                 ? org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(risposta.getConversioneTipo()) : org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  18810.                         if(trasformazioneContenutoRispostaTipo.equals(oldTrasformazioneRispostaContenutoTipo)) {
  18811.                             templateRequired = false;
  18812.                         }
  18813.                     }
  18814.                                
  18815.                     if(postbackElement != null) {
  18816.                         if(postbackElement.equals(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TIPO)) {
  18817.                             old_trasformazioneRispostaContenutoTemplate = false;
  18818.                             templateRequired = true;
  18819.                         }
  18820. //                      if(postbackElement.equals(trasformazioneContenutoTemplate.getName())) {
  18821. //                          if(StringUtils.isEmpty(trasformazioneContenutoTipoCheck))
  18822. //                              trasformazioneContenutoTipoCheck = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_FILE;
  18823. //                      }
  18824.                     }
  18825.                    
  18826.                     de = new DataElement();
  18827.                     de.setLabel("");
  18828.                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TIPO_CHECK);
  18829.                     de.setType(DataElementType.HIDDEN);
  18830.                     de.setValue(trasformazioneContenutoRispostaTipoCheck);
  18831.                     dati.add(de);
  18832.                    
  18833.                     if(StringUtils.isNotEmpty(trasformazioneContenutoRispostaTipoCheck) && trasformazioneContenutoRispostaTipoCheck.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_TIPO))
  18834.                         templateRequired = true;
  18835.                    
  18836.                     String trasformazioneRispostaContenutoLabel = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TEMPLATE;
  18837.                     if(old_trasformazioneRispostaContenutoTemplate && StringUtils.isEmpty(trasformazioneContenutoRispostaTipoCheck)) {
  18838.                         trasformazioneRispostaContenutoLabel = "";
  18839.                         DataElement saveAs = new DataElement();
  18840.                         saveAs.setValue(CostantiControlStation.LABEL_DOWNLOAD_DOCUMENTO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TEMPLATE);
  18841.                         saveAs.setType(DataElementType.LINK);
  18842.                    
  18843.                         Parameter pIdTrasformazioneRegola = new Parameter(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE, idTrasformazione);
  18844.                         Parameter pIdTrasformazioneRegolaRisposta = new Parameter(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE_RISPOSTA, idTrasformazioneRisposta);
  18845.                         Parameter pIdAccordo = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_ID_ACCORDO, idPorta+"");
  18846.                         Parameter pTipoAllegato = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, isPortaDelegata ? "pd" : "pa");
  18847.                         Parameter pTipoDoc = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, isPortaDelegata ?
  18848.                                 ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_PORTA_DELEGATA_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TEMPLATE :
  18849.                                     ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_PORTA_APPLICATIVA_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TEMPLATE);
  18850.                         saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT, pIdAccordo, pTipoAllegato, pTipoDoc, pIdTrasformazioneRegola,pIdTrasformazioneRegolaRisposta);
  18851.                         saveAs.setDisabilitaAjaxStatus();
  18852.                         dati.add(saveAs);
  18853.                     }
  18854.                    
  18855.                     // template
  18856.                     DataElement trasformazioneContenutoTemplateDataElement = trasformazioneContenutoRispostaTemplate.getFileDataElement(trasformazioneRispostaContenutoLabel, "", getSize());
  18857.                     trasformazioneContenutoTemplateDataElement.setRequired(templateRequired);
  18858.                     dati.add(trasformazioneContenutoTemplateDataElement);
  18859.                     dati.addAll(trasformazioneContenutoRispostaTemplate.getFileNameDataElement());
  18860.                     dati.add(trasformazioneContenutoRispostaTemplate.getFileIdDataElement());
  18861.                 }
  18862.                
  18863.                 boolean contentTypePerAttachmentSOAP = false;
  18864.                 if(trasformazioneContenutoRispostaTipo.isTrasformazioneProtocolloEnabled() && trasformazioneRichiestaRestAbilitato &&
  18865.                         !TipoTrasformazione.EMPTY.equals(trasformazioneContenutoRispostaTipo) &&
  18866.                         CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_ATTACHMENT.equals(trasformazioneRispostaSoapEnvelope)) {
  18867.                     contentTypePerAttachmentSOAP = true;
  18868.                 }
  18869.                
  18870.                 if(!contentTypePerAttachmentSOAP && trasformazioneContenutoRispostaTipo.isContentTypeEnabled()) {
  18871.                     // Content-type
  18872.                     de = new DataElement();
  18873.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONTENT_TYPE);
  18874.                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONTENT_TYPE);
  18875.                     de.setType(DataElementType.TEXT_EDIT);
  18876.                     de.setValue(StringEscapeUtils.escapeHtml(trasformazioneContenutoRispostaContentType));
  18877.                     if(trasformazioneRichiestaRestAbilitato) { // devo restituire un soap e il ct e' deciso dall'engine
  18878.                         de.setType(DataElementType.HIDDEN);
  18879.                         de.setValue("");
  18880.                     }  
  18881.                     else {
  18882.                         de.setInfo(dInfoPatternTrasporto);
  18883.                     }
  18884.                     dati.add(de);
  18885.                 }
  18886.                                
  18887.                 if(trasformazioneContenutoRispostaTipo.isTrasformazioneProtocolloEnabled() && trasformazioneRichiestaRestAbilitato &&
  18888.                         !TipoTrasformazione.EMPTY.equals(trasformazioneContenutoRispostaTipo)) {
  18889.                    
  18890.                     boolean trasformazioneRispostaSoapAbilitato = trasformazioneRispostaSoapAbilitatoParam;
  18891.                     trasformazioneRispostaSoapAbilitato = true; // forzo
  18892.                    
  18893.                     // sezione trasformazione SOAP
  18894.                     de = new DataElement();
  18895.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP);
  18896.                     de.setType(DataElementType.SUBTITLE);
  18897.                     dati.add(de);
  18898.                    
  18899.                     // abilitato
  18900.                     de = new DataElement();
  18901.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_TRANSFORMATION);
  18902.                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_TRANSFORMATION);
  18903.                     de.setType(DataElementType.HIDDEN);
  18904.                     de.setValue(trasformazioneRispostaSoapAbilitato+"");
  18905.                     dati.add(de);
  18906.                    
  18907.                     //if(trasformazioneRispostaSoapAbilitato) {
  18908.                     // Envelope
  18909.                     de = new DataElement();
  18910.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE);
  18911.                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE);
  18912.                     de.setLabels(CostantiControlStation.SELECT_LABELS_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE);
  18913.                     de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE);
  18914.                     de.setType(DataElementType.SELECT);
  18915.                     de.setSelected(trasformazioneRispostaSoapEnvelope);
  18916.                     de.setPostBack(true);
  18917.                     dati.add(de);
  18918.                                            
  18919.                     if(trasformazioneRispostaSoapEnvelope!=null && CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_ATTACHMENT.equals(trasformazioneRispostaSoapEnvelope)) {
  18920.                        
  18921.                         // Content-type
  18922.                         de = new DataElement();
  18923.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONTENT_TYPE_ATTACHMENT);
  18924.                         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONTENT_TYPE);
  18925.                         de.setType(DataElementType.TEXT_EDIT);
  18926.                         de.setValue(trasformazioneContenutoRispostaContentType);
  18927.                         de.setInfo(dInfoPatternTrasporto);
  18928.                         de.setRequired(true);
  18929.                         dati.add(de);
  18930.                        
  18931.                         de = new DataElement();
  18932.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TITLE_BODY);
  18933.                         de.setType(DataElementType.SUBTITLE);
  18934.                         dati.add(de);  
  18935.                        
  18936.                         // tipo envelope attachement
  18937.                         de = new DataElement();
  18938.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TIPO);
  18939.                         de.setLabels(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toLabelList(ServiceBinding.SOAP, true));
  18940.                         de.setValues(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toStringList(ServiceBinding.SOAP, true));
  18941.                         de.setType(DataElementType.SELECT);
  18942.                         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TIPO);
  18943.                         if(trasformazioneRispostaSoapEnvelopeTipo!=null) {
  18944.                             de.setSelected(trasformazioneRispostaSoapEnvelopeTipo.getValue());
  18945.                         }
  18946.                         de.setPostBack(true);
  18947.                         setTemplateInfo(de, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TIPO, trasformazioneRispostaSoapEnvelopeTipo, infoServiceBinding, true,
  18948.                                 protocollo, isPortaDelegata);
  18949.                         dati.add(de);
  18950.                        
  18951.                         if(trasformazioneRispostaSoapEnvelopeTipo!=null && trasformazioneRispostaSoapEnvelopeTipo.isTemplateRequired()) {
  18952.                            
  18953.                             // richiesta null in add
  18954.                             boolean templateRequired = true;
  18955.                             if(risposta!=null){
  18956.                                 TrasformazioneSoapRisposta oldTrasformazioneSoapRisposta = risposta.getTrasformazioneSoap();
  18957.                                 old_trasformazioneRispostaSoapEnvelopeTemplate = oldTrasformazioneSoapRisposta != null && oldTrasformazioneSoapRisposta.getEnvelopeBodyConversioneTemplate() != null && oldTrasformazioneSoapRisposta.getEnvelopeBodyConversioneTemplate().length > 0;
  18958.                                 String oldTrasformazioneSoapEnvelopeTipoS = oldTrasformazioneSoapRisposta != null ? oldTrasformazioneSoapRisposta.getEnvelopeBodyConversioneTipo() : null;
  18959.                                 TipoTrasformazione oldTrasformazioneSoapEnvelopeTipo = StringUtils.isNotEmpty(oldTrasformazioneSoapEnvelopeTipoS)
  18960.                                         ? org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(oldTrasformazioneSoapEnvelopeTipoS) : org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  18961.                                 if(trasformazioneRispostaSoapEnvelopeTipo.equals(oldTrasformazioneSoapEnvelopeTipo)) {
  18962.                                     templateRequired = false;
  18963.                                 }  
  18964.                             }
  18965.                            
  18966.                             if(postbackElement != null) {
  18967.                                 if(postbackElement.equals(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TIPO)) {
  18968.                                     old_trasformazioneRispostaSoapEnvelopeTemplate = false;
  18969.                                     templateRequired = true;
  18970.                                 }
  18971.                                
  18972. //                              if(postbackElement.equals(trasformazioneSoapEnvelopeTemplate.getName())) {
  18973. //                                  trasformazioneSoapEnvelopeTipoCheck = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_FILE;
  18974. //                              }
  18975.                             }
  18976.                            
  18977.                             de = new DataElement();
  18978.                             de.setLabel("");
  18979.                             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TIPO_CHECK);
  18980.                             de.setType(DataElementType.HIDDEN);
  18981.                             de.setValue(trasformazioneRispostaSoapEnvelopeTipoCheck);
  18982.                             dati.add(de);
  18983.                            
  18984.                             if(StringUtils.isNotEmpty(trasformazioneRispostaSoapEnvelopeTipoCheck) && trasformazioneRispostaSoapEnvelopeTipoCheck.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_TIPO))
  18985.                                 templateRequired = true;
  18986.                            
  18987.                             String trasformazioneSoapEnvelopeTemplateLabel = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TEMPLATE;
  18988.                             if(old_trasformazioneRispostaSoapEnvelopeTemplate && StringUtils.isEmpty(trasformazioneRispostaSoapEnvelopeTipoCheck)) {
  18989.                                 trasformazioneSoapEnvelopeTemplateLabel = "";
  18990.                                 DataElement saveAs = new DataElement();
  18991.                                 saveAs.setValue(CostantiControlStation.LABEL_DOWNLOAD_DOCUMENTO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TEMPLATE);
  18992.                                 saveAs.setType(DataElementType.LINK);

  18993.                                 Parameter pIdTrasformazioneRegola = new Parameter(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE, idTrasformazione);
  18994.                                 Parameter pIdTrasformazioneRegolaRisposta = new Parameter(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE_RISPOSTA, idTrasformazioneRisposta);
  18995.                                 Parameter pIdAccordo = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_ID_ACCORDO, idPorta+"");
  18996.                                 Parameter pTipoAllegato = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, isPortaDelegata ? "pd" : "pa");
  18997.                                 Parameter pTipoDoc = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, isPortaDelegata
  18998.                                         ? ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_PORTA_DELEGATA_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TEMPLATE
  18999.                                                 : ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_PORTA_APPLICATIVA_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TEMPLATE);
  19000.                                 saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT, pIdAccordo, pTipoAllegato, pTipoDoc,pIdTrasformazioneRegola,pIdTrasformazioneRegolaRisposta);
  19001.                                 dati.add(saveAs);
  19002.                             }
  19003.                            
  19004.                            
  19005.                             //  template envelope attachement
  19006.                             DataElement trasformazioneSoapEnvelopeTemplateDataElement = trasformazioneRispostaSoapEnvelopeTemplate.getFileDataElement(trasformazioneSoapEnvelopeTemplateLabel, "", getSize());
  19007.                             trasformazioneSoapEnvelopeTemplateDataElement.setRequired(templateRequired);
  19008.                             dati.add(trasformazioneSoapEnvelopeTemplateDataElement);
  19009.                             dati.addAll(trasformazioneRispostaSoapEnvelopeTemplate.getFileNameDataElement());
  19010.                             dati.add(trasformazioneRispostaSoapEnvelopeTemplate.getFileIdDataElement());
  19011.                         }
  19012.                     }
  19013.                    
  19014.                 }
  19015.             }
  19016.         }
  19017.        
  19018.        
  19019.         return dati;
  19020.     }
  19021.    
  19022.     public boolean trasformazioniCheckData(TipoOperazione tipoOp, long idPorta, String nome, TrasformazioneRegola regolaDBCheck_criteri, TrasformazioneRegola trasformazioneDBCheck_nome,  TrasformazioneRegola oldRegola,
  19023.             ServiceBinding serviceBinding) throws DriverControlStationException {
  19024.         try{
  19025. //          String [] azioni = this.getParameterValues(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_AZIONI);
  19026. //          String pattern = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_PATTERN);
  19027. //          String contentType = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_CT);
  19028.            
  19029.             if(nome==null || "".equals(nome)) {
  19030.                 this.pd.setMessage("Indicare un valore nel campo '"+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_NOME+"'");
  19031.                 return false;
  19032.             }
  19033.             if(!this.checkLength255(nome, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_NOME)) {
  19034.                 return false;
  19035.             }
  19036.            
  19037.             // Se tipoOp = add, controllo che la trasformazione non sia gia' stato registrata
  19038.             if (tipoOp.equals(TipoOperazione.ADD)) {
  19039.                 if (regolaDBCheck_criteri != null) {
  19040.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_REGOLA_TRASFORMAZIONE_APPLICABILITA_DUPLICATA);
  19041.                     return false;
  19042.                 }
  19043.                 else if (trasformazioneDBCheck_nome != null) {
  19044.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_REGOLA_TRASFORMAZIONE_APPLICABILITA_NOME);
  19045.                     return false;
  19046.                 }
  19047.             } else {
  19048.                 // controllo che le modifiche ai parametri non coincidano con altre regole gia' presenti
  19049. //              TrasformazioneRegola trasformazione = this.porteApplicativeCore.getTrasformazione(idPorta, azioniDBCheck, patternDBCheck, contentTypeDBCheck);
  19050.                 if(regolaDBCheck_criteri != null && regolaDBCheck_criteri.getId().longValue() != oldRegola.getId().longValue()) {
  19051.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_REGOLA_TRASFORMAZIONE_APPLICABILITA_DUPLICATA);
  19052.                     return false;
  19053.                 }
  19054.                 else if (trasformazioneDBCheck_nome != null && trasformazioneDBCheck_nome.getId().longValue() != oldRegola.getId().longValue()) {
  19055.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_REGOLA_TRASFORMAZIONE_APPLICABILITA_NOME);
  19056.                     return false;
  19057.                 }
  19058.             }
  19059.            
  19060.            
  19061.             String pattern = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_PATTERN);
  19062.             if(pattern!=null && StringUtils.isNotEmpty(pattern)) {
  19063.                 if(ServiceBinding.SOAP.equals(serviceBinding)) {
  19064.                     if(this.checkXPath(pattern,CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_PATTERN)==false){
  19065.                         return false;
  19066.                     }
  19067.                 }
  19068.                 else {
  19069.                     if(this.checkXPathOrJsonPath(pattern,CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_PATTERN)==false){
  19070.                         return false;
  19071.                     }
  19072.                 }
  19073.             }
  19074.            
  19075.             return true;
  19076.         } catch (Exception e) {
  19077.             this.logError("Exception: " + e.getMessage(), e);
  19078.             throw new DriverControlStationException(e);
  19079.         }
  19080.     }
  19081.    
  19082.     public boolean trasformazioniRichiestaCheckData(TipoOperazione tipoOp, TrasformazioneRegola oldRegola , ServiceBinding serviceBindingMessage) throws DriverControlStationException {
  19083.         try{
  19084.        
  19085.             String trasformazioneContenutoAbilitatoS  = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_ENABLED);
  19086.             boolean trasformazioneContenutoAbilitato = trasformazioneContenutoAbilitatoS != null ? ServletUtils.isCheckBoxEnabled(trasformazioneContenutoAbilitatoS) : false;
  19087.            
  19088.             if(trasformazioneContenutoAbilitato) {
  19089.                 String trasformazioneContenutoTipoS = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO);
  19090.                 org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneContenutoTipo =
  19091.                         trasformazioneContenutoTipoS != null ? org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(trasformazioneContenutoTipoS) :
  19092.                             org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  19093.                
  19094.                 if(trasformazioneContenutoTipo.isTemplateRequired()) {
  19095.                     BinaryParameter trasformazioneContenutoTemplate = this.getBinaryParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TEMPLATE);
  19096.                    
  19097.                     String trasformazioneContenutoTipoCheck = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK);
  19098.                    
  19099.                     if(StringUtils.isNotEmpty(trasformazioneContenutoTipoCheck)) { // ho cambiato il tipo conversione
  19100.                         if((trasformazioneContenutoTemplate.getValue() == null || trasformazioneContenutoTemplate.getValue().length == 0)) {
  19101.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19102.                                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TEMPLATE));
  19103.                             return false;
  19104.                         }
  19105.                     } else { // non ho cambiato il template
  19106.                         if((oldRegola.getRichiesta() == null || oldRegola.getRichiesta().getConversioneTemplate() == null)) {
  19107.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19108.                                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TEMPLATE));
  19109.                             return false;
  19110.                         }
  19111.                     }
  19112.                 }
  19113.                
  19114.                 String trasformazioneRichiestaContentType = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONTENT_TYPE);
  19115.                
  19116.                 switch (serviceBindingMessage) {
  19117.                 case REST:
  19118.                     String trasformazioneSoapAbilitatoS = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_TRANSFORMATION);
  19119.                     boolean trasformazioneSoapAbilitato =  trasformazioneSoapAbilitatoS != null ? ServletUtils.isCheckBoxEnabled(trasformazioneSoapAbilitatoS) : false;
  19120.                    
  19121.                     if(trasformazioneSoapAbilitato) {
  19122.                         String trasformazioneSoapAction = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ACTION);
  19123.                        
  19124.                         if(!this.checkLength255(trasformazioneSoapAction, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ACTION)) {
  19125.                             return false;
  19126.                         }
  19127.                        
  19128.                         if(trasformazioneSoapAction!=null && !"".equals(trasformazioneSoapAction)) {
  19129.                             try{
  19130.                                 DynamicUtils.validate(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ACTION, trasformazioneSoapAction, false);
  19131.                             }catch(Exception e){
  19132.                                 this.pd.setMessage("Il valore indicato nel parametro '"+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ACTION+"' non risulta corretto: "+e.getMessage());
  19133.                                 return false;
  19134.                             }
  19135.                         }
  19136.                        
  19137.                         String trasformazioneSoapEnvelope = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE);
  19138.                        
  19139.                         if(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_ATTACHMENT.equals(trasformazioneSoapEnvelope)) {
  19140.                            
  19141.                             // content-type obbligatorio
  19142.                             if (StringUtils.isEmpty(trasformazioneRichiestaContentType)) {
  19143.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19144.                                         CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONTENT_TYPE_ATTACHMENT));
  19145.                                 return false;
  19146.                             }
  19147.                             if(!this.checkLength255(trasformazioneRichiestaContentType, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONTENT_TYPE_ATTACHMENT)) {
  19148.                                 return false;
  19149.                             }
  19150.                            
  19151.                             String trasformazioneSoapEnvelopeTipoS = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TIPO);
  19152.                             org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneSoapEnvelopeTipo =
  19153.                                     trasformazioneSoapEnvelopeTipoS != null ? org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(trasformazioneSoapEnvelopeTipoS) :
  19154.                                     org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  19155.                                    
  19156.                             if(trasformazioneSoapEnvelopeTipo.isTemplateRequired()) {
  19157.                                 BinaryParameter trasformazioneSoapEnvelopeTemplate = this.getBinaryParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TEMPLATE);
  19158.                                
  19159.                                 String trasformazioneSoapEnvelopeTipoCheck = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TIPO_CHECK);
  19160.                                
  19161.                                 if(StringUtils.isNotEmpty(trasformazioneSoapEnvelopeTipoCheck)) { // ho cambiato il tipo conversione
  19162.                                     if((trasformazioneSoapEnvelopeTemplate.getValue() == null || trasformazioneSoapEnvelopeTemplate.getValue().length == 0)) {
  19163.                                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19164.                                                 CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TEMPLATE));
  19165.                                         return false;
  19166.                                     }
  19167.                                 } else { // non ho cambiato il template
  19168.                                     if((oldRegola.getRichiesta() == null || oldRegola.getRichiesta().getTrasformazioneSoap() == null || oldRegola.getRichiesta().getTrasformazioneSoap().getEnvelopeBodyConversioneTemplate() == null)) {
  19169.                                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19170.                                                 CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TEMPLATE));
  19171.                                         return false;
  19172.                                     }
  19173.                                 }
  19174.                             }
  19175.                            
  19176.                         }
  19177.                     } else {
  19178.                         // dimensione content-type
  19179.                         if(!this.checkLength255(trasformazioneRichiestaContentType, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONTENT_TYPE)) {
  19180.                             return false;
  19181.                         }
  19182.                     }
  19183.                     break;
  19184.                 case SOAP:
  19185.                     String trasformazioneRestAbilitatoS = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_TRANSFORMATION);
  19186.                     boolean trasformazioneRestAbilitato =  trasformazioneRestAbilitatoS != null ? ServletUtils.isCheckBoxEnabled(trasformazioneRestAbilitatoS) : false;
  19187.                     if(trasformazioneRestAbilitato) {
  19188.                         // content-type obbligatorio
  19189.                         if(trasformazioneContenutoTipo.isContentTypeEnabled()) {
  19190.                             if (StringUtils.isEmpty(trasformazioneRichiestaContentType)) {
  19191.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19192.                                         CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONTENT_TYPE));
  19193.                                 return false;
  19194.                             }
  19195.                         }
  19196.                         // dimensione content-type
  19197.                         if(!this.checkLength255(trasformazioneRichiestaContentType, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONTENT_TYPE)) {
  19198.                             return false;
  19199.                         }
  19200.                        
  19201.                        
  19202.                         String trasformazioneRestMethod = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_METHOD);
  19203.                        
  19204.                         if (StringUtils.isEmpty(trasformazioneRestMethod)) {
  19205.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19206.                                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_METHOD));
  19207.                             return false;
  19208.                         }
  19209.                        
  19210.                         String trasformazioneRestPath = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_PATH);
  19211.                        
  19212.                         if (StringUtils.isEmpty(trasformazioneRestPath)) {
  19213.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19214.                                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_PATH));
  19215.                             return false;
  19216.                         }
  19217.                         if (!this.checkLength4000(trasformazioneRestPath, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_PATH)) {
  19218.                             return false;
  19219.                         }
  19220.                     }
  19221.                     break;
  19222.                 }
  19223.             }
  19224.            
  19225.            
  19226.             if(ServiceBinding.REST.equals(serviceBindingMessage)) {
  19227.            
  19228.                 String trasformazioneRestMethod = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_METHOD);
  19229.                 if (!StringUtils.isEmpty(trasformazioneRestMethod)) {
  19230.                     if (!this.checkLength255(trasformazioneRestMethod, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_METHOD)) {
  19231.                         return false;
  19232.                     }
  19233.                 }
  19234.                
  19235.                 String trasformazioneRestPath = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_PATH);
  19236.                 if (!StringUtils.isEmpty(trasformazioneRestPath)) {
  19237.                     if (!this.checkLength4000(trasformazioneRestPath, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_PATH)) {
  19238.                         return false;
  19239.                     }
  19240.                 }
  19241.                
  19242.             }
  19243.            
  19244.            
  19245.             return true;
  19246.         } catch (Exception e) {
  19247.             this.logError("Exception: " + e.getMessage(), e);
  19248.             throw new DriverControlStationException(e);
  19249.         }
  19250.     }
  19251.    
  19252.     public boolean trasformazioniRispostaCheckData(TipoOperazione tipoOp, TrasformazioneRegola regolaRichiesta, TrasformazioneRegolaRisposta oldRegolaRisposta,
  19253.             ServiceBinding serviceBinding) throws DriverControlStationException {
  19254.         try{

  19255.             String nome = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_NOME);
  19256.             if(nome==null || "".equals(nome)) {
  19257.                 this.pd.setMessage("Indicare un valore nel campo '"+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_NOME+"'");
  19258.                 return false;
  19259.             }
  19260.             if(!this.checkLength255(nome, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_NOME)) {
  19261.                 return false;
  19262.             }
  19263.            
  19264.             String returnCode = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS);
  19265.             String statusMinS = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS_MIN);
  19266.             String statusMaxS = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS_MAX);
  19267.        
  19268.             if(_checkReturnCode(returnCode, statusMinS, statusMaxS,
  19269.                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS,
  19270.                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS_MIN,
  19271.                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS_MAX)==false) {
  19272.                 return false;
  19273.             }
  19274.            
  19275.             String pattern = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_PATTERN);
  19276.             if(pattern!=null && StringUtils.isNotEmpty(pattern)) {
  19277.                 if(ServiceBinding.SOAP.equals(serviceBinding)) {
  19278.                     if(this.checkXPath(pattern,CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_PATTERN)==false){
  19279.                         return false;
  19280.                     }
  19281.                 }
  19282.                 else {
  19283.                     if(this.checkXPathOrJsonPath(pattern,CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_PATTERN)==false){
  19284.                         return false;
  19285.                     }
  19286.                 }
  19287.             }
  19288.            
  19289.             // Se tipoOp = add, controllo che la trasformazione risposta non sia gia' stato registrata
  19290.             if (tipoOp.equals(TipoOperazione.CHANGE)) {
  19291.                
  19292.                 boolean trasformazioneRichiestaRestAbilitato = false;
  19293.                 if(regolaRichiesta.getRichiesta() != null) {
  19294.                     trasformazioneRichiestaRestAbilitato = regolaRichiesta.getRichiesta().getTrasformazioneRest() != null;
  19295.                 }
  19296.                
  19297.                 String trasformazioneContenutoRispostaAbilitatoS  = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_ENABLED);
  19298.                 boolean trasformazioneContenutoRispostaAbilitato = trasformazioneContenutoRispostaAbilitatoS != null ? ServletUtils.isCheckBoxEnabled(trasformazioneContenutoRispostaAbilitatoS) : false;
  19299.                
  19300.                 if(trasformazioneContenutoRispostaAbilitato) {
  19301.                     String trasformazioneContenutoRispostaTipoS = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TIPO);
  19302.                     org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneContenutoRispostaTipo =
  19303.                             trasformazioneContenutoRispostaTipoS != null ? org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(trasformazioneContenutoRispostaTipoS) :
  19304.                                 org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  19305.                    
  19306.                     if(trasformazioneContenutoRispostaTipo.isTemplateRequired()) {
  19307.                         BinaryParameter trasformazioneContenutoTemplate = this.getBinaryParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TEMPLATE);
  19308.                        
  19309.                         String trasformazioneContenutoRispostaTipoCheck = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TIPO_CHECK);
  19310.                        
  19311.                         if(StringUtils.isNotEmpty(trasformazioneContenutoRispostaTipoCheck)) { // ho cambiato il tipo conversione
  19312.                             if((trasformazioneContenutoTemplate.getValue() == null || trasformazioneContenutoTemplate.getValue().length == 0)) {
  19313.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19314.                                         CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TEMPLATE));
  19315.                                 return false;
  19316.                             }
  19317.                         } else { // non ho cambiato il template
  19318.                             if(oldRegolaRisposta.getConversioneTemplate() == null) {
  19319.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19320.                                         CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONVERSIONE_TEMPLATE));
  19321.                                 return false;
  19322.                             }
  19323.                         }
  19324.                     }
  19325.                    
  19326.                     String trasformazioneRispostaContentType = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONTENT_TYPE);
  19327.                    
  19328.                     String trasformazioneRispostaReturnCode = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_RETURN_CODE);
  19329.                    
  19330.                     if(trasformazioneRispostaReturnCode!=null && StringUtils.isNotEmpty(trasformazioneRispostaReturnCode) && !trasformazioneRispostaReturnCode.contains("${")) { // altrimenti vi è una risoluzione dinamica
  19331.                         try {
  19332.                             int returnCodeEsatto = Integer.parseInt(trasformazioneRispostaReturnCode);
  19333.                            
  19334.                             if(returnCodeEsatto < 200) {
  19335.                                 this.pd.setMessage("Il valore inserito nel campo "+ CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_RETURN_CODE + " non &egrave; valido, sono ammessi valori compresi tra 200 e 599.");
  19336.                                 return false;
  19337.                             }
  19338.                             if(returnCodeEsatto > 599) {
  19339.                                 this.pd.setMessage("Il valore inserito nel campo "+ CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_RETURN_CODE + " non &egrave; valido, sono ammessi valori compresi tra 200 e 599.");
  19340.                                 return false;
  19341.                             }
  19342.                         }catch(Exception e) {
  19343.                             this.pd.setMessage("Il formato del campo "+ CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_RETURN_CODE + " non &egrave; valido.");
  19344.                             return false;
  19345.                         }
  19346.                     }
  19347.                    
  19348.                     if(trasformazioneContenutoRispostaTipo.isTrasformazioneProtocolloEnabled() && trasformazioneRichiestaRestAbilitato) {
  19349.                    
  19350.                         String trasformazioneSoapAbilitatoS = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_TRANSFORMATION);
  19351.                         boolean trasformazioneSoapAbilitato =  trasformazioneSoapAbilitatoS != null ? ServletUtils.isCheckBoxEnabled(trasformazioneSoapAbilitatoS) : false;
  19352.                        
  19353.                         if(trasformazioneSoapAbilitato) {
  19354.                             String trasformazioneSoapEnvelope = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE);
  19355.                            
  19356.                             if(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_ATTACHMENT.equals(trasformazioneSoapEnvelope)) {
  19357.                                
  19358.                                 // content-type obbligatorio
  19359.                                 if (StringUtils.isEmpty(trasformazioneRispostaContentType)) {
  19360.                                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19361.                                             CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONTENT_TYPE_ATTACHMENT));
  19362.                                     return false;
  19363.                                 }
  19364.                                 if(!this.checkLength255(trasformazioneRispostaContentType, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_CONTENT_TYPE_ATTACHMENT)) {
  19365.                                     return false;
  19366.                                 }
  19367.                                
  19368.                                 String trasformazioneSoapEnvelopeTipoS = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TIPO);
  19369.                                 org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneSoapEnvelopeTipo =
  19370.                                         trasformazioneSoapEnvelopeTipoS != null ? org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(trasformazioneSoapEnvelopeTipoS) :
  19371.                                         org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  19372.                                        
  19373.                                 if(trasformazioneSoapEnvelopeTipo.isTemplateRequired()) {
  19374.                                     BinaryParameter trasformazioneSoapEnvelopeTemplate = this.getBinaryParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TEMPLATE);
  19375.                                    
  19376.                                     String trasformazioneSoapEnvelopeTipoCheck = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TIPO_CHECK);
  19377.                                    
  19378.                                     if(StringUtils.isNotEmpty(trasformazioneSoapEnvelopeTipoCheck)) { // ho cambiato il tipo conversione
  19379.                                         if((trasformazioneSoapEnvelopeTemplate.getValue() == null || trasformazioneSoapEnvelopeTemplate.getValue().length == 0)) {
  19380.                                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19381.                                                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TEMPLATE));
  19382.                                             return false;
  19383.                                         }
  19384.                                     } else { // non ho cambiato il template
  19385.                                         if(oldRegolaRisposta.getTrasformazioneSoap().getEnvelopeBodyConversioneTemplate() == null) {
  19386.                                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX,
  19387.                                                     CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_SOAP_ENVELOPE_TEMPLATE));
  19388.                                             return false;
  19389.                                         }
  19390.                                     }
  19391.                                 }
  19392.                             }
  19393.                         } else {
  19394.                             // dimensione content-type
  19395.                             if(!this.checkLength255(trasformazioneRispostaContentType, PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_RISPOSTA_CONTENT_TYPE)) {
  19396.                                 return false;
  19397.                             }
  19398.                         }
  19399.                      
  19400.                     }
  19401.                 }
  19402.             }
  19403.            
  19404.             return true;
  19405.         } catch (Exception e) {
  19406.             this.logError("Exception: " + e.getMessage(), e);
  19407.             throw new DriverControlStationException(e);
  19408.         }
  19409.     }
  19410.    
  19411.     public List<DataElement> addTrasformazioneToDatiOpAdd(List<DataElement> dati, Object oggetto, String nome,
  19412.             String stato, boolean azioniAll, String[] azioniDisponibiliList, String[] azioniDisponibiliLabelList, String[] azioni, String pattern, String contentType,
  19413.             String [] connettoriDisponibiliList, String [] connettoriDisponibiliLabelList, String [] connettori,
  19414.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding, boolean isPortaDelegata) throws DriverControlStationException {
  19415.         return addTrasformazioneToDati(TipoOperazione.ADD, dati, oggetto, null, nome,
  19416.                 stato, azioniAll, azioniDisponibiliList, azioniDisponibiliLabelList, azioni, pattern, contentType,
  19417.                 connettoriDisponibiliList, connettoriDisponibiliLabelList, connettori,
  19418.                 serviceBinding,
  19419.                 null, null, null, null, 0, isPortaDelegata, null,null,0,null,null,0);
  19420.     }
  19421.    
  19422.     public List<DataElement> addTrasformazioneToDati(TipoOperazione tipoOP, List<DataElement> dati, Object oggetto, String idTrasformazione, String nome,
  19423.             String stato, boolean azioniAll, String[] azioniDisponibiliList, String[] azioniDisponibiliLabelList, String[] azioni, String pattern, String contentType,
  19424.             String [] connettoriDisponibiliList, String [] connettoriDisponibiliLabelList, String [] connettori,
  19425.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding,
  19426.             String servletTrasformazioniRichiesta, List<Parameter> parametriInvocazioneServletTrasformazioniRichiesta, String servletTrasformazioniRispostaList, List<Parameter> parametriInvocazioneServletTrasformazioniRisposta,
  19427.             int numeroTrasformazioniRisposte, boolean isPortaDelegata, String servletTrasformazioniAutorizzazioneAutenticati,  List<Parameter> parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati , int numAutenticati,
  19428.             String servletTrasformazioniApplicativiAutenticati,  List<Parameter> parametriInvocazioneServletTrasformazioniApplicativiAutenticati , int numApplicativiAutenticati) throws DriverControlStationException {
  19429.        
  19430.         // Id hidden
  19431.         DataElement de = new DataElement();
  19432.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19433.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19434.         de.setType(DataElementType.HIDDEN);
  19435.         de.setValue(idTrasformazione);
  19436.         dati.add(de);
  19437.        
  19438.         // First
  19439.         de = new DataElement();
  19440.         de.setValue("first");
  19441.         de.setType(DataElementType.HIDDEN);
  19442.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_FIRST);
  19443.         dati.add(de);
  19444.        
  19445.         de = new DataElement();
  19446.         de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_TRASFORMAZIONE);
  19447.         de.setType(DataElementType.TITLE);
  19448.         dati.add(de);
  19449.        
  19450.         // Nome
  19451.         de = new DataElement();
  19452.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_NOME);
  19453.         de.setValue(nome);
  19454.         de.setType(DataElementType.TEXT_EDIT);
  19455.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_NOME);
  19456.         de.setRequired(true);
  19457.         dati.add(de);
  19458.        
  19459.         // Stato
  19460.         de = new DataElement();
  19461.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_STATO);
  19462.         if(stato==null || "".equals(stato)) {
  19463.             stato = StatoFunzionalita.ABILITATO.getValue();
  19464.         }
  19465.         de.setSelected(stato);
  19466.         de.setType(DataElementType.SELECT);
  19467.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_STATO);
  19468.         de.setValues(ConfigurazioneCostanti.STATI);
  19469.         de.setLabels(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATI);
  19470.         dati.add(de);
  19471.        
  19472.         de = new DataElement();
  19473.         de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA);
  19474.         de.setType(DataElementType.SUBTITLE);
  19475.         dati.add(de);
  19476.                
  19477.         // Azione
  19478.        
  19479.         de = new DataElement();
  19480.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_AZIONI_ALL);
  19481.         de.setPostBack(true);
  19482.         de.setValues(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_AZIONI_ALL_VALUES);
  19483.         if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  19484.             de.setLabels(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_RISORSE_ALL_VALUES);
  19485.         }
  19486.         else {
  19487.             de.setLabels(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_AZIONI_ALL_VALUES);
  19488.         }
  19489.         if(azioniAll) {
  19490.             de.setSelected(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_AZIONI_ALL_VALUE_TRUE);
  19491.         }
  19492.         else {
  19493.             de.setSelected(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_AZIONI_ALL_VALUE_FALSE);
  19494.         }
  19495.         if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  19496.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_RISORSE);
  19497.         }
  19498.         else {
  19499.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_AZIONI);
  19500.         }
  19501.         de.setType(DataElementType.SELECT);
  19502.         dati.add(de);
  19503.        
  19504.         if(!azioniAll) {
  19505.             de = new DataElement();
  19506.             de.setLabel("");
  19507.             de.setValues(azioniDisponibiliList);
  19508.             de.setLabels(azioniDisponibiliLabelList);
  19509.             de.setSelezionati(azioni);
  19510.             de.setType(DataElementType.MULTI_SELECT);
  19511.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_AZIONI);
  19512.             de.setRows(15);
  19513.     //      de.setRequired(true);
  19514.             dati.add(de);
  19515.         }
  19516.        
  19517.         // Content-type
  19518.         de = new DataElement();
  19519.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_CT);
  19520.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_CT);
  19521.         de.setType(DataElementType.TEXT_EDIT);
  19522.         de.setValue(contentType);
  19523.         de.enableTags();
  19524. //      de.setRequired(true);
  19525.         DataElementInfo dInfoCT = new DataElementInfo(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA+" - "+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_CT);
  19526.         dInfoCT.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_INFO_CONTENT_TYPE);
  19527.         dInfoCT.setListBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_INFO_CONTENT_TYPE_VALORI);
  19528.         de.setInfo(dInfoCT);
  19529.         dati.add(de);
  19530.        
  19531.         // Pattern
  19532.         de = new DataElement();
  19533.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_PATTERN);
  19534.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_PATTERN);
  19535.         de.setType(DataElementType.TEXT_AREA);
  19536.         de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  19537.         de.setSize(this.getSize());
  19538.         de.setValue(pattern);
  19539. //      de.setRequired(true);
  19540.         DataElementInfo dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA+" - "+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_PATTERN);
  19541.         if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  19542.             dInfoPattern.setHeaderBody(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_INFO_PATTERN_REST_RICHIESTA);
  19543.             dInfoPattern.setListBody(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_INFO_PATTERN_VALORI_REST);
  19544.         }
  19545.         else {
  19546.             dInfoPattern.setBody(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_INFO_PATTERN_SOAP_RICHIESTA);
  19547.         }
  19548.         de.setInfo(dInfoPattern);
  19549.         dati.add(de);
  19550.        
  19551.         if(connettoriDisponibiliList!=null && connettoriDisponibiliList.length>0) {
  19552.             de = new DataElement();
  19553.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_CONNETTORI);
  19554.             de.setValues(connettoriDisponibiliList);
  19555.             de.setLabels(connettoriDisponibiliLabelList);
  19556.             de.setSelezionati(connettori);
  19557.             de.setType(DataElementType.MULTI_SELECT);
  19558.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_CONNETTORI);
  19559.             de.setRows(10);
  19560.     //      de.setRequired(true);
  19561.             dati.add(de);
  19562.         }
  19563.                        
  19564.         // in edit faccio vedere i link per configurare la richiesta e le risposte
  19565.         if(tipoOP.equals(TipoOperazione.CHANGE)) {
  19566.            
  19567.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  19568.             boolean autenticazione = false;
  19569.             String protocollo = null;
  19570.             boolean isSupportatoAutenticazione;
  19571.             boolean autenticazioneToken = false;
  19572.            
  19573.             TrasformazioneRegola tr = null;
  19574.             if(isPortaDelegata){
  19575.                 PortaDelegata pd = (PortaDelegata) oggetto;
  19576.                 if(pd!=null) {
  19577.                     autenticazione = !TipoAutenticazione.DISABILITATO.equals(pd.getAutenticazione());
  19578.                 }
  19579.                 isSupportatoAutenticazione = true;
  19580.                 if(pd!=null && pd.getServizio()!=null && pd.getServizio().getTipo()!=null) {
  19581.                     try {
  19582.                         protocollo = this.apsCore.getProtocolloAssociatoTipoServizio(pd.getServizio().getTipo());
  19583.                     }catch(Exception e) {
  19584.                         throw new DriverControlStationException(e.getMessage(),e);
  19585.                     }
  19586.                 }
  19587.                 if(pd!=null && pd.getTrasformazioni()!=null && pd.getTrasformazioni().sizeRegolaList()>0) {
  19588.                     for (TrasformazioneRegola trCheck : pd.getTrasformazioni().getRegolaList()){
  19589.                         if(trCheck.getNome().equals(nome)) {
  19590.                             tr = trCheck;
  19591.                             break;
  19592.                         }
  19593.                     }
  19594.                 }
  19595.                 if(pd!=null) {
  19596.                     autenticazioneToken = pd.getGestioneToken()!=null && pd.getGestioneToken().getPolicy()!=null;
  19597.                 }
  19598.             }else {
  19599.                 PortaApplicativa pa = (PortaApplicativa) oggetto;
  19600.                 if(pa!=null) {
  19601.                     autenticazione = !TipoAutenticazione.DISABILITATO.equals(pa.getAutenticazione());
  19602.                 }
  19603.                 if(pa!=null && pa.getServizio()!=null && pa.getServizio().getTipo()!=null) {
  19604.                     try {
  19605.                         protocollo = this.apsCore.getProtocolloAssociatoTipoServizio(pa.getServizio().getTipo());
  19606.                     }catch(Exception e) {
  19607.                         throw new DriverControlStationException(e.getMessage(),e);
  19608.                     }
  19609.                 }
  19610.                 try {
  19611.                     isSupportatoAutenticazione = this.soggettiCore.isSupportatoAutenticazioneApplicativiErogazione(protocollo);
  19612.                 }catch(Exception e) {
  19613.                     throw new DriverControlStationException(e.getMessage(),e);
  19614.                 }
  19615.                 if(pa!=null && pa.getTrasformazioni()!=null && pa.getTrasformazioni().sizeRegolaList()>0) {
  19616.                     for (TrasformazioneRegola trCheck : pa.getTrasformazioni().getRegolaList()){
  19617.                         if(trCheck.getNome().equals(nome)) {
  19618.                             tr = trCheck;
  19619.                             break;
  19620.                         }
  19621.                     }
  19622.                 }
  19623.                 if(pa!=null) {
  19624.                     autenticazioneToken = pa.getGestioneToken()!=null && pa.getGestioneToken().getPolicy()!=null;
  19625.                 }
  19626.             }
  19627.            
  19628.            
  19629.             // soggetti o applicativi
  19630.             if(servletTrasformazioniAutorizzazioneAutenticati !=null && (autenticazione || autenticazioneToken) ){
  19631.                 de = new DataElement();
  19632.                 de.setType(DataElementType.LINK);
  19633.                 de.setUrl(servletTrasformazioniAutorizzazioneAutenticati, parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati.toArray(new Parameter[parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati.size()]));
  19634.                 if(isPortaDelegata){
  19635.                     String labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZI_APPLICATIVI;
  19636.                     if(!this.isModalitaCompleta()) {
  19637.                         labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVI;
  19638.                     }
  19639.                     if (contaListe) {
  19640.                         ServletUtils.setDataElementCustomLabel(de,labelApplicativi,Long.valueOf(numAutenticati));
  19641.                     } else
  19642.                         ServletUtils.setDataElementCustomLabel(de,labelApplicativi);
  19643.                 }
  19644.                 else{
  19645.                     if (contaListe) {
  19646.                         ServletUtils.setDataElementCustomLabel(de,PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_SOGGETTI,Long.valueOf(numAutenticati));
  19647.                     } else
  19648.                         ServletUtils.setDataElementCustomLabel(de,PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_SOGGETTI);
  19649.                 }
  19650.                 dati.add(de);
  19651.             }
  19652.            
  19653.             // servizi applicativi
  19654.             boolean showLinkApplicativi = false;
  19655.             if(!isPortaDelegata && servletTrasformazioniApplicativiAutenticati!=null) {
  19656.                 if(autenticazioneToken) {
  19657.                     showLinkApplicativi = true;
  19658.                 }
  19659.                 else {
  19660.                     showLinkApplicativi = autenticazione && isSupportatoAutenticazione; // il link degli applicativi sulla pa deve essere visualizzato SOLO se è abilitata l'autenticazione
  19661.                 }
  19662.             }
  19663.             if(showLinkApplicativi){
  19664.                 de = new DataElement();
  19665.                 de.setType(DataElementType.LINK);
  19666.                 de.setUrl(servletTrasformazioniApplicativiAutenticati, parametriInvocazioneServletTrasformazioniApplicativiAutenticati.toArray(new Parameter[parametriInvocazioneServletTrasformazioniApplicativiAutenticati.size()]));
  19667.                 String labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZI_APPLICATIVI; // uso cmq label PD
  19668.                 if(!this.isModalitaCompleta()) {
  19669.                     labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVI;// uso cmq label PD
  19670.                 }
  19671.                 if (contaListe) {
  19672.                     ServletUtils.setDataElementCustomLabel(de,labelApplicativi,Long.valueOf(numApplicativiAutenticati));
  19673.                 } else {
  19674.                     ServletUtils.setDataElementCustomLabel(de,labelApplicativi);
  19675.                 }
  19676.                 dati.add(de);
  19677.             }
  19678.        
  19679.             de = new DataElement();
  19680.             de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_REGOLE_TRASFORMAZIONE);
  19681.             de.setType(DataElementType.TITLE);
  19682.             dati.add(de);
  19683.            
  19684.             // Richiesta
  19685.             de = new DataElement();
  19686.             de.setType(DataElementType.LINK);
  19687.             StringBuilder sb = new StringBuilder();
  19688.             if(tr!=null && tr.getRichiesta()!=null) {
  19689.                 if(tr.getRichiesta().sizeHeaderList()>0
  19690.                         ||
  19691.                         tr.getRichiesta().sizeParametroUrlList()>0
  19692.                         ||
  19693.                         (
  19694.                                 org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding) && tr.getRichiesta().getTrasformazioneRest()!=null
  19695.                                 &&
  19696.                                 (
  19697.                                     (tr.getRichiesta().getTrasformazioneRest().getMetodo()!=null && StringUtils.isNotEmpty(tr.getRichiesta().getTrasformazioneRest().getMetodo()))
  19698.                                     ||
  19699.                                     (tr.getRichiesta().getTrasformazioneRest().getPath()!=null && StringUtils.isNotEmpty(tr.getRichiesta().getTrasformazioneRest().getPath()))
  19700.                                 )
  19701.                         )
  19702.                     ){
  19703.                     if(sb.length()>0) {
  19704.                         sb.append(", ");
  19705.                     }
  19706.                     sb.append(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_TRASPORTO.toLowerCase());
  19707.                 }
  19708.                 if(tr.getRichiesta().getConversioneTemplate()!=null) {
  19709.                     if(sb.length()>0) {
  19710.                         sb.append(", ");
  19711.                     }
  19712.                     sb.append(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_CONTENUTO.toLowerCase());
  19713.                 }
  19714.                 if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding) && tr.getRichiesta().getTrasformazioneSoap()!=null) {
  19715.                     if(sb.length()>0) {
  19716.                         sb.append(", ");
  19717.                     }
  19718.                     sb.append(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP.toLowerCase());
  19719.                 }
  19720.                 if(org.openspcoop2.core.registry.constants.ServiceBinding.SOAP.equals(serviceBinding) && tr.getRichiesta().getTrasformazioneRest()!=null) {
  19721.                     if(sb.length()>0) {
  19722.                         sb.append(", ");
  19723.                     }
  19724.                     sb.append(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_REST.toLowerCase());
  19725.                 }
  19726.             }
  19727.             if(sb.length()>0) {
  19728.                 //de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA+" (" + sb.toString()+ ")");
  19729.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA+" (" + CostantiConfigurazione.ABILITATO.getValue().toLowerCase()+ ")");
  19730.             }
  19731.             else {
  19732.                 //de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA);
  19733.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA+" (" + CostantiConfigurazione.DISABILITATO.getValue().toLowerCase()+ ")");
  19734.             }
  19735.             de.setUrl(servletTrasformazioniRichiesta, parametriInvocazioneServletTrasformazioniRichiesta.toArray(new Parameter[parametriInvocazioneServletTrasformazioniRichiesta.size()]));
  19736.             dati.add(de);
  19737.            
  19738.             // Risposta
  19739.             de = new DataElement();
  19740.             de.setType(DataElementType.LINK);
  19741.             boolean contaListeFromSession = ServletUtils.getContaListeFromSession(this.session) != null ? ServletUtils.getContaListeFromSession(this.session) : false;
  19742.             if (contaListeFromSession)
  19743.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTE+" (" + numeroTrasformazioniRisposte + ")");
  19744.             else
  19745.                 de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTE);
  19746.             de.setUrl(servletTrasformazioniRispostaList, parametriInvocazioneServletTrasformazioniRisposta.toArray(new Parameter[parametriInvocazioneServletTrasformazioniRisposta.size()]));
  19747.             dati.add(de);
  19748.         }
  19749.        
  19750.         return dati;
  19751.     }
  19752.    
  19753.     public List<DataElement> addTrasformazioneRichiestaHeaderToDati(TipoOperazione tipoOP, String protocollo, boolean isPortaDelegata, List<DataElement> dati,
  19754.             String idTrasformazione, String idTrasformazioneRichiestaHeader, String nome, String tipo, String valore, String identificazione,
  19755.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding) {
  19756.        
  19757.         DataElement de = new DataElement();
  19758.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER);
  19759.         de.setType(DataElementType.TITLE);
  19760.         dati.add(de);
  19761.        
  19762.         // Id trasformazione hidden
  19763.         de = new DataElement();
  19764.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19765.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19766.         de.setType(DataElementType.HIDDEN);
  19767.         de.setValue(idTrasformazione);
  19768.         dati.add(de);
  19769.        
  19770.         // id trasformazione richiesta header
  19771.         de = new DataElement();
  19772.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19773.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE_RICHIESTA_HEADER);
  19774.         de.setType(DataElementType.HIDDEN);
  19775.         de.setValue(idTrasformazioneRichiestaHeader);
  19776.         dati.add(de);
  19777.        
  19778.         // Tipo
  19779.         de = new DataElement();
  19780.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_TIPO);
  19781.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_TIPO);
  19782.         //if(tipoOP.equals(TipoOperazione.ADD)) {
  19783.         de.setLabels(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO);
  19784.         de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO);
  19785.         de.setType(DataElementType.SELECT);
  19786.         de.setSelected(tipo);
  19787.         de.setRequired(true);
  19788.         de.setPostBack(true);
  19789.         //} else {
  19790.         //  de.setType(DataElementType.TEXT);
  19791.         //  de.setValue(tipo);
  19792.         //}
  19793.         dati.add(de);
  19794.        
  19795.         // Nome
  19796.         de = new DataElement();
  19797.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_NOME);
  19798.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_NOME);
  19799.         //if(tipoOP.equals(TipoOperazione.ADD)) {
  19800.         de.setType(DataElementType.TEXT_EDIT);
  19801.         de.setRequired(true);
  19802.         //} else {
  19803.         //  de.setType(DataElementType.TEXT);
  19804.         //}
  19805.         de.setValue(nome);
  19806.         dati.add(de);
  19807.        
  19808.         // Valore
  19809.         de = new DataElement();
  19810.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_VALORE);
  19811.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_VALORE);
  19812.         if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_DELETE.equals(tipo)) {
  19813.             de.setType(DataElementType.TEXT_AREA);
  19814.             de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  19815.             de.setSize(this.getSize());
  19816.             de.setRequired(true);
  19817.            
  19818.             DataElementInfo dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_VALORE);
  19819.             dInfoPattern.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TRASPORTO);
  19820.             if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  19821.                 dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_REST_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  19822.             }
  19823.             else {
  19824.                 dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_SOAP_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  19825.             }
  19826.             de.setInfo(dInfoPattern);
  19827.         }
  19828.         else {
  19829.             de.setType(DataElementType.HIDDEN);
  19830.         }
  19831.         de.setValue(valore);
  19832.         dati.add(de);
  19833.        
  19834.         // Identificazione Risorsa Fallita
  19835.         de = new DataElement();
  19836.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_IDENTIFICAZIONE);
  19837.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_IDENTIFICAZIONE);
  19838.         if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_DELETE.equals(tipo)) {
  19839.             de.setLabels(CostantiControlStation.SELECT_LABELS_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_IDENTIFICAZIONE_FALLITA_HEADER);
  19840.             de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_IDENTIFICAZIONE_FALLITA);
  19841.             de.setType(DataElementType.SELECT);
  19842.             de.setSelected(identificazione);
  19843.            
  19844.             DataElementInfo dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_IDENTIFICAZIONE);
  19845.             dInfoPattern.setHeaderBody(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_NOTE);
  19846.             dInfoPattern.setListBody(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_NOTE_VALORI_HEADER);
  19847.             de.setInfo(dInfoPattern);
  19848.         } else {
  19849.             de.setType(DataElementType.HIDDEN);
  19850.         }
  19851.         de.setValue(identificazione);
  19852.         dati.add(de);
  19853.        
  19854.         return dati;
  19855.     }
  19856.    
  19857.     public List<DataElement> addTrasformazioneRichiestaUrlParameterToDati(TipoOperazione tipoOP, String protocollo, boolean isPortaDelegata, List<DataElement> dati,
  19858.             String idTrasformazione, String idTrasformazioneRichiestaUrlParameter, String nome, String tipo, String valore, String identificazione,
  19859.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding) {
  19860.        
  19861.         DataElement de = new DataElement();
  19862.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO);
  19863.         de.setType(DataElementType.TITLE);
  19864.         dati.add(de);
  19865.        
  19866.         // Id trasformazione hidden
  19867.         de = new DataElement();
  19868.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19869.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19870.         de.setType(DataElementType.HIDDEN);
  19871.         de.setValue(idTrasformazione);
  19872.         dati.add(de);
  19873.        
  19874.         // id trasformazione richiesta header
  19875.         de = new DataElement();
  19876.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19877.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE_RICHIESTA_PARAMETRO);
  19878.         de.setType(DataElementType.HIDDEN);
  19879.         de.setValue(idTrasformazioneRichiestaUrlParameter);
  19880.         dati.add(de);
  19881.        
  19882.         // Tipo
  19883.         de = new DataElement();
  19884.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_TIPO);
  19885.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_TIPO);
  19886.         //if(tipoOP.equals(TipoOperazione.ADD)) {
  19887.         de.setLabels(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO);
  19888.         de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO);
  19889.         de.setType(DataElementType.SELECT);
  19890.         de.setSelected(tipo);
  19891.         de.setRequired(true);
  19892.         de.setPostBack(true);
  19893.         //} else {
  19894.         //de.setType(DataElementType.TEXT);
  19895.         //de.setValue(tipo);
  19896.         //}
  19897.         dati.add(de);
  19898.        
  19899.         // Nome
  19900.         de = new DataElement();
  19901.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_NOME);
  19902.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_NOME);
  19903.         //if(tipoOP.equals(TipoOperazione.ADD)) {
  19904.         de.setType(DataElementType.TEXT_EDIT);
  19905.         de.setRequired(true);
  19906.         //} else {
  19907.         //  de.setType(DataElementType.TEXT);
  19908.         //}
  19909.         de.setValue(nome);
  19910.         dati.add(de);
  19911.        
  19912.         // Valore
  19913.         de = new DataElement();
  19914.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_VALORE);
  19915.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_VALORE);
  19916.         if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_DELETE.equals(tipo)) {
  19917.             de.setType(DataElementType.TEXT_AREA);
  19918.             de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  19919.             de.setSize(this.getSize());
  19920.             de.setRequired(true);
  19921.            
  19922.             DataElementInfo dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_VALORE);
  19923.             dInfoPattern.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TRASPORTO);
  19924.             if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  19925.                 dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_REST_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  19926.             }
  19927.             else {
  19928.                 dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_SOAP_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  19929.             }
  19930.             de.setInfo(dInfoPattern);
  19931.         }
  19932.         else {
  19933.             de.setType(DataElementType.HIDDEN);
  19934.         }
  19935.         de.setValue(valore);
  19936.         dati.add(de);
  19937.        
  19938.         // Identificazione Risorsa Fallita
  19939.         de = new DataElement();
  19940.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_IDENTIFICAZIONE);
  19941.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_IDENTIFICAZIONE);
  19942.         if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_DELETE.equals(tipo)) {
  19943.             de.setLabels(CostantiControlStation.SELECT_LABELS_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_IDENTIFICAZIONE_FALLITA_PARAMETRO);
  19944.             de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_IDENTIFICAZIONE_FALLITA);
  19945.             de.setType(DataElementType.SELECT);
  19946.             de.setSelected(identificazione);
  19947.            
  19948.             DataElementInfo dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_IDENTIFICAZIONE);
  19949.             dInfoPattern.setHeaderBody(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_NOTE);
  19950.             dInfoPattern.setListBody(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_NOTE_VALORI_PARAMETRO);
  19951.             de.setInfo(dInfoPattern);
  19952.         } else {
  19953.             de.setType(DataElementType.HIDDEN);
  19954.         }
  19955.         de.setValue(identificazione);
  19956.         dati.add(de);
  19957.        
  19958.         return dati;
  19959.     }
  19960.    
  19961.     public List<DataElement> addTrasformazioneRispostaHeaderToDati(TipoOperazione tipoOP, String protocollo, boolean isPortaDelegata, List<DataElement> dati,
  19962.             String idTrasformazione, String idTrasformazioneRisposta, String idTrasformazioneRispostaHeader, String nome, String tipo, String valore, String identificazione,
  19963.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding) {
  19964.        
  19965.         DataElement de = new DataElement();
  19966.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER);
  19967.         de.setType(DataElementType.TITLE);
  19968.         dati.add(de);
  19969.        
  19970.         // Id trasformazione hidden
  19971.         de = new DataElement();
  19972.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19973.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19974.         de.setType(DataElementType.HIDDEN);
  19975.         de.setValue(idTrasformazione);
  19976.         dati.add(de);
  19977.        
  19978.         // id trasformazione risposta
  19979.         de = new DataElement();
  19980.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19981.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE_RISPOSTA);
  19982.         de.setType(DataElementType.HIDDEN);
  19983.         de.setValue(idTrasformazioneRisposta);
  19984.         dati.add(de);
  19985.        
  19986.         // id trasformazione risposta header
  19987.         de = new DataElement();
  19988.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  19989.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE_RISPOSTA_HEADER);
  19990.         de.setType(DataElementType.HIDDEN);
  19991.         de.setValue(idTrasformazioneRispostaHeader);
  19992.         dati.add(de);
  19993.        
  19994.         // Tipo
  19995.         de = new DataElement();
  19996.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_TIPO);
  19997.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_TIPO);
  19998.         //if(tipoOP.equals(TipoOperazione.ADD)) {
  19999.         de.setLabels(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO);
  20000.         de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO);
  20001.         de.setType(DataElementType.SELECT);
  20002.         de.setSelected(tipo);
  20003.         de.setPostBack(true);
  20004.         //} else {
  20005.         //  de.setType(DataElementType.TEXT);
  20006.         //  de.setValue(tipo);
  20007.         //}
  20008.         dati.add(de);
  20009.        
  20010.         // Nome
  20011.         de = new DataElement();
  20012.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_NOME);
  20013.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_NOME);
  20014.         //if(tipoOP.equals(TipoOperazione.ADD)) {
  20015.         de.setType(DataElementType.TEXT_EDIT);
  20016.         de.setRequired(true);
  20017.         //} else {
  20018.         //  de.setType(DataElementType.TEXT);
  20019.         //}
  20020.        
  20021.         de.setValue(nome);
  20022.         dati.add(de);
  20023.        
  20024.         // Valore
  20025.         de = new DataElement();
  20026.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_VALORE);
  20027.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_VALORE);
  20028.         if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_DELETE.equals(tipo)) {
  20029.             de.setType(DataElementType.TEXT_AREA);
  20030.             de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  20031.             de.setRequired(true);
  20032.            
  20033.             DataElementInfo dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_VALORE);
  20034.             dInfoPattern.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TRASPORTO);
  20035.             if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  20036.                 dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_REST_VALORI_CON_RISPOSTE(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20037.             }
  20038.             else {
  20039.                 dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_SOAP_VALORI_CON_RISPOSTE(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20040.             }
  20041.             de.setInfo(dInfoPattern);
  20042.         }
  20043.         else {
  20044.             de.setType(DataElementType.HIDDEN);
  20045.         }
  20046.         de.setValue(valore);
  20047.         dati.add(de);
  20048.        
  20049.         // Identificazione Risorsa Fallita
  20050.         de = new DataElement();
  20051.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_IDENTIFICAZIONE);
  20052.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_IDENTIFICAZIONE);
  20053.         if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_DELETE.equals(tipo)) {
  20054.             de.setLabels(CostantiControlStation.SELECT_LABELS_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_IDENTIFICAZIONE_FALLITA_HEADER);
  20055.             de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_IDENTIFICAZIONE_FALLITA);
  20056.             de.setType(DataElementType.SELECT);
  20057.             de.setSelected(identificazione);
  20058.            
  20059.             DataElementInfo dInfoPattern = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_IDENTIFICAZIONE);
  20060.             dInfoPattern.setHeaderBody(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_NOTE);
  20061.             dInfoPattern.setListBody(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_NOTE_VALORI_HEADER);
  20062.             de.setInfo(dInfoPattern);
  20063.         } else {
  20064.             de.setType(DataElementType.HIDDEN);
  20065.         }
  20066.         de.setValue(identificazione);
  20067.         dati.add(de);
  20068.        
  20069.         return dati;
  20070.     }
  20071.    
  20072.     public DataElement getHttpMethodDataElementTrasformazione(TipoOperazione tipoOperazione, String httpMethod) {
  20073.         return this.getHttpMethodDataElement(tipoOperazione, httpMethod, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_METHOD,
  20074.                 CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_METHOD,
  20075.                 false, null, null);
  20076.     }
  20077.    
  20078.     public List<DataElement> addTrasformazioneRichiestaToDati(TipoOperazione tipoOP, String protocollo, List<DataElement> dati, long idPorta, TrasformazioneRegolaRichiesta richiesta, boolean isPortaDelegata, String idTrasformazione,
  20079.             boolean trasformazioneContenutoAbilitato, org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneContenutoTipo, BinaryParameter trasformazioneContenutoTemplate, String trasformazioneContenutoTipoCheck,
  20080.             String trasformazioneRichiestaContentType,
  20081.             ServiceBinding serviceBindingMessage, boolean trasformazioneRestAbilitato, String trasformazioneRestMethod, String trasformazioneRestPath,
  20082.             boolean trasformazioneSoapAbilitato, String trasformazioneSoapAction, String trasformazioneSoapVersion, String trasformazioneSoapEnvelope,  
  20083.             org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneSoapEnvelopeTipo, BinaryParameter trasformazioneSoapEnvelopeTemplate, String trasformazioneSoapEnvelopeTipoCheck,
  20084.             String servletTrasformazioniRichiestaHeadersList, List<Parameter> parametriInvocazioneServletTrasformazioniRichiestaHeaders, int numeroTrasformazioniRichiestaHeaders,
  20085.             String servletTrasformazioniRichiestaParametriList, List<Parameter> parametriInvocazioneServletTrasformazioniRichiestaParametri, int numeroTrasformazioniRichiestaParametri,
  20086.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding) throws DriverControlStationException {
  20087.        
  20088.         DataElementInfo dInfoPatternTrasporto = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_VALORE);
  20089.         dInfoPatternTrasporto.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TRASPORTO);
  20090.         if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  20091.             dInfoPatternTrasporto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_REST_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20092.         }
  20093.         else {
  20094.             dInfoPatternTrasporto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_SOAP_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20095.         }
  20096.        
  20097.         // Id trasformazione hidden
  20098.         DataElement  de = new DataElement();
  20099.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  20100.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  20101.         de.setType(DataElementType.HIDDEN);
  20102.         de.setValue(idTrasformazione);
  20103.         dati.add(de);
  20104.        
  20105.         de = new DataElement();
  20106.         de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_TRASFORMAZIONI_TRASFORMAZIONE);
  20107.         de.setType(DataElementType.TITLE);
  20108.         dati.add(de);
  20109.        
  20110.         // sezione trasporto
  20111.         de = new DataElement();
  20112.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_TRASPORTO);
  20113.         de.setType(DataElementType.SUBTITLE);
  20114.         dati.add(de);
  20115.        
  20116.         if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding) && !trasformazioneSoapAbilitato) {
  20117.            
  20118.             // method
  20119.             de = new DataElement();
  20120.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_METHOD);
  20121.             de.setValue(trasformazioneRestMethod);
  20122.             de.setType(DataElementType.TEXT_EDIT);
  20123.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_METHOD);
  20124.             de.setSize(this.getSize());
  20125.             de.setInfo(dInfoPatternTrasporto);
  20126.             dati.add(de);
  20127.            
  20128.             //  path
  20129.             de = new DataElement();
  20130.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_PATH);
  20131.             de.setValue(trasformazioneRestPath);
  20132.             de.setType(DataElementType.TEXT_AREA);
  20133.             de.setRows(1);
  20134.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_PATH);
  20135.             de.setSize(this.getSize());
  20136.             de.setInfo(dInfoPatternTrasporto);
  20137.             de.setNote(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_PATH_NOTE);
  20138.             dati.add(de);
  20139.                        
  20140.         }
  20141.        
  20142.        
  20143.         // Header
  20144.         de = new DataElement();
  20145.         de.setType(DataElementType.LINK);
  20146.         boolean contaListeFromSession = ServletUtils.getContaListeFromSession(this.session) != null ? ServletUtils.getContaListeFromSession(this.session) : false;
  20147.         if (contaListeFromSession)
  20148.             de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADERS+" (" + numeroTrasformazioniRichiestaHeaders + ")");
  20149.         else
  20150.             de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADERS);
  20151.         de.setUrl(servletTrasformazioniRichiestaHeadersList, parametriInvocazioneServletTrasformazioniRichiestaHeaders.toArray(new Parameter[parametriInvocazioneServletTrasformazioniRichiestaHeaders.size()]));
  20152.         dati.add(de);
  20153.        
  20154.         // url parameters
  20155.         de = new DataElement();
  20156.         de.setType(DataElementType.LINK);
  20157.         if (contaListeFromSession)
  20158.             de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRI+" (" + numeroTrasformazioniRichiestaParametri + ")");
  20159.         else
  20160.             de.setValue(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRI);
  20161.         de.setUrl(servletTrasformazioniRichiestaParametriList, parametriInvocazioneServletTrasformazioniRichiestaParametri.toArray(new Parameter[parametriInvocazioneServletTrasformazioniRichiestaParametri.size()]));
  20162.         dati.add(de);
  20163.        
  20164.        
  20165.        
  20166.        
  20167.         // sezione contenuto
  20168.         de = new DataElement();
  20169.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_CONTENUTO);
  20170.         de.setType(DataElementType.SUBTITLE);
  20171.         dati.add(de);
  20172.        
  20173.         // abilitato
  20174.         de = new DataElement();
  20175.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_ENABLED);
  20176.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_ENABLED);
  20177.         de.setType(DataElementType.CHECKBOX);
  20178.         de.setSelected(trasformazioneContenutoAbilitato);
  20179.         de.setValue(trasformazioneContenutoAbilitato+"");
  20180.         de.setPostBack(true);
  20181.         dati.add(de);
  20182.        
  20183.         String postbackElement = this.getPostBackElementName();
  20184.        
  20185.         boolean old_trasformazioneContenutoTemplate = false;
  20186.         boolean old_trasformazioneSoapEnvelopeTemplate = false;
  20187.        
  20188.         if(trasformazioneContenutoAbilitato) {
  20189.             // tipo
  20190.             de = new DataElement();
  20191.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO);
  20192.             List<String> labels = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toLabelList(serviceBindingMessage, false);
  20193.             if(trasformazioneRestAbilitato) {
  20194.                 List<String> newLabels = new ArrayList<>();
  20195.                 String payloadVuotoSoap = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY.getLabel(ServiceBinding.SOAP);
  20196.                 for (String l : labels) {
  20197.                     if(l.equals(payloadVuotoSoap)) {
  20198.                         newLabels.add(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY.getLabel(ServiceBinding.REST));
  20199.                     }
  20200.                     else {
  20201.                         newLabels.add(l);
  20202.                     }
  20203.                 }
  20204.                 labels = newLabels;
  20205.             }
  20206.             else if(trasformazioneSoapAbilitato) {
  20207.                 List<String> newLabels = new ArrayList<>();
  20208.                 String payloadVuotoSoap = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY.getLabel(ServiceBinding.REST);
  20209.                 for (String l : labels) {
  20210.                     if(l.equals(payloadVuotoSoap)) {
  20211.                         newLabels.add(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY.getLabel(ServiceBinding.SOAP));
  20212.                     }
  20213.                     else {
  20214.                         newLabels.add(l);
  20215.                     }
  20216.                 }
  20217.                 labels = newLabels;
  20218.             }
  20219.             de.setLabels(labels);
  20220.             de.setValues(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toStringList(serviceBindingMessage, false));
  20221.             de.setType(DataElementType.SELECT);
  20222.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO);
  20223.             de.setPostBack(true);
  20224.             de.setSelected(trasformazioneContenutoTipo.getValue());
  20225.             setTemplateInfo(de, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO, trasformazioneContenutoTipo, serviceBinding, false,
  20226.                     protocollo, isPortaDelegata);
  20227.             dati.add(de);
  20228.            
  20229.             if(trasformazioneContenutoTipo.isTemplateRequired()) {
  20230.                
  20231.                 // richiesta null in add
  20232.                 boolean templateRequired = true;
  20233.                
  20234.                 if(richiesta!=null){
  20235.                     old_trasformazioneContenutoTemplate = richiesta.getConversioneTemplate() != null && richiesta.getConversioneTemplate().length > 0;
  20236.                     TipoTrasformazione oldTrasformazioneContenutoTipo = StringUtils.isNotEmpty(richiesta.getConversioneTipo())
  20237.                             ? org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(richiesta.getConversioneTipo()) : org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  20238.                     if(trasformazioneContenutoTipo.equals(oldTrasformazioneContenutoTipo)) {
  20239.                         templateRequired = false;
  20240.                     }
  20241.                 }
  20242.                            
  20243.                 if(postbackElement != null) {
  20244.                     if(postbackElement.equals(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO)) {
  20245.                         old_trasformazioneContenutoTemplate = false;
  20246.                         templateRequired = true;
  20247.                     }
  20248. //                  if(postbackElement.equals(trasformazioneContenutoTemplate.getName())) {
  20249. //                      if(StringUtils.isEmpty(trasformazioneContenutoTipoCheck))
  20250. //                          trasformazioneContenutoTipoCheck = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_FILE;
  20251. //                  }
  20252.                 }
  20253.                
  20254.                 de = new DataElement();
  20255.                 de.setLabel("");
  20256.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK);
  20257.                 de.setType(DataElementType.HIDDEN);
  20258.                 de.setValue(trasformazioneContenutoTipoCheck);
  20259.                 dati.add(de);
  20260.                
  20261.                 if(StringUtils.isNotEmpty(trasformazioneContenutoTipoCheck) && trasformazioneContenutoTipoCheck.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_TIPO))
  20262.                     templateRequired = true;
  20263.                
  20264.                 String trasformazioneContenutoLabel = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TEMPLATE;
  20265.                 if(old_trasformazioneContenutoTemplate && StringUtils.isEmpty(trasformazioneContenutoTipoCheck)) {
  20266.                     trasformazioneContenutoLabel = "";
  20267.                     DataElement saveAs = new DataElement();
  20268.                     saveAs.setValue(CostantiControlStation.LABEL_DOWNLOAD_DOCUMENTO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TEMPLATE);
  20269.                     saveAs.setType(DataElementType.LINK);
  20270.                
  20271.                     Parameter pIdTrasformazioneRegola = new Parameter(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE, idTrasformazione);
  20272.                     Parameter pIdAccordo = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_ID_ACCORDO, idPorta+"");
  20273.                     Parameter pTipoAllegato = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, isPortaDelegata ? "pd" : "pa");
  20274.                     Parameter pTipoDoc = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, isPortaDelegata ?
  20275.                             ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_PORTA_DELEGATA_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TEMPLATE :
  20276.                                 ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_PORTA_APPLICATIVA_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TEMPLATE);
  20277.                     saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT, pIdAccordo, pTipoAllegato, pTipoDoc, pIdTrasformazioneRegola);
  20278.                     saveAs.setDisabilitaAjaxStatus();
  20279.                     dati.add(saveAs);
  20280.                 }
  20281.                
  20282.                 // template
  20283.                 DataElement trasformazioneContenutoTemplateDataElement = trasformazioneContenutoTemplate.getFileDataElement(trasformazioneContenutoLabel, "", getSize());
  20284.                 trasformazioneContenutoTemplateDataElement.setRequired(templateRequired);
  20285.                 dati.add(trasformazioneContenutoTemplateDataElement);
  20286.                 dati.addAll(trasformazioneContenutoTemplate.getFileNameDataElement());
  20287.                 dati.add(trasformazioneContenutoTemplate.getFileIdDataElement());
  20288.             }
  20289.            
  20290.             boolean contentTypePerAttachmentSOAP = false;
  20291.             if(trasformazioneContenutoTipo.isTrasformazioneProtocolloEnabled()) {
  20292.                 if(ServiceBinding.REST.equals(serviceBindingMessage) &&
  20293.                         trasformazioneSoapAbilitato &&
  20294.                         (!TipoTrasformazione.EMPTY.equals(trasformazioneContenutoTipo)) &&
  20295.                         CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_ATTACHMENT.equals(trasformazioneSoapEnvelope)) {
  20296.                     contentTypePerAttachmentSOAP = true;
  20297.                 }
  20298.             }
  20299.            
  20300.             if(!contentTypePerAttachmentSOAP && trasformazioneContenutoTipo.isContentTypeEnabled()) {
  20301.                 // Content-type
  20302.                 de = new DataElement();
  20303.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONTENT_TYPE);
  20304.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONTENT_TYPE);
  20305.                 de.setType(DataElementType.TEXT_EDIT);
  20306.                 de.setValue(StringEscapeUtils.escapeHtml(trasformazioneRichiestaContentType));
  20307.            
  20308.                 switch (serviceBindingMessage) {
  20309.                 case REST:
  20310.                     if(trasformazioneSoapAbilitato) {
  20311.                         de.setType(DataElementType.HIDDEN);
  20312.                         de.setValue("");
  20313.                     }
  20314.                     else {
  20315.                         de.setInfo(dInfoPatternTrasporto);
  20316.                     }
  20317.                     break;
  20318.                 case SOAP:
  20319.                     de.setInfo(dInfoPatternTrasporto);
  20320.                     if(trasformazioneRestAbilitato) {
  20321.                         de.setRequired(true);
  20322.                     }
  20323.                     break;
  20324.                 }
  20325.        
  20326.                 dati.add(de);
  20327.             }
  20328.            
  20329.             if(trasformazioneContenutoTipo.isTrasformazioneProtocolloEnabled()) {
  20330.                 switch (serviceBindingMessage) {
  20331.                 case REST:
  20332.                     // sezione trasformazione SOAP
  20333.                     de = new DataElement();
  20334.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP);
  20335.                     de.setType(DataElementType.SUBTITLE);
  20336.                     dati.add(de);
  20337.                    
  20338.                     // abilitato
  20339.                     de = new DataElement();
  20340.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_TRANSFORMATION);
  20341.                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_TRANSFORMATION);
  20342.                     de.setType(DataElementType.CHECKBOX);
  20343.                     de.setSelected(trasformazioneSoapAbilitato);
  20344.                     de.setValue(trasformazioneSoapAbilitato+"");
  20345.                     de.setPostBack(true);
  20346.                     dati.add(de);
  20347.                    
  20348.                     if(trasformazioneSoapAbilitato) {
  20349.                         // soap versione
  20350.                         de = new DataElement();
  20351.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_VERSION);
  20352.                         String soapVersionLabels[] = {CostantiControlStation.LABEL_SOAP_11, CostantiControlStation.LABEL_SOAP_12};
  20353.                         String soapVersionValues[] = {CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_12};
  20354.                         de.setLabels(soapVersionLabels);
  20355.                         de.setValues(soapVersionValues);
  20356.                         de.setType(DataElementType.SELECT);
  20357.                         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_VERSION);
  20358.                         de.setSelected(trasformazioneSoapVersion);
  20359.                         dati.add(de);
  20360.                        
  20361.                         // soap action
  20362.                         de = new DataElement();
  20363.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ACTION);
  20364.                         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ACTION);
  20365.                         de.setType(DataElementType.TEXT_EDIT);
  20366.                         de.setValue(trasformazioneSoapAction);
  20367.                         de.setInfo(dInfoPatternTrasporto);
  20368.                         dati.add(de);
  20369.                        
  20370.                         if(!TipoTrasformazione.EMPTY.equals(trasformazioneContenutoTipo)) {
  20371.                             // Envelope
  20372.                             de = new DataElement();
  20373.                             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE);
  20374.                             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE);
  20375.                             de.setLabels(CostantiControlStation.SELECT_LABELS_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE);
  20376.                             de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE);
  20377.                             de.setType(DataElementType.SELECT);
  20378.                             de.setSelected(trasformazioneSoapEnvelope);
  20379.                             de.setPostBack(true);
  20380.                             dati.add(de);
  20381.                                                    
  20382.                             if(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_ATTACHMENT.equals(trasformazioneSoapEnvelope)) {
  20383.                                
  20384.                                 // Content-type
  20385.                                 de = new DataElement();
  20386.                                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONTENT_TYPE_ATTACHMENT);
  20387.                                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONTENT_TYPE);
  20388.                                 de.setType(DataElementType.TEXT_EDIT);
  20389.                                 de.setValue(trasformazioneRichiestaContentType);
  20390.                                 de.setInfo(dInfoPatternTrasporto);
  20391.                                 de.setRequired(true);
  20392.                                 dati.add(de);
  20393.                                
  20394.                                 de = new DataElement();
  20395.                                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TITLE_BODY);
  20396.                                 de.setType(DataElementType.SUBTITLE);
  20397.                                 dati.add(de);                          
  20398.                                
  20399.                                 // tipo envelope attachement
  20400.                                 de = new DataElement();
  20401.                                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TIPO);
  20402.                                 de.setLabels(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toLabelList(ServiceBinding.SOAP, true));
  20403.                                 de.setValues(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toStringList(ServiceBinding.SOAP, true));
  20404.                                 de.setType(DataElementType.SELECT);
  20405.                                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TIPO);
  20406.                                 de.setSelected(trasformazioneSoapEnvelopeTipo.getValue());
  20407.                                 de.setPostBack(true);
  20408.                                 setTemplateInfo(de, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TIPO, trasformazioneSoapEnvelopeTipo, serviceBinding, false,
  20409.                                         protocollo, isPortaDelegata);
  20410.                                 dati.add(de);
  20411.                                
  20412.                                 if(trasformazioneSoapEnvelopeTipo.isTemplateRequired()) {
  20413.                                    
  20414.                                     // richiesta null in add
  20415.                                     boolean templateRequired = true;
  20416.                                     if(richiesta!=null){
  20417.                                         TrasformazioneSoap oldTrasformazioneSoap = richiesta.getTrasformazioneSoap();
  20418.                                         old_trasformazioneSoapEnvelopeTemplate = oldTrasformazioneSoap != null && oldTrasformazioneSoap.getEnvelopeBodyConversioneTemplate() != null && oldTrasformazioneSoap.getEnvelopeBodyConversioneTemplate().length > 0;
  20419.                                         String oldTrasformazioneSoapEnvelopeTipoS = oldTrasformazioneSoap != null ? oldTrasformazioneSoap.getEnvelopeBodyConversioneTipo() : null;
  20420.                                         TipoTrasformazione oldTrasformazioneSoapEnvelopeTipo = StringUtils.isNotEmpty(oldTrasformazioneSoapEnvelopeTipoS)
  20421.                                                 ? org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(oldTrasformazioneSoapEnvelopeTipoS) : org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  20422.                                         if(trasformazioneSoapEnvelopeTipo.equals(oldTrasformazioneSoapEnvelopeTipo)) {
  20423.                                             templateRequired = false;
  20424.                                         }  
  20425.                                     }
  20426.                                    
  20427.                                     if(postbackElement != null) {
  20428.                                         if(postbackElement.equals(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TIPO)) {
  20429.                                             old_trasformazioneSoapEnvelopeTemplate = false;
  20430.                                             templateRequired = true;
  20431.                                         }
  20432.                                        
  20433. //                                      if(postbackElement.equals(trasformazioneSoapEnvelopeTemplate.getName())) {
  20434. //                                          trasformazioneSoapEnvelopeTipoCheck = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_FILE;
  20435. //                                      }
  20436.                                     }
  20437.                                    
  20438.                                     de = new DataElement();
  20439.                                     de.setLabel("");
  20440.                                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TIPO_CHECK);
  20441.                                     de.setType(DataElementType.HIDDEN);
  20442.                                     de.setValue(trasformazioneSoapEnvelopeTipoCheck);
  20443.                                     dati.add(de);
  20444.                                    
  20445.                                     if(StringUtils.isNotEmpty(trasformazioneSoapEnvelopeTipoCheck) && trasformazioneSoapEnvelopeTipoCheck.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_TIPO))
  20446.                                         templateRequired = true;
  20447.                                    
  20448.                                     String trasformazioneSoapEnvelopeTemplateLabel = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TEMPLATE;
  20449.                                     if(old_trasformazioneSoapEnvelopeTemplate && StringUtils.isEmpty(trasformazioneSoapEnvelopeTipoCheck)) {
  20450.                                         trasformazioneSoapEnvelopeTemplateLabel = "";
  20451.                                         DataElement saveAs = new DataElement();
  20452.                                         saveAs.setValue(CostantiControlStation.LABEL_DOWNLOAD_DOCUMENTO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TEMPLATE);
  20453.                                         saveAs.setType(DataElementType.LINK);

  20454.                                         Parameter pIdTrasformazioneRegola = new Parameter(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE, idTrasformazione);
  20455.                                         Parameter pIdAccordo = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_ID_ACCORDO, idPorta+"");
  20456.                                         Parameter pTipoAllegato = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, isPortaDelegata ? "pd" : "pa");
  20457.                                         Parameter pTipoDoc = new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, isPortaDelegata
  20458.                                                 ? ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_PORTA_DELEGATA_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TEMPLATE
  20459.                                                         : ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_PORTA_APPLICATIVA_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TEMPLATE);
  20460.                                         saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT, pIdAccordo, pTipoAllegato, pTipoDoc,pIdTrasformazioneRegola);
  20461.                                         dati.add(saveAs);
  20462.                                     }
  20463.                                    
  20464.                                     //  template envelope attachement
  20465.                                     DataElement trasformazioneSoapEnvelopeTemplateDataElement = trasformazioneSoapEnvelopeTemplate.getFileDataElement(trasformazioneSoapEnvelopeTemplateLabel, "", getSize());
  20466.                                     trasformazioneSoapEnvelopeTemplateDataElement.setRequired(templateRequired);
  20467.                                     dati.add(trasformazioneSoapEnvelopeTemplateDataElement);
  20468.                                     dati.addAll(trasformazioneSoapEnvelopeTemplate.getFileNameDataElement());
  20469.                                     dati.add(trasformazioneSoapEnvelopeTemplate.getFileIdDataElement());
  20470.                                 }
  20471.                             }
  20472.                         }
  20473.                     }
  20474.                     break;
  20475.                 case SOAP:
  20476.                 default:
  20477.                     // sezione trasformazione REST
  20478.                     de = new DataElement();
  20479.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_REST);
  20480.                     de.setType(DataElementType.SUBTITLE);
  20481.                     dati.add(de);
  20482.    
  20483.                     // abilitato
  20484.                     de = new DataElement();
  20485.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_TRANSFORMATION);
  20486.                     de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_TRANSFORMATION);
  20487.                     de.setType(DataElementType.CHECKBOX);
  20488.                     de.setSelected(trasformazioneRestAbilitato);
  20489.                     de.setValue(trasformazioneRestAbilitato+"");
  20490.                     de.setPostBack(true);
  20491.                     dati.add(de);
  20492.                    
  20493.                     if(trasformazioneRestAbilitato) {
  20494.                         //  path
  20495.                         de = new DataElement();
  20496.                         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_PATH);
  20497.                         de.setValue(trasformazioneRestPath);
  20498.                         de.setType(DataElementType.TEXT_AREA);
  20499.                         de.setRows(3);
  20500.                         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REST_PATH);
  20501.                         de.setSize(this.getSize());
  20502.                         de.setRequired(true);
  20503.                         de.setInfo(dInfoPatternTrasporto);
  20504.                         dati.add(de);
  20505.                        
  20506.                         // method
  20507.                         de = getHttpMethodDataElementTrasformazione(tipoOP, trasformazioneRestMethod);
  20508.                         dati.add(de);
  20509.                        
  20510.                     }
  20511.                    
  20512.                     break;
  20513.                 }
  20514.             }
  20515.         }
  20516.        
  20517.         return dati;
  20518.     }
  20519.    
  20520.     private void setTemplateInfo(DataElement de, String label, org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneContenutoTipo,
  20521.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding, boolean risposta,
  20522.             String protocollo, boolean isPortaDelegata) throws DriverControlStationException {
  20523.        
  20524.         if(trasformazioneContenutoTipo==null) {
  20525.             throw new DriverControlStationException("Param trasformazioneContenutoTipo is null");
  20526.         }
  20527.        
  20528.         switch (trasformazioneContenutoTipo) {
  20529.         case TEMPLATE:
  20530.             DataElementInfo dInfoPatternContenuto = new DataElementInfo(label);
  20531.             dInfoPatternContenuto.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TEMPLATE);
  20532.             if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  20533.                 if(risposta) {
  20534.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_REST_VALORI_CON_RISPOSTE(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20535.                 }
  20536.                 else {
  20537.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_REST_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20538.                 }
  20539.             }
  20540.             else {
  20541.                 if(risposta) {
  20542.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_SOAP_VALORI_CON_RISPOSTE(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20543.                 }
  20544.                 else {
  20545.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_SOAP_VALORI(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20546.                 }
  20547.             }
  20548.             de.setInfo(dInfoPatternContenuto);
  20549.             break;
  20550.         case FREEMARKER_TEMPLATE:
  20551.         case CONTEXT_FREEMARKER_TEMPLATE:
  20552.         case FREEMARKER_TEMPLATE_ZIP:
  20553.             dInfoPatternContenuto = new DataElementInfo(label);
  20554.             if(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.FREEMARKER_TEMPLATE.equals(trasformazioneContenutoTipo) ||
  20555.                     org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.CONTEXT_FREEMARKER_TEMPLATE.equals(trasformazioneContenutoTipo)) {
  20556.                 dInfoPatternContenuto.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_OBJECT_TEMPLATE_FREEMARKER);
  20557.             }
  20558.             else {
  20559.                 dInfoPatternContenuto.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_OBJECT_TEMPLATE_FREEMARKER_ZIP);
  20560.             }
  20561.             if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  20562.                 if(risposta) {
  20563.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_REST_VALORI_CON_RISPOSTE_FREEMARKER(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20564.                 }
  20565.                 else {
  20566.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_REST_VALORI_FREEMARKER(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20567.                 }
  20568.             }
  20569.             else {
  20570.                 if(risposta) {
  20571.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_SOAP_VALORI_CON_RISPOSTE_FREEMARKER(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20572.                 }
  20573.                 else {
  20574.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_SOAP_VALORI_FREEMARKER(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20575.                 }
  20576.             }
  20577.             de.setInfo(dInfoPatternContenuto);
  20578.             break;
  20579.         case VELOCITY_TEMPLATE:
  20580.         case CONTEXT_VELOCITY_TEMPLATE:
  20581.         case VELOCITY_TEMPLATE_ZIP:
  20582.             dInfoPatternContenuto = new DataElementInfo(label);
  20583.             if(org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.VELOCITY_TEMPLATE.equals(trasformazioneContenutoTipo) ||
  20584.                     org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.CONTEXT_VELOCITY_TEMPLATE.equals(trasformazioneContenutoTipo)) {
  20585.                 dInfoPatternContenuto.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_OBJECT_TEMPLATE_VELOCITY);
  20586.             }
  20587.             else {
  20588.                 dInfoPatternContenuto.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_OBJECT_TEMPLATE_VELOCITY_ZIP);
  20589.             }
  20590.             if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  20591.                 if(risposta) {
  20592.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_REST_VALORI_CON_RISPOSTE_VELOCITY(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20593.                 }
  20594.                 else {
  20595.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_REST_VALORI_VELOCITY(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20596.                 }
  20597.             }
  20598.             else {
  20599.                 if(risposta) {
  20600.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_SOAP_VALORI_CON_RISPOSTE_VELOCITY(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20601.                 }
  20602.                 else {
  20603.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_SOAP_VALORI_VELOCITY(this.isProfiloModIPA(protocollo), isPortaDelegata, false));
  20604.                 }
  20605.             }
  20606.             de.setInfo(dInfoPatternContenuto);
  20607.             break;
  20608.         case ZIP:
  20609.         case TGZ:
  20610.         case TAR:
  20611.             dInfoPatternContenuto = new DataElementInfo(label);
  20612.             dInfoPatternContenuto.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TEMPLATE_COMPRESS);
  20613.             if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  20614.                 if(risposta) {
  20615.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TEMPLATE_COMPRESS_REST_VALORI_CON_RISPOSTE);
  20616.                 }
  20617.                 else {
  20618.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TEMPLATE_COMPRESS_REST_VALORI);
  20619.                 }
  20620.             }
  20621.             else {
  20622.                 if(risposta) {
  20623.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TEMPLATE_COMPRESS_SOAP_VALORI_CON_RISPOSTE);
  20624.                 }
  20625.                 else {
  20626.                     dInfoPatternContenuto.setListBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TEMPLATE_COMPRESS_SOAP_VALORI);
  20627.                 }
  20628.             }
  20629.             de.setInfo(dInfoPatternContenuto);
  20630.             break;
  20631.         case EMPTY:
  20632.         case XSLT:
  20633.             break;
  20634.         }
  20635.     }
  20636.    
  20637.     public boolean trasformazioniRispostaHeaderCheckData(TipoOperazione tipoOp) throws DriverControlStationException {
  20638.         try{
  20639.             String tipo = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_TIPO);
  20640.             String nome = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_NOME);
  20641.             String valore = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_VALORE);
  20642.            
  20643.             // Campi obbligatori
  20644.             if (StringUtils.isEmpty(nome)) {
  20645.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_NOME));
  20646.                 return false;
  20647.             }
  20648.             if ((nome.indexOf(" ") != -1) ) {
  20649.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEL_CAMPO_NOME);
  20650.                 return false;
  20651.             }
  20652.             if(!this.checkLength255(nome, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_NOME)) {
  20653.                 return false;
  20654.             }
  20655.            
  20656.             if (StringUtils.isEmpty(tipo)) {
  20657.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_TIPO));
  20658.                 return false;
  20659.             }
  20660.             if(!this.checkLength255(tipo, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_TIPO)) {
  20661.                 return false;
  20662.             }
  20663.            
  20664.             if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_DELETE.equals(tipo)) {
  20665.                 if (StringUtils.isEmpty(valore)) {
  20666.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_VALORE));
  20667.                     return false;
  20668.                 }
  20669.                 try{
  20670.                     DynamicUtils.validate(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_VALORE, valore, false);
  20671.                 }catch(Exception e){
  20672.                     this.pd.setMessage("Il valore indicato nel parametro '"+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RISPOSTA_HEADER_VALORE+"' non risulta corretto: "+e.getMessage());
  20673.                     return false;
  20674.                 }
  20675.             }
  20676.            
  20677.             return true;
  20678.         } catch (Exception e) {
  20679.             this.logError("Exception: " + e.getMessage(), e);
  20680.             throw new DriverControlStationException(e);
  20681.         }
  20682.     }
  20683.    
  20684.     public boolean trasformazioniRichiestaHeaderCheckData(TipoOperazione tipoOp) throws DriverControlStationException {
  20685.         try{
  20686.             String tipo = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_TIPO);
  20687.             String nome = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_NOME);
  20688.             String valore = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_VALORE);
  20689.            
  20690.             // Campi obbligatori
  20691.             if (StringUtils.isEmpty(nome)) {
  20692.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_NOME));
  20693.                 return false;
  20694.             }
  20695.             if ((nome.indexOf(" ") != -1) ) {
  20696.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEL_CAMPO_NOME);
  20697.                 return false;
  20698.             }
  20699.             if(!this.checkLength255(nome, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_NOME)) {
  20700.                 return false;
  20701.             }
  20702.            
  20703.             if (StringUtils.isEmpty(tipo)) {
  20704.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_TIPO));
  20705.                 return false;
  20706.             }
  20707.             if(!this.checkLength255(tipo, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_TIPO)) {
  20708.                 return false;
  20709.             }
  20710.            
  20711.             if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_DELETE.equals(tipo)) {
  20712.                 if (StringUtils.isEmpty(valore)) {
  20713.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_VALORE));
  20714.                     return false;
  20715.                 }
  20716.                 try{
  20717.                     DynamicUtils.validate(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_VALORE, valore, false);
  20718.                 }catch(Exception e){
  20719.                     this.pd.setMessage("Il valore indicato nel parametro '"+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_VALORE+"' non risulta corretto: "+e.getMessage());
  20720.                     return false;
  20721.                 }
  20722.             }
  20723.            
  20724.             return true;
  20725.         } catch (Exception e) {
  20726.             this.logError("Exception: " + e.getMessage(), e);
  20727.             throw new DriverControlStationException(e);
  20728.         }
  20729.     }
  20730.    
  20731.     public boolean trasformazioniRichiestaUrlParameterCheckData(TipoOperazione tipoOp) throws DriverControlStationException {
  20732.         try{
  20733.             String tipo = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_TIPO);
  20734.             String nome = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_NOME);
  20735.             String valore = this.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_VALORE);
  20736.            
  20737.             // Campi obbligatori
  20738.             if (StringUtils.isEmpty(nome)) {
  20739.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_NOME));
  20740.                 return false;
  20741.             }
  20742.             if ((nome.indexOf(" ") != -1) ) {
  20743.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEL_CAMPO_NOME);
  20744.                 return false;
  20745.             }
  20746.             if(!this.checkLength255(nome, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_NOME)) {
  20747.                 return false;
  20748.             }
  20749.            
  20750.             if (StringUtils.isEmpty(tipo)) {
  20751.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_TIPO));
  20752.                 return false;
  20753.             }
  20754.             if(!this.checkLength255(tipo, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_TIPO)) {
  20755.                 return false;
  20756.             }
  20757.            
  20758.             if(!CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PARAMETRO_DELETE.equals(tipo)) {
  20759.                 if (StringUtils.isEmpty(valore)) {
  20760.                     this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_HEADER_VALORE));
  20761.                     return false;
  20762.                 }
  20763.                 try{
  20764.                     DynamicUtils.validate(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_VALORE, valore, false);
  20765.                 }catch(Exception e){
  20766.                     this.pd.setMessage("Il valore indicato nel parametro '"+CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_VALORE+"' non risulta corretto: "+e.getMessage());
  20767.                     return false;
  20768.                 }
  20769.             }
  20770.            
  20771.             return true;
  20772.         } catch (Exception e) {
  20773.             this.logError("Exception: " + e.getMessage(), e);
  20774.             throw new DriverControlStationException(e);
  20775.         }
  20776.     }
  20777.    
  20778.     public List<DataElement> addPorteTrasformazioniServizioApplicativoToDati(TipoOperazione tipoOp, List<DataElement> dati, String idTrasformazione, boolean fromList,
  20779.         String servizioApplicativo, String[] servizioApplicativoList, int sizeAttuale,
  20780.         boolean addMsgServiziApplicativoNonDisponibili, boolean addTitle) {
  20781.        
  20782.         if(fromList) {
  20783.             DataElement de = new DataElement();
  20784.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_LIST);
  20785.             de.setType(DataElementType.HIDDEN);
  20786.             de.setValue(fromList+"");
  20787.             dati.add(de);
  20788.         }
  20789.        
  20790.         DataElement  de = new DataElement();
  20791.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  20792.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  20793.         de.setType(DataElementType.HIDDEN);
  20794.         de.setValue(idTrasformazione);
  20795.         dati.add(de);
  20796.        
  20797.         if(servizioApplicativoList!=null && servizioApplicativoList.length>0){
  20798.        
  20799.             String labelApplicativo = CostantiControlStation.LABEL_PARAMETRO_SERVIZIO_APPLICATIVO;
  20800.             if(!this.isModalitaCompleta()) {
  20801.                 labelApplicativo = CostantiControlStation.LABEL_PARAMETRO_APPLICATIVO;
  20802.             }
  20803.            
  20804.             if(addTitle) {
  20805.                 de = new DataElement();
  20806.                 de.setType(DataElementType.TITLE);
  20807.                 de.setLabel(labelApplicativo);
  20808.                 dati.add(de);
  20809.             }
  20810.            
  20811.             de = new DataElement();
  20812.             de.setLabel( CostantiControlStation.LABEL_PARAMETRO_NOME );
  20813.             de.setType(DataElementType.SELECT);
  20814.             de.setName(CostantiControlStation.PARAMETRO_SERVIZIO_APPLICATIVO);
  20815.             de.setValues(servizioApplicativoList);
  20816.             de.setSelected(servizioApplicativo);
  20817.             dati.add(de);
  20818.            
  20819.         }else{
  20820.             if(addMsgServiziApplicativoNonDisponibili){
  20821.                 if(sizeAttuale>0){
  20822.                     this.pd.setMessage("Non esistono ulteriori servizi applicativi associabili alla trasformazione",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  20823.                 }
  20824.                 else{
  20825.                     this.pd.setMessage("Non esistono servizi applicativi associabili alla trasformazione",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  20826.                 }
  20827.                 this.pd.disableEditMode();
  20828.             }
  20829.         }

  20830.         return dati;
  20831.     }
  20832.    
  20833.     public List<DataElement> addPorteTrasformazioniSoggettoToDati(TipoOperazione tipoOp, List<DataElement> dati, String idTrasformazione, boolean fromList,
  20834.         String[] soggettiLabelList, String[] soggettiList, String soggetto, int sizeAttuale,
  20835.             boolean addMsgSoggettiNonDisponibili, boolean addTitle) {
  20836.        
  20837.         if(fromList) {
  20838.             DataElement de = new DataElement();
  20839.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_LIST);
  20840.             de.setType(DataElementType.HIDDEN);
  20841.             de.setValue(fromList+"");
  20842.             dati.add(de);
  20843.         }
  20844.        
  20845.         DataElement  de = new DataElement();
  20846.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  20847.         de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  20848.         de.setType(DataElementType.HIDDEN);
  20849.         de.setValue(idTrasformazione);
  20850.         dati.add(de);
  20851.            
  20852.         if(soggettiList!=null && soggettiList.length>0){
  20853.        
  20854.             if(addTitle) {
  20855.                   de = new DataElement();
  20856.                 de.setType(DataElementType.TITLE);
  20857.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_SOGGETTO);
  20858.                 dati.add(de);
  20859.             }
  20860.            
  20861.               de = new DataElement();
  20862.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  20863.             de.setType(DataElementType.SELECT);
  20864.             de.setName(CostantiControlStation.PARAMETRO_SOGGETTO);
  20865.             de.setLabels(soggettiLabelList);
  20866.             de.setValues(soggettiList);
  20867.             de.setSelected(soggetto);
  20868.             dati.add(de);
  20869.            
  20870.         }else{
  20871.             if(addMsgSoggettiNonDisponibili){
  20872.                 if(sizeAttuale>0){
  20873.                     this.pd.setMessage("Non esistono ulteriori soggetti associabili",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  20874.                 }
  20875.                 else{
  20876.                     this.pd.setMessage("Non esistono soggetti associabili",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  20877.                 }
  20878.                 this.pd.disableEditMode();
  20879.             }
  20880.         }

  20881.         return dati;
  20882.     }

  20883.     public List<DataElement> addPorteTrasformazioniServizioApplicativoAutorizzatiToDati(TipoOperazione tipoOp, List<DataElement> dati, String idTrasformazione, boolean fromList,
  20884.         String[] soggettiLabelList, String[] soggettiList, String soggetto, int sizeAttuale,
  20885.         Map<String,List<IDServizioApplicativoDB>> listServiziApplicativi, String sa,
  20886.             boolean addMsgApplicativiNonDisponibili) {
  20887.        
  20888.         if(fromList) {
  20889.             DataElement de = new DataElement();
  20890.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_LIST);
  20891.             de.setType(DataElementType.HIDDEN);
  20892.             de.setValue(fromList+"");
  20893.             dati.add(de);
  20894.         }
  20895.        
  20896.         if(soggettiList!=null && soggettiList.length>0 && listServiziApplicativi!=null && listServiziApplicativi.size()>0){
  20897.        
  20898.             DataElement de = new DataElement();
  20899.             de.setType(DataElementType.TITLE);
  20900.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_APPLICATIVO);
  20901.             dati.add(de);
  20902.            
  20903.             de = new DataElement();
  20904.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  20905.             de.setName(CostantiControlStation.PARAMETRO_ID_CONFIGURAZIONE_TRASFORMAZIONE);
  20906.             de.setType(DataElementType.HIDDEN);
  20907.             de.setValue(idTrasformazione);
  20908.             dati.add(de);
  20909.            
  20910.             de = new DataElement();
  20911.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_SOGGETTO);
  20912.             de.setName(CostantiControlStation.PARAMETRO_SOGGETTO);
  20913.             de.setValue(soggetto);
  20914.             if(this.core.isMultitenant()) {
  20915.                 de.setType(DataElementType.SELECT);
  20916.                 de.setLabels(soggettiLabelList);
  20917.                 de.setValues(soggettiList);
  20918.                 de.setSelected(soggetto);
  20919.                 de.setPostBack(true);
  20920.             }
  20921.             else {
  20922.                 de.setType(DataElementType.HIDDEN);
  20923.             }
  20924.             dati.add(de);
  20925.            
  20926.             List<IDServizioApplicativoDB> listSA = null;
  20927.             if(soggetto!=null && !"".equals(soggetto)) {
  20928.                 listSA = listServiziApplicativi.get(soggetto);
  20929.             }
  20930.            
  20931.             if(listSA!=null && !listSA.isEmpty()) {
  20932.                
  20933.                 String [] saValues = new String[listSA.size()];
  20934.                 String [] saLabels = new String[listSA.size()];
  20935.                 int index =0;
  20936.                 for (IDServizioApplicativoDB saObject : listSA) {
  20937.                     saValues[index] = saObject.getId().longValue()+"";
  20938.                     saLabels[index] = saObject.getNome();
  20939.                     index++;
  20940.                 }
  20941.                
  20942.                 de = new DataElement();
  20943.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  20944.                 de.setType(DataElementType.SELECT);
  20945.                 de.setName(CostantiControlStation.PARAMETRO_SERVIZIO_APPLICATIVO_AUTORIZZATO);
  20946.                 de.setLabels(saLabels);
  20947.                 de.setValues(saValues);
  20948.                 de.setSelected(sa);
  20949.                 dati.add(de);
  20950.                
  20951.             }
  20952.             else {
  20953.                 this.pd.setMessage("Non esistono applicativi associabili per il soggetto selezionato",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  20954.                 this.pd.disableEditMode();
  20955.             }
  20956.            
  20957.         }else{
  20958.             if(addMsgApplicativiNonDisponibili){
  20959.                 if(sizeAttuale>0){
  20960.                     this.pd.setMessage("Non esistono ulteriori applicativi associabili",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  20961.                 }
  20962.                 else{
  20963.                     this.pd.setMessage("Non esistono applicativi associabili",org.openspcoop2.web.lib.mvc.MessageType.INFO);
  20964.                 }
  20965.                 this.pd.disableEditMode();
  20966.             }
  20967.         }

  20968.         return dati;
  20969.     }
  20970.    
  20971.     public DataElement getHttpMethodDataElement(TipoOperazione tipoOperazione, String httpMethod, String label, String name, boolean addQualsiasi, String labelQualsiasi, String valueQualsiasi) {
  20972.         DataElement de = new DataElement();
  20973.        
  20974.         de.setLabel(label);
  20975.         de.setSelected(httpMethod);
  20976.         de.setType(DataElementType.SELECT);
  20977.         de.setName(name);
  20978.         de.setSize(this.getSize());
  20979.         de.setPostBack(true);
  20980.        
  20981.         HttpMethod[] httpMethods = HttpMethod.values();
  20982.         int numeroOptions = !addQualsiasi ? httpMethods.length : httpMethods.length + 1;
  20983.        
  20984.         String [] values = new String[numeroOptions];
  20985.         String [] labels = new String[numeroOptions];

  20986.         if(addQualsiasi) {
  20987.             labels[0] = labelQualsiasi;
  20988.             values[0] = valueQualsiasi;
  20989.         }
  20990.        
  20991.         for (int i = 0; i < httpMethods.length; i++) {
  20992.             HttpMethod method = httpMethods[i];
  20993.             labels[(addQualsiasi ? i+1 : i)] = method.name();
  20994.             values[(addQualsiasi ? i+1 : i)] = method.name();
  20995.         }
  20996.        
  20997.         de.setLabels(labels);
  20998.         de.setValues(values);
  20999.        
  21000.         return de;
  21001.     }
  21002.    
  21003.     public boolean checkAzioniUtilizzateErogazione(AccordiServizioParteSpecificaPorteApplicativeMappingInfo mappingInfo, String [] azioni) throws DriverControlStationException {
  21004.         List<MappingErogazionePortaApplicativa> list = mappingInfo.getListaMappingErogazione();
  21005.         return checkAzioniUtilizzateErogazione(list, azioni);
  21006.     }
  21007.     public boolean checkAzioniUtilizzateErogazione(List<MappingErogazionePortaApplicativa> list, String [] azioni) throws DriverControlStationException {
  21008.         if(azioni==null || azioni.length<=0) {
  21009.             return true;
  21010.         }
  21011.         if(list!=null && !list.isEmpty()) {
  21012.             for (MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa : list) {
  21013.                 IDPortaApplicativa idPA = mappingErogazionePortaApplicativa.getIdPortaApplicativa();
  21014.                 List<AttivazionePolicy> listPolicies = this.confCore.attivazionePolicyList(null, RuoloPolicy.APPLICATIVA, idPA.getNome());
  21015.                 List<ConfigurazioneAllarmeBean> listAllarmi = null;
  21016.                 if(this.confCore.isConfigurazioneAllarmiEnabled()) {
  21017.                     listAllarmi = this.confCore.allarmiList(new ConsoleSearch(true), RuoloPorta.APPLICATIVA, idPA.getNome());
  21018.                 }
  21019.                 try {
  21020.                     PortaApplicativa pa = this.porteApplicativeCore.getPortaApplicativa(idPA);
  21021.                     if(this._checkAzioniUtilizzate(listPolicies, listAllarmi, pa.getTrasformazioni(), azioni,
  21022.                             mappingErogazionePortaApplicativa.getDescrizione(), list.size())==false) {
  21023.                         return false;
  21024.                     }
  21025.                 }catch(Exception e) {
  21026.                     throw new DriverControlStationException(e.getMessage(),e);
  21027.                 }
  21028.             }
  21029.         }
  21030.        
  21031.         return true;
  21032.     }
  21033.    
  21034.     public boolean checkAzioniUtilizzateFruizione(AccordiServizioParteSpecificaFruitoriPorteDelegateMappingInfo mappingInfo, String [] azioni) throws DriverControlStationException {
  21035.         List<MappingFruizionePortaDelegata> list = mappingInfo.getListaMappingFruizione();
  21036.         return this.checkAzioniUtilizzateFruizione(list, azioni);
  21037.     }
  21038.     public boolean checkAzioniUtilizzateFruizione(List<MappingFruizionePortaDelegata> list, String [] azioni) throws DriverControlStationException {
  21039.         if(azioni==null || azioni.length<=0) {
  21040.             return true;
  21041.         }
  21042.         if(list!=null && !list.isEmpty()) {
  21043.             for (MappingFruizionePortaDelegata mappingFruizionePortaDelegata : list) {
  21044.                 IDPortaDelegata idPD = mappingFruizionePortaDelegata.getIdPortaDelegata();
  21045.                 List<AttivazionePolicy> listPolicies = this.confCore.attivazionePolicyList(null, RuoloPolicy.DELEGATA, idPD.getNome());
  21046.                 List<ConfigurazioneAllarmeBean> listAllarmi = null;
  21047.                 if(this.confCore.isConfigurazioneAllarmiEnabled()) {
  21048.                     listAllarmi = this.confCore.allarmiList(new ConsoleSearch(true), RuoloPorta.DELEGATA, idPD.getNome());
  21049.                 }
  21050.                 try {
  21051.                     PortaDelegata pd = this.porteDelegateCore.getPortaDelegata(idPD);
  21052.                     if(this._checkAzioniUtilizzate(listPolicies, listAllarmi, pd.getTrasformazioni(), azioni,
  21053.                             mappingFruizionePortaDelegata.getDescrizione(), list.size())==false) {
  21054.                         return false;
  21055.                     }
  21056.                 }catch(Exception e) {
  21057.                     throw new DriverControlStationException(e.getMessage(),e);
  21058.                 }
  21059.             }
  21060.         }
  21061.        
  21062.         return true;
  21063.     }
  21064.    
  21065.     private boolean _checkAzioniUtilizzate(List<AttivazionePolicy> listPolicies, List<ConfigurazioneAllarmeBean> listAllarmi, Trasformazioni trasformazioni, String [] azioni, String descrizioneGruppo, int sizeGruppi) {
  21066.        
  21067.         // verifico rate limiting
  21068.         if(listPolicies!=null && !listPolicies.isEmpty()) {
  21069.             for (AttivazionePolicy policy : listPolicies) {
  21070.                 if(policy.getFiltro()!=null && policy.getFiltro().getAzione()!=null) {
  21071.                     for (String azioneTmp : azioni) {
  21072.                        
  21073.                         String [] tmp = policy.getFiltro().getAzione().split(",");
  21074.                         if(tmp!=null && tmp.length>0) {
  21075.                             for (String az : tmp) {
  21076.                                 if(azioneTmp.equals(az)) {
  21077.                                     String nomePolicy = policy.getAlias();
  21078.                                     if(nomePolicy==null || "".equals(nomePolicy)) {
  21079.                                         nomePolicy = policy.getIdActivePolicy();
  21080.                                     }
  21081.                                     if(sizeGruppi>1) {
  21082.                                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_NON_ASSEGNABILE_RATE_LIMITING_GRUPPO,
  21083.                                                 azioneTmp, nomePolicy, descrizioneGruppo));
  21084.                                     }
  21085.                                     else {
  21086.                                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_NON_ASSEGNABILE_RATE_LIMITING,
  21087.                                                 azioneTmp, nomePolicy, descrizioneGruppo));
  21088.                                     }
  21089.                                     return false;  
  21090.                                 }
  21091.                             }
  21092.                         }
  21093.                        
  21094.                     }
  21095.                 }
  21096.             }
  21097.         }
  21098.        
  21099.         // verifico allarmi
  21100.         if(listAllarmi!=null && !listAllarmi.isEmpty()) {
  21101.             for (Allarme allarme : listAllarmi) {
  21102.                 if(allarme.getFiltro()!=null && allarme.getFiltro().getAzione()!=null) {
  21103.                     for (String azioneTmp : azioni) {
  21104.                        
  21105.                         String [] tmp = allarme.getFiltro().getAzione().split(",");
  21106.                         if(tmp!=null && tmp.length>0) {
  21107.                             for (String az : tmp) {
  21108.                                 if(azioneTmp.equals(az)) {
  21109.                                     String nomeAllarme = allarme.getAlias();
  21110.                                     if(nomeAllarme==null || "".equals(nomeAllarme)) {
  21111.                                         nomeAllarme = allarme.getNome();
  21112.                                     }
  21113.                                     if(sizeGruppi>1) {
  21114.                                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_NON_ASSEGNABILE_ALLARME_GRUPPO,
  21115.                                                 azioneTmp, nomeAllarme, descrizioneGruppo));
  21116.                                     }
  21117.                                     else {
  21118.                                         this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_NON_ASSEGNABILE_ALLARME,
  21119.                                                 azioneTmp, nomeAllarme, descrizioneGruppo));
  21120.                                     }
  21121.                                     return false;  
  21122.                                 }
  21123.                             }
  21124.                         }
  21125.                        
  21126.                     }
  21127.                 }
  21128.             }
  21129.         }
  21130.        
  21131.         // verifico trasformazioni
  21132.         List<TrasformazioneRegola> trasformazione = null;
  21133.         if(trasformazioni!=null) {
  21134.             trasformazione = trasformazioni.getRegolaList();
  21135.         }
  21136.         if(trasformazione!=null && !trasformazione.isEmpty()) {
  21137.             for (TrasformazioneRegola regola : trasformazione) {
  21138.                 if(regola.getApplicabilita()!=null && regola.getApplicabilita().sizeAzioneList()>0) {
  21139.                     List<String> azioniTrasf = regola.getApplicabilita().getAzioneList();
  21140.                     for (String azioneTmp : azioni) {
  21141.                         if(azioniTrasf.contains(azioneTmp)) {
  21142.                             String nomeRegola = regola.getNome();
  21143.                             if(sizeGruppi>1) {
  21144.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_NON_ASSEGNABILE_TRASFORMAZIONE_GRUPPO,
  21145.                                         azioneTmp, nomeRegola, descrizioneGruppo));
  21146.                             }
  21147.                             else {
  21148.                                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_NON_ASSEGNABILE_TRASFORMAZIONE,
  21149.                                         azioneTmp, nomeRegola, descrizioneGruppo));
  21150.                             }
  21151.                             return false;  
  21152.                         }
  21153.                     }
  21154.                 }
  21155.             }
  21156.         }
  21157.         return true;
  21158.     }
  21159.    
  21160.     public DataElement getHttpReturnCodeDataElement(String label, String name, String value, boolean required) {
  21161.         DataElement de = new DataElement();
  21162.         de.setLabel(label);
  21163.         de.setValue(value);
  21164.         de.setType(DataElementType.NUMBER);
  21165.         de.setName(name);
  21166.         de.setMinValue(200);
  21167.         de.setMaxValue(599);
  21168.         de.setSize(getSize());
  21169.         de.reloadMinValue(false);
  21170.         de.setRequired(required);
  21171.         return de;
  21172.     }
  21173.    
  21174.     public DataElement getHttpReturnCodeIntervallDataElement(String label,
  21175.             String nameMin, String nameMax,
  21176.             String valueMin, String valueMax,
  21177.             boolean required) {
  21178.         DataElement de = new DataElement();
  21179.         de.setLabel("&nbsp;");
  21180.         de.setValues(Arrays.asList(valueMin + "", valueMax + ""));
  21181.         de.setType(DataElementType.INTERVAL_NUMBER);
  21182.         de.setNames(Arrays.asList(nameMin, nameMax));
  21183.         de.setMinValue(200);
  21184.         de.setMaxValue(599);
  21185.         de.setSize(getSize());
  21186.         de.reloadMinValue(false);
  21187.         de.setRequired(required);
  21188.         return de;
  21189.     }
  21190.    
  21191.     public DataElement getVersionDataElement(String label, String name, String value, boolean required) {
  21192.         DataElement de = new DataElement();
  21193.         de.setLabel(label);
  21194.         de.setValue(value);
  21195.         de.setType(DataElementType.NUMBER);
  21196.         de.setName(name);
  21197.         de.setMinValue(1);
  21198.         de.setMaxValue(999);
  21199.         de.setSize(getSize());
  21200.         //de.reloadMinValue(false);
  21201.         de.setRequired(required);
  21202.         return de;
  21203.     }
  21204.    
  21205.     public String getUpperFirstChar(String value) {
  21206.         return (value.charAt(0)+"").toUpperCase() + value.substring(1);
  21207.     }
  21208.    
  21209.     public boolean isFunzionalitaProtocolloSupportataDalProtocollo(String protocollo, ServiceBinding serviceBinding,FunzionalitaProtocollo funzionalitaProtocollo)
  21210.             throws DriverRegistroServiziNotFound, DriverRegistroServiziException, DriverConfigurazioneException {
  21211.         if(serviceBinding == null) {
  21212.             List<ServiceBinding> serviceBindingListProtocollo = this.core.getServiceBindingListProtocollo(protocollo);
  21213.            
  21214.             boolean supportato = true;
  21215.             if(serviceBindingListProtocollo != null && serviceBindingListProtocollo.size() > 0) {
  21216.                 for (ServiceBinding serviceBinding2 : serviceBindingListProtocollo) {
  21217.                     boolean supportatoTmp = this.core.isFunzionalitaProtocolloSupportataDalProtocollo(protocollo, serviceBinding2, funzionalitaProtocollo);
  21218.                     supportato = supportato || supportatoTmp;
  21219.                 }
  21220.             }
  21221.             return supportato;
  21222.         } else {
  21223.             return this.core.isFunzionalitaProtocolloSupportataDalProtocollo(protocollo, serviceBinding, funzionalitaProtocollo);
  21224.         }
  21225.     }
  21226.    
  21227.     public List<DataElement>  addProprietaAutorizzazioneCustomToDati(List<DataElement> dati, TipoOperazione tipoOp, String nome, String valore) {

  21228.         DataElement de = new DataElement();
  21229.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_AUTORIZZAZIONE_CUSTOM_PROPERTIES);
  21230.         de.setType(DataElementType.TITLE);
  21231.         dati.add(de);
  21232.        
  21233.         de = new DataElement();
  21234.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  21235.         de.setValue(nome);
  21236.         if(TipoOperazione.ADD.equals(tipoOp)){
  21237.             de.setType(DataElementType.TEXT_EDIT);
  21238.             de.setRequired(true);
  21239.         }
  21240.         else{
  21241.             de.setType(DataElementType.TEXT);
  21242.         }
  21243.         de.setName(CostantiControlStation.PARAMETRO_NOME);
  21244.         de.setSize(this.getSize());
  21245.         dati.add(de);

  21246.         de = new DataElement();
  21247.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_VALORE);
  21248.         de.setName(CostantiControlStation.PARAMETRO_VALORE);
  21249.         this.core.getLockUtilities().lockProperty(de, valore);
  21250.         de.setRequired(true);
  21251.         de.setSize(this.getSize());
  21252.         dati.add(de);

  21253.         return dati;
  21254.     }
  21255.    
  21256.     public List<DataElement>  addProprietaAutenticazioneCustomToDati(List<DataElement> dati, TipoOperazione tipoOp, String nome, String valore) {

  21257.         DataElement de = new DataElement();
  21258.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_AUTENTICAZIONE_CUSTOM_PROPERTIES);
  21259.         de.setType(DataElementType.TITLE);
  21260.         dati.add(de);
  21261.        
  21262.         de = new DataElement();
  21263.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  21264.         de.setValue(nome);
  21265.         if(TipoOperazione.ADD.equals(tipoOp)){
  21266.             de.setType(DataElementType.TEXT_EDIT);
  21267.             de.setRequired(true);
  21268.         }
  21269.         else{
  21270.             de.setType(DataElementType.TEXT);
  21271.         }
  21272.         de.setName(CostantiControlStation.PARAMETRO_NOME);
  21273.         de.setSize(this.getSize());
  21274.         dati.add(de);

  21275.         de = new DataElement();
  21276.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_VALORE);
  21277.         de.setName(CostantiControlStation.PARAMETRO_VALORE);
  21278.         this.core.getLockUtilities().lockProperty(de, valore);
  21279.         de.setRequired(true);
  21280.         de.setSize(this.getSize());
  21281.         dati.add(de);

  21282.         return dati;
  21283.        
  21284.     }
  21285.    
  21286.    
  21287.     // ****** PROFILO MODI ******
  21288.    
  21289.     public boolean isProfiloModIPA(String protocollo) {
  21290.         return this.core.isProfiloModIPA(protocollo);
  21291.     }
  21292.    
  21293.     public boolean forceHttpsProfiloModiPA() {
  21294.         return true;
  21295.     }
  21296.     public void readModIConfiguration(BooleanNullable forceHttpsClient, BooleanNullable forcePDND, BooleanNullable forceOAuth,
  21297.             IDAccordo idAccordoParteComune, String portType,
  21298.             List<String> azioneGruppo) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  21299.         AccordoServizioParteComune aspc = this.apcCore.getAccordoServizioFull(idAccordoParteComune,false);
  21300.        
  21301.         // Sicurezza canale
  21302.         readForceHttpsClient(aspc, forceHttpsClient);
  21303.        
  21304.         // SorgenteToken
  21305.         String propertyNameSicurezzaRidefinita = CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_ACTION_MODE;
  21306.        
  21307.         BooleanNullable forcePDNDApi=null;
  21308.         BooleanNullable forceOAuthApi=null;
  21309.         if(azioneGruppo==null || azioneGruppo.isEmpty()) {
  21310.             readForceTokenPolicy(aspc.getProtocolPropertyList(), forcePDND, forceOAuth);
  21311.             if(forcePDND.getValue()!=null && forceOAuth.getValue()!=null) {
  21312.                 return;
  21313.             }
  21314.         }
  21315.         else {
  21316.             forcePDNDApi=BooleanNullable.NULL();
  21317.             forceOAuthApi=BooleanNullable.NULL();
  21318.             readForceTokenPolicy(aspc.getProtocolPropertyList(), forcePDNDApi, forceOAuthApi);
  21319.         }
  21320.        
  21321.         if(org.openspcoop2.core.registry.constants.ServiceBinding.SOAP.equals(aspc.getServiceBinding())) {
  21322.             readForceTokenPolicySoap(forcePDND, forceOAuth,
  21323.                     aspc, portType, azioneGruppo,
  21324.                     propertyNameSicurezzaRidefinita, forcePDNDApi, forceOAuthApi);
  21325.         }
  21326.         else {
  21327.             readForceTokenPolicyRest(forcePDND, forceOAuth,
  21328.                     aspc, azioneGruppo,
  21329.                     propertyNameSicurezzaRidefinita, forcePDNDApi, forceOAuthApi);
  21330.         }
  21331.        
  21332.         if(forcePDND.getValue()==null) {
  21333.             forcePDND.setValue(false);
  21334.         }
  21335.         if(forceOAuth.getValue()==null) {
  21336.             forceOAuth.setValue(false);
  21337.         }
  21338.     }
  21339.     private void readForceHttpsClient(AccordoServizioParteComune aspc, BooleanNullable forceHttpsClient) {
  21340.         String propertyName = CostantiDB.MODIPA_PROFILO_SICUREZZA_CANALE;
  21341.         for (ProtocolProperty pp : aspc.getProtocolPropertyList()) {
  21342.             if(pp.getName().equals(propertyName)) {
  21343.                 String value = pp.getValue();
  21344.                 if(CostantiDB.MODIPA_PROFILO_SICUREZZA_CANALE_VALUE_IDAC02.equals(value)) {
  21345.                     forceHttpsClient.setValue(true);
  21346.                     return;
  21347.                 }
  21348.                 break;
  21349.             }
  21350.         }
  21351.         forceHttpsClient.setValue(false);
  21352.     }
  21353.     private void readForceTokenPolicySoap(BooleanNullable forcePDND, BooleanNullable forceOAuth,
  21354.             AccordoServizioParteComune aspc, String portType, List<String> azioneGruppo,
  21355.             String propertyNameSicurezzaRidefinita, BooleanNullable forcePDNDApi, BooleanNullable forceOAuthApi) {
  21356.         if(portType!=null) {
  21357.             if(aspc.sizePortTypeList()>0) {
  21358.                 for (PortType pt : aspc.getPortTypeList()) {
  21359.                     if(portType.equals(pt.getNome()) &&
  21360.                         pt.sizeAzioneList()>0) {
  21361.                         readForceTokenPolicySoapOperation(forcePDND, forceOAuth,
  21362.                                 pt, azioneGruppo,
  21363.                                 propertyNameSicurezzaRidefinita, forcePDNDApi, forceOAuthApi);
  21364.                     }
  21365.                 }
  21366.             }
  21367.         }
  21368.         else {
  21369.             readForceTokenPolicySoapAzione(forcePDND, forceOAuth,
  21370.                     aspc, azioneGruppo,
  21371.                     propertyNameSicurezzaRidefinita, forcePDNDApi, forceOAuthApi);
  21372.         }
  21373.     }
  21374.     private void readForceTokenPolicySoapOperation(BooleanNullable forcePDND, BooleanNullable forceOAuth,
  21375.             PortType pt, List<String> azioneGruppo,
  21376.             String propertyNameSicurezzaRidefinita, BooleanNullable forcePDNDApi, BooleanNullable forceOAuthApi) {
  21377.         for (Operation op : pt.getAzioneList()) {
  21378.             if(azioneGruppo==null || azioneGruppo.contains(op.getNome())) {
  21379.                 readForceTokenPolicy(op.getProtocolPropertyList(), forcePDND, forceOAuth,  
  21380.                         propertyNameSicurezzaRidefinita, forcePDNDApi, forceOAuthApi);
  21381.                 if(forcePDND.getValue()!=null && forceOAuth.getValue()!=null) {
  21382.                     return;
  21383.                 }
  21384.             }
  21385.         }
  21386.     }
  21387.     private void readForceTokenPolicySoapAzione(BooleanNullable forcePDND, BooleanNullable forceOAuth,
  21388.             AccordoServizioParteComune aspc, List<String> azioneGruppo,
  21389.             String propertyNameSicurezzaRidefinita, BooleanNullable forcePDNDApi, BooleanNullable forceOAuthApi) {
  21390.         if(aspc.sizeAzioneList()>0) {
  21391.             for (Azione az : aspc.getAzioneList()) {
  21392.                 if(azioneGruppo==null || azioneGruppo.contains(az.getNome())) {
  21393.                     readForceTokenPolicy(az.getProtocolPropertyList(), forcePDND, forceOAuth,  
  21394.                             propertyNameSicurezzaRidefinita, forcePDNDApi, forceOAuthApi);
  21395.                     if(forcePDND.getValue()!=null && forceOAuth.getValue()!=null) {
  21396.                         return;
  21397.                     }
  21398.                 }
  21399.             }
  21400.         }
  21401.     }
  21402.     private void readForceTokenPolicyRest(BooleanNullable forcePDND, BooleanNullable forceOAuth,
  21403.             AccordoServizioParteComune aspc, List<String> azioneGruppo,
  21404.             String propertyNameSicurezzaRidefinita, BooleanNullable forcePDNDApi, BooleanNullable forceOAuthApi) {
  21405.         if(aspc.sizeResourceList()>0) {
  21406.             for (Resource res : aspc.getResource()) {
  21407.                 if(azioneGruppo==null || azioneGruppo.contains(res.getNome())) {
  21408.                     readForceTokenPolicy(res.getProtocolPropertyList(), forcePDND, forceOAuth,
  21409.                             propertyNameSicurezzaRidefinita, forcePDNDApi, forceOAuthApi);
  21410.                     if(forcePDND.getValue()!=null && forceOAuth.getValue()!=null) {
  21411.                         return;
  21412.                     }
  21413.                 }
  21414.             }
  21415.         }
  21416.     }
  21417.     private void readForceTokenPolicy(List<ProtocolProperty> list, BooleanNullable forcePDND, BooleanNullable forceOAuth,
  21418.             String propertyNameSicurezzaRidefinita, BooleanNullable forcePDNDApi, BooleanNullable forceOAuthApi) {
  21419.         if(list!=null && !list.isEmpty()) {
  21420.             boolean leggiSorgente = true;
  21421.             if(propertyNameSicurezzaRidefinita!=null) {
  21422.                 leggiSorgente = false;
  21423.                 for (ProtocolProperty pp : list) {
  21424.                     if(pp.getName().equals(propertyNameSicurezzaRidefinita)) {
  21425.                         if(CostantiDB.MODIPA_PROFILO_RIDEFINISCI.equals(pp.getValue())) {
  21426.                             leggiSorgente = true;
  21427.                         }
  21428.                         else {
  21429.                             if(forcePDNDApi!=null && forcePDNDApi.getValue()!=null) {
  21430.                                 forcePDND.setValue(forcePDNDApi.getValue());
  21431.                             }
  21432.                             if(forceOAuthApi!=null && forceOAuthApi.getValue()!=null) {
  21433.                                 forceOAuth.setValue(forceOAuthApi.getValue());
  21434.                             }
  21435.                         }
  21436.                     }
  21437.                 }
  21438.             }
  21439.             if(leggiSorgente) {
  21440.                 readForceTokenPolicy(list, forcePDND, forceOAuth);
  21441.             }
  21442.         }
  21443.     }
  21444.     private void readForceTokenPolicy(List<ProtocolProperty> list, BooleanNullable forcePDND, BooleanNullable forceOAuth) {
  21445.         String propertyNameSorgenteToken = CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH;
  21446.         for (ProtocolProperty pp : list) {
  21447.             if(pp.getName().equals(propertyNameSorgenteToken)) {
  21448.                 String value = pp.getValue();
  21449.                 setForceTokenPolicy(forcePDND, forceOAuth, value);
  21450.                 if(forcePDND.getValue()!=null && forceOAuth.getValue()!=null) {
  21451.                     break;
  21452.                 }
  21453.             }
  21454.         }
  21455.     }
  21456.     private void setForceTokenPolicy(BooleanNullable forcePDND, BooleanNullable forceOAuth, String value) {
  21457.         if(CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH_VALUE_PDND.equals(value)) {
  21458.             forcePDND.setValue(true);
  21459.         }
  21460.         else if(CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH_VALUE_OAUTH.equals(value)) {
  21461.             forceOAuth.setValue(true);
  21462.         }
  21463.     }

  21464.     public List<DataElement> addProxyPassConfigurazioneRegola(TipoOperazione tipoOp, List<DataElement> dati,
  21465.             String idRegolaS, String nome, String descrizione, String stato, boolean regExpr, String regolaText,
  21466.             String contestoEsterno, String baseUrl, String protocollo, List<String> protocolli, String soggetto,
  21467.             List<IDSoggetto> soggetti, String ruolo, String serviceBinding, boolean multiTenant) throws DriverControlStationException {
  21468.        
  21469.         DataElement dataElement = new DataElement();
  21470.         dataElement.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA);
  21471.         dataElement.setType(DataElementType.TITLE);
  21472.         dati.add(dataElement);
  21473.        
  21474.         DataElement de = new DataElement();
  21475.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_ID_REGOLA);
  21476.         de.setType(DataElementType.HIDDEN);
  21477.         de.setValue(idRegolaS);
  21478.         dati.add(de);
  21479.        
  21480.         // nome
  21481.         de = new DataElement();
  21482.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_NOME);
  21483.         de.setValue(nome);
  21484. //      if(TipoOperazione.ADD.equals(tipoOp)){
  21485.             de.setType(DataElementType.TEXT_EDIT);
  21486.             de.setRequired(true);
  21487. //      }
  21488. //      else{
  21489. //          de.setType(DataElementType.TEXT);
  21490. //      }
  21491.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_NOME);
  21492.         de.setSize(this.getSize());
  21493.         dati.add(de);
  21494.        
  21495.         // stato
  21496.         de = new DataElement();
  21497.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_STATO);
  21498.         String [] labelsStato = {StatoFunzionalita.ABILITATO.toString(), StatoFunzionalita.DISABILITATO.toString()};
  21499.         String [] valuesStato = {StatoFunzionalita.ABILITATO.toString(), StatoFunzionalita.DISABILITATO.toString()};
  21500.         de.setLabels(labelsStato);
  21501.         de.setValues(valuesStato);
  21502.         de.setType(DataElementType.SELECT);
  21503.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_STATO);
  21504.         de.setSelected(stato);
  21505.         dati.add(de);
  21506.        
  21507.         // descrizione
  21508.         de = new DataElement();
  21509.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_DESCRIZIONE);
  21510.         de.setValue(descrizione);
  21511.         de.setType(DataElementType.TEXT_AREA);
  21512.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_DESCRIZIONE);
  21513.         de.setSize(this.getSize());
  21514.         dati.add(de);
  21515.        
  21516.        
  21517.         dataElement = new DataElement();
  21518.         dataElement.setLabel(CostantiControlStation.LABEL_PROXY_PASS_REGOLA_CRITERI_APPLICABILITA);
  21519.         dataElement.setType(DataElementType.TITLE);
  21520.         dati.add(dataElement);
  21521.        
  21522.         // regExpr
  21523.         de = new DataElement();
  21524.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_REG_EXPR);
  21525.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_REG_EXPR);
  21526.         de.setType(DataElementType.CHECKBOX);
  21527.         de.setSelected(regExpr);
  21528.         de.setValue(regExpr+"");
  21529.         de.setPostBack(true);
  21530.         dati.add(de);
  21531.        
  21532.         // regola
  21533.         de = new DataElement();
  21534.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_REGOLA_TEXT);
  21535.         de.setValue(regolaText);
  21536.         de.setType(DataElementType.TEXT_EDIT);
  21537.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_REGOLA_TEXT);
  21538.         de.setSize(this.getSize());
  21539.         de.setRequired(true);
  21540.         DataElementInfo deInfo = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_REGOLA_TEXT);
  21541.         if(regExpr) {
  21542.             deInfo.setHeaderBody(CostantiControlStation.MESSAGGIO_INFO_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_REGOLA_TEXT_REGEXP);
  21543.         }
  21544.         else {
  21545.             deInfo.setHeaderBody(CostantiControlStation.MESSAGGIO_INFO_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_REGOLA_TEXT_STRINGA_LIBERA);
  21546.         }
  21547.         de.setInfo(deInfo);
  21548.        
  21549.         dati.add(de);
  21550.                
  21551.         // profilo
  21552.         de = new DataElement();
  21553.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_PROFILO);
  21554.        
  21555.         String [] labelsProfili = new String[protocolli.size() + 1];
  21556.         String [] valuesProfili = new String[protocolli.size() + 1];
  21557.        
  21558.         labelsProfili[0] = CostantiControlStation.LABEL_QUALSIASI;
  21559.         valuesProfili[0] = "";
  21560.        
  21561.         int i = 1;
  21562.         for (String protocolloS : protocolli) {
  21563.             labelsProfili[i] = _getLabelProtocollo(protocolloS);
  21564.             valuesProfili[i] = protocolloS;
  21565.             i++;
  21566.         }
  21567.                
  21568.         de.setLabels(labelsProfili);
  21569.         de.setValues(valuesProfili);
  21570.         de.setType(DataElementType.SELECT);
  21571.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_PROFILO);
  21572.         de.setPostBack(true);
  21573.         de.setSelected(protocollo);
  21574.         dati.add(de);
  21575.        
  21576.         // soggetto
  21577.         de = new DataElement();
  21578.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_SOGGETTO);
  21579.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_SOGGETTO);
  21580.         if(!"".equals(protocollo) && multiTenant) {
  21581.             String [] labelsSoggetti = new String[soggetti.size() + 1];
  21582.             String [] valuesSoggetti = new String[soggetti.size() + 1];
  21583.            
  21584.             labelsSoggetti[0] = CostantiControlStation.LABEL_QUALSIASI;
  21585.             valuesSoggetti[0] = "";
  21586.            
  21587.             i = 1;
  21588.             for (IDSoggetto idSoggetto : soggetti) {
  21589.                 labelsSoggetti[i] = _getLabelNomeSoggetto(idSoggetto);
  21590.                 valuesSoggetti[i] = idSoggetto.toString();
  21591.                 i++;
  21592.             }
  21593.            
  21594.             de.setLabels(labelsSoggetti);
  21595.             de.setValues(valuesSoggetti);
  21596.             de.setType(DataElementType.SELECT);
  21597.             de.setSelected(soggetto);
  21598.         } else {
  21599.             de.setType(DataElementType.HIDDEN);
  21600.             de.setValue(soggetto);
  21601.         }
  21602.         dati.add(de);
  21603.        
  21604.         // ruolo
  21605.         de = new DataElement();
  21606.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_RUOLO);
  21607.         de.setLabels(CostantiControlStation.SELECT_LABELS_PARAMETRO_PROXY_PASS_REGOLA_RUOLO);
  21608.         de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_PROXY_PASS_REGOLA_RUOLO);
  21609.         de.setType(DataElementType.SELECT);
  21610.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_RUOLO);
  21611.         de.setSelected(ruolo);
  21612.         dati.add(de);
  21613.        
  21614.         // serviceBinding
  21615.         de = new DataElement();
  21616.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_SERVICE_BINDING);
  21617.         de.setLabels(CostantiControlStation.SELECT_LABELS_PARAMETRO_PROXY_PASS_REGOLA_SERVICE_BINDING);
  21618.         de.setValues(CostantiControlStation.SELECT_VALUES_PARAMETRO_PROXY_PASS_REGOLA_SERVICE_BINDING);
  21619.         de.setType(DataElementType.SELECT);
  21620.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_SERVICE_BINDING);
  21621.         de.setSelected(serviceBinding);
  21622.         dati.add(de);

  21623.         dataElement = new DataElement();
  21624.         dataElement.setLabel(CostantiControlStation.LABEL_PROXY_PASS_REGOLA_NUOVA_URL);
  21625.         dataElement.setType(DataElementType.TITLE);
  21626.         dati.add(dataElement);
  21627.        
  21628.         StringBuilder sb = new StringBuilder();
  21629.         if(regExpr) {
  21630.             sb.append(CostantiControlStation.MESSAGGIO_INFO_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_EXPR_DATI_DINAMICI_REGXP);
  21631.         }
  21632.         CanaliConfigurazione canali = null;
  21633.         try {
  21634.             canali = this.confCore.getCanaliConfigurazione(false);
  21635.         }catch(Exception e) {
  21636.             throw new DriverControlStationException(e.getMessage(),e);
  21637.         }
  21638.         if(canali!=null && StatoFunzionalita.ABILITATO.equals(canali.getStato())) {
  21639.             sb.append(CostantiControlStation.MESSAGGIO_INFO_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_EXPR_DATI_DINAMICI_CANALE);
  21640.         }
  21641.         sb.append(CostantiControlStation.MESSAGGIO_INFO_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_EXPR_DATI_DINAMICI_TAG);
  21642.        
  21643.         // baseUrl
  21644.         de = new DataElement();
  21645.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_BASE_URL);
  21646.         de.setValue(baseUrl);
  21647.         de.setType(DataElementType.TEXT_EDIT);
  21648.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_BASE_URL);
  21649.         de.setSize(this.getSize());
  21650.         deInfo = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_BASE_URL);
  21651.         deInfo.setHeaderBody(CostantiControlStation.MESSAGGIO_INFO_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_BASE_URL);
  21652.         deInfo.setHeaderBody(deInfo.getHeaderBody()+sb.toString());
  21653.         de.setInfo(deInfo);
  21654.         dati.add(de);
  21655.        
  21656.         // contesto
  21657.         de = new DataElement();
  21658.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_CONTESTO_ESTERNO);
  21659.         de.setValue(contestoEsterno);
  21660.         de.setType(DataElementType.TEXT_EDIT);
  21661.         de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_CONTESTO_ESTERNO);
  21662.         de.setSize(this.getSize());
  21663.         de.setRequired(false);
  21664.         deInfo = new DataElementInfo(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_CONTESTO_ESTERNO);
  21665.         deInfo.setHeaderBody(CostantiControlStation.MESSAGGIO_INFO_PARAMETRO_CONFIGURAZIONE_PROXY_PASS_REGOLA_CONTESTO_ESTERNO);
  21666.         deInfo.setHeaderBody(deInfo.getHeaderBody()+sb.toString());
  21667.         de.setInfo(deInfo);
  21668.         dati.add(de);
  21669.                
  21670.         return dati;
  21671.     }
  21672.    
  21673.     public String getStatoConnettoriMultipliPortaApplicativa(PortaApplicativa paAssociata) throws DriverControlStationException, DriverControlStationNotFound {
  21674.        
  21675.         if(paAssociata==null) {
  21676.             throw new DriverControlStationException("Param paAssociata is null");
  21677.         }
  21678.        
  21679.         boolean connettoreMultiploEnabled = paAssociata.getBehaviour() != null;
  21680.         return connettoreMultiploEnabled ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString();
  21681.     }
  21682.    
  21683.     public String getNomiConnettoriMultipliPortaApplicativa(PortaApplicativa paAssociata) throws DriverControlStationException, DriverControlStationNotFound, NotFoundException {
  21684.         StringBuilder sbConnettoriMultipli = new StringBuilder();
  21685.        
  21686.         TipoBehaviour behaviourType = TipoBehaviour.toEnumConstant(paAssociata.getBehaviour().getNome());
  21687.         switch (behaviourType) {
  21688.         case CONSEGNA_LOAD_BALANCE:
  21689.             String loadBalanceStrategia = ConfigurazioneLoadBalancer.readLoadBalancerType(paAssociata.getBehaviour());
  21690.             LoadBalancerType type = LoadBalancerType.toEnumConstant(loadBalanceStrategia, true);
  21691.             sbConnettoriMultipli.append(behaviourType.getLabel()).append(" '");
  21692.             if(StickyUtils.isConfigurazioneSticky(paAssociata, ControlStationLogger.getPddConsoleCoreLogger())){
  21693.                 sbConnettoriMultipli.append(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_STICKY).append(" ");
  21694.             }
  21695.             sbConnettoriMultipli.append(type.getLabel()).append("'");
  21696.            
  21697.             boolean condizionale = ConditionalUtils.isConfigurazioneCondizionale(paAssociata, ControlStationLogger.getPddConsoleCoreLogger());
  21698.             if(condizionale) {
  21699.                 sbConnettoriMultipli.append(" ").append(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CONSEGNA_CONDIZIONALE);
  21700.             }
  21701.            
  21702.             break;
  21703.         case CONSEGNA_MULTIPLA:
  21704.             sbConnettoriMultipli.append(behaviourType.getLabel());
  21705.            
  21706.             condizionale = ConditionalUtils.isConfigurazioneCondizionale(paAssociata, ControlStationLogger.getPddConsoleCoreLogger());
  21707.             if(condizionale) {
  21708.                 sbConnettoriMultipli.append(" ").append(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CONSEGNA_CONDIZIONALE);
  21709.             }
  21710.            
  21711.             break;
  21712.         case CONSEGNA_CON_NOTIFICHE:
  21713.             sbConnettoriMultipli.append(behaviourType.getLabel());
  21714.            
  21715.             condizionale = ConditionalUtils.isConfigurazioneCondizionale(paAssociata, ControlStationLogger.getPddConsoleCoreLogger());
  21716.             if(condizionale) {
  21717.                 sbConnettoriMultipli.append(" ").append(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_NOTIFICHE_CONDIZIONALI);
  21718.             }
  21719.            
  21720.             break;
  21721.         case CONSEGNA_CONDIZIONALE:
  21722.             sbConnettoriMultipli.append(behaviourType.getLabel());
  21723.            
  21724.             break;
  21725.         case CUSTOM:
  21726.            
  21727.             String customLabel = paAssociata.getBehaviour().getNome();
  21728.             Plugin plugin = null;
  21729.             try {
  21730.                 plugin = this.confCore.getPlugin(TipoPlugin.BEHAVIOUR,customLabel, false);
  21731.             }catch(Throwable e) {
  21732.                 // ignore
  21733.             }
  21734.             if(plugin!=null) {
  21735.                 customLabel = plugin.getLabel();
  21736.             }
  21737.            
  21738.             sbConnettoriMultipli.append("Consegna Personalizzata '"+customLabel+"'");
  21739.             break;
  21740.         }
  21741.        
  21742.         return sbConnettoriMultipli.toString();
  21743.     }
  21744.    
  21745.     public String getToolTipConnettoriMultipliPortaApplicativa(PortaApplicativa paAssociata) throws DriverControlStationException, DriverControlStationNotFound {
  21746.         StringBuilder sbConnettoriMultipli = new StringBuilder();
  21747.         for (PortaApplicativaServizioApplicativo paSA : paAssociata.getServizioApplicativoList()) {
  21748.             if(sbConnettoriMultipli.length() >0)
  21749.                 sbConnettoriMultipli.append(", ");
  21750.             if(paSA.getDatiConnettore() == null) {
  21751.                 sbConnettoriMultipli.append(CostantiConfigurazione.NOME_CONNETTORE_DEFAULT);
  21752.             } else {
  21753.                 sbConnettoriMultipli.append(paSA.getDatiConnettore().getNome());
  21754.             }
  21755.         }
  21756.         return sbConnettoriMultipli.toString();
  21757.     }
  21758.    
  21759.     public List<DataElement> addInformazioniGruppiAsHiddenToDati(TipoOperazione tipoOp, List<DataElement> dati,
  21760.             String idTabGruppo, String idTabConnettoriMultipli, String accessoDaAPS, String connettoreAccessoDaGruppi, String connettoreRegistro, String connettoreAccessoDaListaConnettoriMultipli) {
  21761.        
  21762.         if(idTabGruppo != null) {
  21763.             DataElement de = new DataElement();
  21764.             de.setName(CostantiControlStation.PARAMETRO_ID_TAB);
  21765.             de.setType(DataElementType.HIDDEN);
  21766.             de.setValue(idTabGruppo);
  21767.             dati.add(de);
  21768.         }
  21769.        
  21770.         if(idTabConnettoriMultipli != null) {
  21771.             DataElement de = new DataElement();
  21772.             de.setName(CostantiControlStation.PARAMETRO_ID_CONN_TAB);
  21773.             de.setType(DataElementType.HIDDEN);
  21774.             de.setValue(idTabConnettoriMultipli);
  21775.             dati.add(de);
  21776.         }
  21777.        
  21778.         if(accessoDaAPS != null) {
  21779.             DataElement de = new DataElement();
  21780.             de.setName(CostantiControlStation.PARAMETRO_CONNETTORE_DA_LISTA_APS);
  21781.             de.setType(DataElementType.HIDDEN);
  21782.             de.setValue(accessoDaAPS);
  21783.             dati.add(de);
  21784.         }
  21785.        
  21786.         if(connettoreAccessoDaGruppi != null) {
  21787.             DataElement de = new DataElement();
  21788.             de.setName(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_GRUPPI);
  21789.             de.setType(DataElementType.HIDDEN);
  21790.             de.setValue(connettoreAccessoDaGruppi);
  21791.             dati.add(de);
  21792.         }
  21793.        
  21794.         if(connettoreRegistro != null) {
  21795.             DataElement de = new DataElement();
  21796.             de.setName(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_REGISTRO);
  21797.             de.setType(DataElementType.HIDDEN);
  21798.             de.setValue(connettoreRegistro);
  21799.             dati.add(de);
  21800.         }
  21801.        
  21802.         if(connettoreAccessoDaListaConnettoriMultipli != null) {
  21803.             DataElement de = new DataElement();
  21804.             de.setName(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_LISTA_CONNETTORI_MULTIPLI);
  21805.             de.setType(DataElementType.HIDDEN);
  21806.             de.setValue(connettoreAccessoDaListaConnettoriMultipli);
  21807.             dati.add(de);
  21808.         }
  21809.        
  21810.         return dati;
  21811.     }
  21812.    
  21813.     public boolean isConnettoreDefault(PortaApplicativaServizioApplicativo paSA) {
  21814.         return paSA.getDatiConnettore()!= null ? !paSA.getDatiConnettore().isNotifica() : true;
  21815.     }
  21816.    
  21817.     public String getLabelNomePortaApplicativaServizioApplicativo(PortaApplicativaServizioApplicativo paSA) {
  21818.         String nomePaSA = (paSA!=null && paSA.getDatiConnettore()!= null) ? paSA.getDatiConnettore().getNome() : CostantiConfigurazione.NOME_CONNETTORE_DEFAULT;
  21819.         return nomePaSA;
  21820.     }
  21821.    
  21822.     public int getIdxNuovoConnettoreMultiplo(PortaApplicativa pa) {
  21823.         int idxConfigurazione = 0;
  21824.         int listaMappingErogazioneSize = pa.sizeServizioApplicativoList();
  21825.        
  21826.         for (int i = 0; i < listaMappingErogazioneSize; i++) {
  21827.             PortaApplicativaServizioApplicativo paSA = pa.getServizioApplicativo(i);
  21828.             //if(!this.isConnettoreDefault(paSA)) {
  21829.             int idx = paSA.getNome().indexOf(ConnettoriCostanti.PARAMETRO_CONNETTORI_MULTIPLI_SAX_PREFIX);
  21830.             if(idx > -1) {
  21831.                 String idxTmp = paSA.getNome().substring(idx + ConnettoriCostanti.PARAMETRO_CONNETTORI_MULTIPLI_SAX_PREFIX.length());
  21832.                 int idxMax = -1;
  21833.                 try {
  21834.                     idxMax = Integer.parseInt(idxTmp);
  21835.                 }catch(Exception e) {
  21836.                     idxMax = 0;
  21837.                 }
  21838.                 idxConfigurazione = Math.max(idxConfigurazione, idxMax);
  21839.             }
  21840.             //}
  21841.         }
  21842.                
  21843.         return ( ++ idxConfigurazione);
  21844.     }

  21845.    
  21846.     public boolean allActionsRedefinedMappingErogazione(List<String> azioni, List<MappingErogazionePortaApplicativa> lista) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  21847.         // verifico se tutte le azioni sono definite in regole specifiche
  21848.         boolean all = true;
  21849.         if(azioni!=null && azioni.size()>0) {
  21850.             for (String azione : azioni) {
  21851.                 if(lista==null || lista.size()<=0) {
  21852.                     all  = false;
  21853.                     break;
  21854.                 }
  21855.                 boolean found = false;
  21856.                 for (MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa : lista) {
  21857.                     PortaApplicativa paAssociata = this.porteApplicativeCore.getPortaApplicativa(mappingErogazionePortaApplicativa.getIdPortaApplicativa());
  21858.                     if(paAssociata.getAzione() != null && paAssociata.getAzione().getAzioneDelegataList().contains(azione)) {
  21859.                         found = true;
  21860.                         break;
  21861.                     }
  21862.                 }
  21863.                 if(!found) {
  21864.                     all  = false;
  21865.                     break;
  21866.                 }
  21867.             }
  21868.         }
  21869.         return all;
  21870.     }
  21871.    
  21872.     public List<String> getAllActionsNotRedefinedMappingErogazione(List<String> azioni, List<MappingErogazionePortaApplicativa> lista) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  21873.         // verifico se tutte le azioni sono definite in regole specifiche
  21874.         List<String> l = new ArrayList<>();
  21875.         if(lista==null || lista.size()<=0) {
  21876.             return azioni;
  21877.         }
  21878.         l.addAll(azioni);
  21879.         for (MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa : lista) {
  21880.             PortaApplicativa paAssociata = this.porteApplicativeCore.getPortaApplicativa(mappingErogazionePortaApplicativa.getIdPortaApplicativa());
  21881.             if(paAssociata.getAzione() != null && !paAssociata.getAzione().getAzioneDelegataList().isEmpty()) {
  21882.                 for (String azPA : paAssociata.getAzione().getAzioneDelegataList()) {
  21883.                     l.remove(azPA);
  21884.                 }
  21885.             }
  21886.         }
  21887.         return l;
  21888.     }
  21889.    
  21890.     public boolean isSoapOneWay(PortaApplicativa portaApplicativa, MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa,
  21891.             AccordoServizioParteSpecifica asps, AccordoServizioParteComuneSintetico as, ServiceBinding serviceBinding)
  21892.                     throws DriverControlStationException, DriverRegistroServiziException, DriverConfigurazioneException, DriverConfigurazioneNotFound {
  21893.         boolean isSoapOneWay = false;
  21894.        
  21895.         if(serviceBinding.equals(ServiceBinding.SOAP)) {
  21896.             // controllo che tutte le azioni del gruppo siano oneway
  21897.             // se c'e' almeno un'azione non oneway visualizzo la sezione notifiche
  21898.             if(mappingErogazionePortaApplicativa.isDefault()) {
  21899.                 Map<String,String> azioni = null;
  21900.                 try{
  21901.                     azioni =this.porteApplicativeCore.getAzioniConLabel(asps, as, false, true, new ArrayList<>());
  21902.                 }catch(Exception e) {
  21903.                     throw new DriverControlStationException(e.getMessage(),e);
  21904.                 }
  21905.                 IDServizio idServizio2 = IDServizioFactory.getInstance().getIDServizioFromAccordo(asps);
  21906.                 List<MappingErogazionePortaApplicativa> lista = this.apsCore.mappingServiziPorteAppList(idServizio2,asps.getId(), null);
  21907.        
  21908.                 boolean allActionRedefined = false;
  21909.                 List<String> actionNonRidefinite = null;
  21910.        
  21911.                 List<String> azioniL = new ArrayList<>();
  21912.                 if(azioni != null && azioni.size() > 0)
  21913.                     azioniL.addAll(azioni.keySet());
  21914.                 allActionRedefined = this.allActionsRedefinedMappingErogazione(azioniL, lista);
  21915.                 if(!allActionRedefined) {
  21916.                     actionNonRidefinite = this.getAllActionsNotRedefinedMappingErogazione(azioniL, lista);
  21917.                     isSoapOneWay = this.porteApplicativeCore.azioniTutteOneway(asps, as, actionNonRidefinite);
  21918.                 } else {
  21919.                     isSoapOneWay = false;
  21920.                 }
  21921.             } else {
  21922.                 List<String> listaAzioni = portaApplicativa.getAzione()!= null ?  portaApplicativa.getAzione().getAzioneDelegataList() : new ArrayList<>();
  21923.                 isSoapOneWay = this.porteApplicativeCore.azioniTutteOneway(asps, as, listaAzioni);
  21924.             }
  21925.         } else {
  21926.             isSoapOneWay = false;
  21927.         }
  21928.        
  21929.         return isSoapOneWay;
  21930.     }

  21931.     public DataElement newDataElementVisualizzaInNuovoTab(DataElement deParam, String url, String tooltip ) {
  21932.            
  21933.         DataElement de = deParam;
  21934.         if(de==null)
  21935.             de = new DataElement();
  21936.        
  21937.         de.setUrl(url);
  21938.         de.setTarget(TargetType.BLANK);
  21939.         if(tooltip != null)
  21940.             de.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_VISUALIZZA_TOOLTIP_CON_PARAMETRO, tooltip));
  21941.         else  
  21942.             de.setToolTip(CostantiControlStation.ICONA_VISUALIZZA_TOOLTIP);
  21943.        
  21944.         de.setIcon(CostantiControlStation.ICONA_VISUALIZZA);
  21945.         de.setDisabilitaAjaxStatus();
  21946.         // link apri nuovo tab
  21947.         de.setVisualizzaLinkApriNuovaFinestra(true);
  21948.            
  21949.         return de;
  21950.     }
  21951.    
  21952.     public void setSecretPleaseCopy(String secret_password, String secret_user, boolean appId, String tipoAuth, OggettoDialogEnum oggettoDialog, String nome) {

  21953.         String nomeP = nome!=null ? " "+nome : "";
  21954.         String tipoOggetto = null;
  21955.         switch (oggettoDialog) {
  21956.         case UTENTE:
  21957.             tipoOggetto = "all'utente"+nomeP;
  21958.             break;
  21959.         case SOGGETTO:
  21960.             tipoOggetto = "al soggetto"+nomeP;
  21961.             break;
  21962.         case APPLICATIVO:
  21963.             tipoOggetto = "all'applicativo"+nomeP;
  21964.             break;
  21965.         case EROGAZIONE:
  21966.             tipoOggetto = "all'erogazione";
  21967.             break;
  21968.         case CONNETTORE_MULTIPLO:
  21969.             tipoOggetto = "al connettore"+nomeP+" dell'erogazione";
  21970.             break;
  21971.         }
  21972.        
  21973.         String header1= "";
  21974.         BodyElement utente = Dialog.newBodyElement();
  21975.         if(utente!=null) {
  21976.             utente.setVisualizzaCopyAction(true);
  21977.         }
  21978.         BodyElement password = Dialog.newBodyElement();
  21979.         if(password!=null) {
  21980.             password.setVisualizzaCopyAction(true);
  21981.         }
  21982.        
  21983.         if (ConnettoriCostanti.AUTENTICAZIONE_TIPO_BASIC.equals(tipoAuth)) {
  21984.             if(utente!=null) {
  21985.                 utente.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  21986.                 utente.setType(DataElementType.TEXT_EDIT);
  21987.                 utente.setValue(StringEscapeUtils.escapeHtml(secret_user));
  21988.                 utente.setTooltipCopyAction(MessageFormat.format(Costanti.TOOLTIP_ICONA_COPIA, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME));
  21989.             }
  21990.            
  21991.             if(password!=null) {
  21992.                 password.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  21993.                 password.setType(DataElementType.TEXT_EDIT);
  21994.                 password.setValue(StringEscapeUtils.escapeHtml(secret_password));
  21995.                 password.setTooltipCopyAction(MessageFormat.format(Costanti.TOOLTIP_ICONA_COPIA, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD));
  21996.             }
  21997.            
  21998.             header1 = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME+" e " + ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD + " generata" ;
  21999.         }
  22000.         else if (ConnettoriCostanti.AUTENTICAZIONE_TIPO_APIKEY.equals(tipoAuth)) {
  22001.             if(appId) {
  22002.                 if(utente!=null) {
  22003.                     utente.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID);
  22004.                     utente.setType(DataElementType.TEXT_EDIT);
  22005.                     utente.setValue(StringEscapeUtils.escapeHtml(secret_user));
  22006.                     utente.setTooltipCopyAction(MessageFormat.format(Costanti.TOOLTIP_ICONA_COPIA, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID));
  22007.                 }
  22008.             } else {
  22009.                 utente = null;
  22010.             }
  22011.            
  22012.             if(password!=null) {
  22013.                 password.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY);
  22014.                 password.setType(DataElementType.TEXT_AREA);
  22015.                 password.setValue(StringEscapeUtils.escapeHtml(secret_password));
  22016.                 password.setTooltipCopyAction(MessageFormat.format(Costanti.TOOLTIP_ICONA_COPIA, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY));
  22017.                 password.setCols(44);
  22018.             }
  22019.            
  22020.             header1 = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY + " generata" ;
  22021.             if(appId) {
  22022.                 header1 = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID+" e " + header1;
  22023.             }
  22024.         }
  22025.        
  22026.         boolean unaCredenziale = (ConnettoriCostanti.AUTENTICAZIONE_TIPO_APIKEY.equals(tipoAuth) && !appId);
  22027.         String singolare = unaCredenziale ? "a" : "e";
  22028.         String verbo = unaCredenziale ? "viene" : "vengono";
  22029.         String oggetto = unaCredenziale ? "la chiave" : "le credenziali";
  22030.         String intestazione = StringEscapeUtils.escapeHtml("Di seguito "+verbo+" riportat"+singolare+" "+oggetto+" associat"+singolare+" "+tipoOggetto+".")
  22031.                 +org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE+
  22032.                 StringEscapeUtils.escapeHtml("L'informazione viene visualizzata in questo avviso e successivamente non sarà più consultabile.");
  22033.         String attenzione = StringEscapeUtils.escapeHtml("Si prega di copiarl"+singolare+" e custodirl"+singolare+" attentamente.");
  22034.        
  22035.         Dialog dialog = new Dialog();
  22036.        
  22037.         dialog.setTitolo(Costanti.MESSAGE_TYPE_WARN_TITLE);
  22038.         dialog.setHeaderRiga1(header1);
  22039.         dialog.setHeaderRiga2(intestazione);
  22040.        
  22041.         if(utente!=null) {
  22042.             dialog.addBodyElement(utente);
  22043.         }
  22044.         if(password!=null) {
  22045.             dialog.addBodyElement(password);
  22046.         }

  22047.         dialog.setNotaFinale(attenzione);
  22048.        
  22049.        
  22050.         String[][] bottoni = {
  22051.                 { Costanti.LABEL_MONITOR_BUTTON_CHIUDI, "" }
  22052.                 };
  22053.        
  22054.         this.pd.setBottoni(bottoni);
  22055.        
  22056.         this.pd.setDialog(dialog);
  22057.        
  22058.     }
  22059.    
  22060.     public void addInUsoButtonVisualizzazioneClassica(List<DataElement> e, String titolo, String id, InUsoType inUsoType) {
  22061.         this.addInUsoButton(e, DataElementType.BUTTON, titolo, id, inUsoType,
  22062.                 CostantiControlStation.LABEL_IN_USO_TOOLTIP, Costanti.ICON_USO,
  22063.                 CostantiControlStation.LABEL_IN_USO_BODY_HEADER_RISULTATI,
  22064.                 true, true);
  22065.     }
  22066.     public void addInUsoButton(List<DataElement> e, String titolo, String id, InUsoType inUsoType) {
  22067.         this.addInUsoButton(e, DataElementType.IMAGE, titolo, id, inUsoType,
  22068.                 CostantiControlStation.LABEL_IN_USO_TOOLTIP, Costanti.ICON_USO,
  22069.                 CostantiControlStation.LABEL_IN_USO_BODY_HEADER_RISULTATI,
  22070.                 true, true);
  22071.     }
  22072.     public void addInUsoInfoButton(List<DataElement> e, String titolo, String id, InUsoType inUsoType) {
  22073.         this.addInUsoButton(e, DataElementType.IMAGE, titolo, id, inUsoType,
  22074.                 CostantiControlStation.LABEL_IN_USO_INFORMAZIONI_TOOLTIP, Costanti.ICON_USO_INFO,
  22075.                 CostantiControlStation.LABEL_IN_USO_BODY_HEADER_INFORMAZIONI,
  22076.                 true, true);
  22077.     }
  22078.     private void addInUsoButton(List<DataElement> e, DataElementType deType, String titolo, String id, InUsoType inUsoType,
  22079.             String tooltip, String icon, String headerRiga1,
  22080.             Boolean resizable, Boolean draggable) {
  22081.        
  22082.         ServletUtils.addInUsoButton(UtilsCostanti.SERVLET_NAME_INFORMAZIONI_UTILIZZO_OGGETTO, e, deType, titolo, id, inUsoType.toString(),
  22083.                 tooltip, icon, headerRiga1,
  22084.                 resizable, draggable, true);
  22085.        
  22086.     }
  22087.    
  22088.     public void addComandoInUsoButton(String titolo, String id, InUsoType inUsoType) {
  22089.          addComandoInUsoElementoButton(titolo, id, inUsoType,
  22090.                  CostantiControlStation.LABEL_IN_USO_TOOLTIP, Costanti.ICON_USO,
  22091.                     CostantiControlStation.LABEL_IN_USO_BODY_HEADER_RISULTATI,
  22092.                     true, true);
  22093.     }
  22094.     public void addComandoInUsoInfoButton(String titolo, String id, InUsoType inUsoType) {
  22095.          addComandoInUsoElementoButton(titolo, id, inUsoType,
  22096.                  CostantiControlStation.LABEL_IN_USO_INFORMAZIONI_TOOLTIP, Costanti.ICON_USO_INFO,
  22097.                     CostantiControlStation.LABEL_IN_USO_BODY_HEADER_INFORMAZIONI,
  22098.                     true, true);
  22099.     }
  22100.     private void addComandoInUsoElementoButton(String titolo, String id, InUsoType inUsoType,
  22101.             String tooltip, String icon, String headerRiga1,
  22102.             Boolean resizable, Boolean draggable) {
  22103.         this.pd.addComandoInUsoElementoButton(UtilsCostanti.SERVLET_NAME_INFORMAZIONI_UTILIZZO_OGGETTO,
  22104.                 titolo, id, inUsoType.toString(),
  22105.                 tooltip, icon, headerRiga1,
  22106.                 resizable, draggable);
  22107.     }
  22108.    
  22109.    
  22110.    
  22111.     public void addProprietaOggettoButtonVisualizzazioneClassica(List<DataElement> e, String titolo, String id, InUsoType inUsoType) {
  22112.         this.addProprietaOggettoButton(e, DataElementType.BUTTON, titolo, id, inUsoType,
  22113.                 CostantiControlStation.LABEL_PROPRIETA_OGGETTO_TOOLTIP, Costanti.ICON_USO,
  22114.                 CostantiControlStation.LABEL_PROPRIETA_OGGETTO_BODY_HEADER_RISULTATI,
  22115.                 true, true);
  22116.     }
  22117.     public void addProprietaOggettoButton(List<DataElement> e, String titolo, String id, InUsoType inUsoType) {
  22118.         this.addProprietaOggettoButton(e, DataElementType.IMAGE, titolo, id, inUsoType,
  22119.                 CostantiControlStation.LABEL_PROPRIETA_OGGETTO_TOOLTIP, Costanti.ICON_USO,
  22120.                 CostantiControlStation.LABEL_PROPRIETA_OGGETTO_BODY_HEADER_RISULTATI,
  22121.                 true, true);
  22122.     }
  22123.     public void addProprietaOggettoInfoButton(List<DataElement> e, String titolo, String id, InUsoType inUsoType) {
  22124.         this.addProprietaOggettoButton(e, DataElementType.IMAGE, titolo, id, inUsoType,
  22125.                 CostantiControlStation.LABEL_PROPRIETA_OGGETTO_INFORMAZIONI_TOOLTIP, Costanti.ICON_USO_INFO,
  22126.                 CostantiControlStation.LABEL_PROPRIETA_OGGETTO_BODY_HEADER_INFORMAZIONI,
  22127.                 true, true);
  22128.     }
  22129.     private void addProprietaOggettoButton(List<DataElement> e, DataElementType deType, String titolo, String id, InUsoType inUsoType,
  22130.             String tooltip, String icon, String headerRiga1,
  22131.             Boolean resizable, Boolean draggable) {
  22132.        
  22133.         ServletUtils.addInUsoButton(UtilsCostanti.SERVLET_NAME_PROPRIETA_OGGETTO, e, deType, titolo, id, inUsoType.toString(),
  22134.                 tooltip, icon, headerRiga1,
  22135.                 resizable, draggable, true);
  22136.        
  22137.     }
  22138.    
  22139.     public void addComandoProprietaOggettoButton(String titolo, String id, InUsoType inUsoType) {
  22140.          addComandoProprietaOggettoElementoButton(titolo, id, inUsoType,
  22141.                  CostantiControlStation.LABEL_PROPRIETA_OGGETTO_TOOLTIP, Costanti.ICON_USO,
  22142.                     CostantiControlStation.LABEL_PROPRIETA_OGGETTO_BODY_HEADER_RISULTATI,
  22143.                     true, true);
  22144.     }
  22145.     public void addComandoProprietaOggettoInfoButton(String titolo, String id, InUsoType inUsoType) {
  22146.          addComandoProprietaOggettoElementoButton(titolo, id, inUsoType,
  22147.                  CostantiControlStation.LABEL_PROPRIETA_OGGETTO_INFORMAZIONI_TOOLTIP, Costanti.ICON_USO_INFO,
  22148.                     CostantiControlStation.LABEL_PROPRIETA_OGGETTO_BODY_HEADER_INFORMAZIONI,
  22149.                     true, true);
  22150.     }
  22151.     private void addComandoProprietaOggettoElementoButton(String titolo, String id, InUsoType inUsoType,
  22152.             String tooltip, String icon, String headerRiga1,
  22153.             Boolean resizable, Boolean draggable) {
  22154.         this.pd.addComandoInUsoElementoButton(UtilsCostanti.SERVLET_NAME_PROPRIETA_OGGETTO,
  22155.                 titolo, id, inUsoType.toString(),
  22156.                 tooltip, icon, headerRiga1,
  22157.                 resizable, draggable);
  22158.     }
  22159.    
  22160.     public void addComandoResetCacheElementoButton(boolean utilizzaServizioCondiviso, String servletName, List<Parameter> parameters, InUsoType inUsoType) {
  22161.         if(utilizzaServizioCondiviso) {
  22162.             String titoloModale = "";
  22163.             String bodyModale = "";
  22164.             this.addComandoResetCacheCheUtilizzaServizioCondivisoButton(titoloModale, bodyModale, UtilsCostanti.SERVLET_NAME_CACHE_MANAGER, parameters, inUsoType);
  22165.         } else {
  22166.             this.pd.addComandoResetCacheElementoButton(servletName, parameters);
  22167.         }
  22168.     }
  22169.    
  22170.     public void addComandoResetCacheCheUtilizzaServizioCondivisoButton(String titoloModale, String bodyModale, String servletName, List<Parameter> parameters, InUsoType inUsoType) {
  22171.         this.pd.addComandoElementoCheUtilizzaServizioCondivisoButton(Costanti.ICONA_RESET_CACHE_ELEMENTO, Costanti.ICONA_RESET_CACHE_ELEMENTO_TOOLTIP, titoloModale, bodyModale, servletName, parameters, inUsoType.toString());        
  22172.        
  22173.     }
  22174.    
  22175.     public void addComandoVerificaCertificatiElementoButton(boolean utilizzaServizioCondiviso, String servletName, List<Parameter> parameters, InUsoType inUsoType) {
  22176.         if(utilizzaServizioCondiviso) {
  22177.             String titoloModale = "";
  22178.             String bodyModale = "";
  22179.             this.addComandoVerificaCertificatiCheUtilizzaServizioCondivisoButton(titoloModale, bodyModale, UtilsCostanti.SERVLET_NAME_VERIFICA_CERTIFICATI, parameters, inUsoType);
  22180.         } else {
  22181.             this.pd.addComandoVerificaCertificatiElementoButton(servletName, parameters);
  22182.         }
  22183.     }
  22184.    
  22185.     public void addComandoVerificaCertificatiCheUtilizzaServizioCondivisoButton(String titoloModale, String bodyModale, String servletName, List<Parameter> parameters, InUsoType inUsoType) {
  22186.         this.pd.addComandoElementoCheUtilizzaServizioCondivisoButton(Costanti.ICONA_VERIFICA_CERTIFICATI, Costanti.ICONA_VERIFICA_CERTIFICATI_TOOLTIP, titoloModale, bodyModale, servletName, parameters, inUsoType.toString());        
  22187.     }
  22188.    
  22189.     protected boolean existsProprietaOggetto(org.openspcoop2.core.registry.beans.ProprietaOggettoSintetico p, String descrizione) {
  22190.         return (p!=null &&
  22191.                     (
  22192.                             (p.getUtenteRichiedente()!=null && StringUtils.isNotEmpty(p.getUtenteRichiedente()))
  22193.                             ||
  22194.                             p.getDataCreazione()!=null
  22195.                             ||
  22196.                             (p.getUtenteUltimaModifica()!=null && StringUtils.isNotEmpty(p.getUtenteUltimaModifica()))  
  22197.                             ||
  22198.                             p.getDataUltimaModifica()!=null
  22199.                     )
  22200.                 )
  22201.                 ||
  22202.                 (descrizione!=null && StringUtils.isNotEmpty(descrizione));
  22203.     }
  22204.     protected boolean existsProprietaOggetto(org.openspcoop2.core.registry.ProprietaOggetto p, String descrizione) {
  22205.         return (p!=null &&
  22206.                 (
  22207.                         (p.getUtenteRichiedente()!=null && StringUtils.isNotEmpty(p.getUtenteRichiedente()))
  22208.                         ||
  22209.                         p.getDataCreazione()!=null
  22210.                         ||
  22211.                         (p.getUtenteUltimaModifica()!=null && StringUtils.isNotEmpty(p.getUtenteUltimaModifica()))  
  22212.                         ||
  22213.                         p.getDataUltimaModifica()!=null
  22214.                 )
  22215.             )
  22216.             ||
  22217.             (descrizione!=null && StringUtils.isNotEmpty(descrizione));
  22218.     }
  22219.     protected boolean existsProprietaOggetto(org.openspcoop2.core.config.ProprietaOggetto p, String descrizione) {
  22220.         return (p!=null &&
  22221.                 (
  22222.                         (p.getUtenteRichiedente()!=null && StringUtils.isNotEmpty(p.getUtenteRichiedente()))
  22223.                         ||
  22224.                         p.getDataCreazione()!=null
  22225.                         ||
  22226.                         (p.getUtenteUltimaModifica()!=null && StringUtils.isNotEmpty(p.getUtenteUltimaModifica()))  
  22227.                         ||
  22228.                         p.getDataUltimaModifica()!=null
  22229.                 )
  22230.             )
  22231.             ||
  22232.             (descrizione!=null && StringUtils.isNotEmpty(descrizione));
  22233.     }
  22234.    
  22235.    
  22236.    
  22237.     public void addComandoVerificaCertificatiButton(List<DataElement> e, String nomeElementoSuCuiEffettuareLaVerifica, String servletName, List<Parameter> parameters) {
  22238.         if(parameters == null) {
  22239.             parameters = new ArrayList<>();
  22240.         }

  22241.         if(nomeElementoSuCuiEffettuareLaVerifica!=null) {
  22242.             // nop
  22243.         }
  22244.         this.addAzioneButton(e, DataElementType.IMAGE,  CostantiControlStation.ICONA_VERIFICA_CERTIFICATI_TOOLTIP,
  22245. //              MessageFormat.format(Costanti.ICONA_RESET_CACHE_ELEMENTO_TOOLTIP_CON_PARAMETRO, nomeElementoSuCuiEffettuareLaVerifica),
  22246.                 CostantiControlStation.ICONA_VERIFICA_CERTIFICATI, servletName,parameters);
  22247.     }
  22248.    
  22249.     public void addComandoResetCacheButton(List<DataElement> e, String nomeElementoSuCuiEffettuareIlReset, String servletName, List<Parameter> parameters) {
  22250.         if(parameters == null) {
  22251.             parameters = new ArrayList<>();
  22252.         }
  22253.        
  22254.         parameters.add(new Parameter(CostantiControlStation.PARAMETRO_ELIMINA_ELEMENTO_DALLA_CACHE, "true"));
  22255.        
  22256.         if(nomeElementoSuCuiEffettuareIlReset!=null) {
  22257.             // nop
  22258.         }
  22259.         this.addAzioneButton(e, DataElementType.IMAGE,  Costanti.ICONA_RESET_CACHE_ELEMENTO_TOOLTIP,
  22260. //              MessageFormat.format(Costanti.ICONA_RESET_CACHE_ELEMENTO_TOOLTIP_CON_PARAMETRO, nomeElementoSuCuiEffettuareIlReset),
  22261.                 Costanti.ICONA_RESET_CACHE_ELEMENTO, servletName,parameters);
  22262.     }
  22263.    
  22264.     public void addVerificaCertificatiButton(List<DataElement> e, String servletName, List<Parameter> parameters) {
  22265.         this.addAzioneButton(e, DataElementType.IMAGE,
  22266.                 MessageFormat.format(CostantiControlStation.ICONA_VERIFICA_TOOLTIP_CON_PARAMETRO, CostantiControlStation.LABEL_CERTIFICATI.toLowerCase()),
  22267.                 CostantiControlStation.ICONA_VERIFICA_CERTIFICATI, servletName,parameters);
  22268.     }
  22269.    
  22270.     public void addVerificaConnettivitaButton(List<DataElement> e, String servletName, List<Parameter> parameters) {
  22271.         this.addAzioneButton(e, DataElementType.IMAGE,
  22272.                 MessageFormat.format(CostantiControlStation.ICONA_VERIFICA_TOOLTIP_CON_PARAMETRO, CostantiControlStation.LABEL_CONFIGURAZIONE_CONNETTIVITA.toLowerCase()),
  22273.                 CostantiControlStation.ICONA_VERIFICA, servletName,parameters);
  22274.     }
  22275.    
  22276.     protected void addAzioneButton(List<DataElement> e, DataElementType deType, String tooltip, String icon, String servletName, List<Parameter> parameters) {
  22277.         DataElement de = new DataElement();
  22278.         de.setType(deType);
  22279.         de.setToolTip(tooltip);
  22280.         if(parameters != null && !parameters.isEmpty()) {
  22281.             de.setUrl(servletName, parameters.toArray(new Parameter[parameters.size()]));
  22282.         } else {
  22283.             de.setUrl(servletName);
  22284.         }
  22285.         de.setIcon(icon);
  22286.        
  22287.         e.add(de);
  22288.     }
  22289.    
  22290.     public void addCanaleToDati(List<DataElement> dati, TipoOperazione tipoOperazione, String canaleStato, String canale, String canaleAPI,
  22291.             List<CanaleConfigurazione> canaleList, boolean gestioneCanaliEnabled) throws DriverConfigurazioneNotFound {
  22292.         this.addCanaleToDati(dati, tipoOperazione, canaleStato, canale, canaleAPI, canaleList, gestioneCanaliEnabled, true);
  22293.     }
  22294.    
  22295.     public void addCanaleToDati(List<DataElement> dati, TipoOperazione tipoOperazione, String canaleStato, String canale, String canaleAPI,
  22296.             List<CanaleConfigurazione> canaleList, boolean gestioneCanaliEnabled, boolean addTitle) throws DriverConfigurazioneNotFound {
  22297.         DataElement de;
  22298.         // canale
  22299.         if(gestioneCanaliEnabled) {
  22300.             if(addTitle) {
  22301.                 DataElement dataElement = new DataElement();
  22302.                 dataElement.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_CANALE);
  22303.                 dataElement.setType(DataElementType.TITLE);
  22304.                 dati.add(dataElement);
  22305.             }
  22306.            
  22307.             de = new DataElement();
  22308.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_CANALE_STATO);
  22309.             de.setValues(CostantiControlStation.VALUES_PARAMETRO_CONFIGURAZIONE_CANALI_CANALE_STATO);
  22310.            
  22311.             List<String> labelsCanaleStato = new ArrayList<>();
  22312.            
  22313.             CanaleConfigurazione canaleConfigurazioneDefault = getCanaleDefault(canaleList);
  22314.            
  22315.             String nomeCanaleDefault = MessageFormat.format(CostantiControlStation.LABEL_DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CANALI_CANALE_STATO_DEFAULT, canaleConfigurazioneDefault.getNome());
  22316.             if(canaleAPI != null) {
  22317.                 nomeCanaleDefault = MessageFormat.format(CostantiControlStation.LABEL_DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CANALI_CANALE_STATO_DEFAULT_API, canaleAPI);
  22318.             }
  22319.             labelsCanaleStato.add(nomeCanaleDefault);
  22320.             labelsCanaleStato.add(CostantiControlStation.LABEL_DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_CANALI_CANALE_STATO_RIDEFINITO);
  22321.            
  22322.             de.setLabels(labelsCanaleStato);
  22323.             de.setType(DataElementType.SELECT);
  22324.             de.setSelected(canaleStato);
  22325.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CANALI_CANALE_STATO);
  22326.             de.setSize(this.getSize());
  22327.             de.setPostBack(true);
  22328.             dati.add(de);
  22329.            
  22330.             if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CANALE_STATO_RIDEFINITO.equals(canaleStato)) {
  22331.                 de = new DataElement();
  22332.                 de.setLabel(""); //(AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_CANALE);
  22333.                 List<String> canaliListValues = canaleList.stream().map(CanaleConfigurazione::getNome).collect(Collectors.toList());
  22334.                 de.setValues(canaliListValues);
  22335.                 de.setLabels(canaliListValues);
  22336.                 de.setType(DataElementType.SELECT);
  22337.                 de.setSelected(canale);
  22338.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CANALI_CANALE);
  22339.                 de.setSize(this.getSize());
  22340.                 dati.add(de);
  22341.             }
  22342.         }
  22343.     }
  22344.    
  22345.     public void addCanaleToDatiAsHidden(List<DataElement> dati, TipoOperazione tipoOperazione, String canaleStato, String canale, boolean gestioneCanaliEnabled) {
  22346.         DataElement de;
  22347.         // canale
  22348.         if(gestioneCanaliEnabled) {
  22349.             de = new DataElement();
  22350.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_CANALE_STATO);
  22351.             de.setType(DataElementType.HIDDEN);
  22352.             de.setValue(canaleStato);
  22353.             de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CANALI_CANALE_STATO);
  22354.             de.setSize(this.getSize());
  22355.             dati.add(de);
  22356.            
  22357.             if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CANALE_STATO_RIDEFINITO.equals(canaleStato)) {
  22358.                 de = new DataElement();
  22359.                 de.setLabel(""); //(AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_CANALE);
  22360.                 de.setType(DataElementType.HIDDEN);
  22361.                 de.setValue(canale);
  22362.                 de.setName(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CANALI_CANALE);
  22363.                 de.setSize(this.getSize());
  22364.                 dati.add(de);
  22365.             }
  22366.         }
  22367.     }
  22368.    
  22369.     public boolean canaleCheckData(String canaleStato, String canale, boolean gestioneCanaliEnabled) throws DriverControlStationException {
  22370.         // validazione canale
  22371.         if(gestioneCanaliEnabled) {
  22372.             if(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CANALE_STATO_RIDEFINITO.equals(canaleStato)) {
  22373.                 if(this.checkNCName(canale, CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_CANALI_CANALE)==false){
  22374.                     return false;
  22375.                 }
  22376.             }
  22377.         }
  22378.        
  22379.         return true;
  22380.     }
  22381.    
  22382.     public void addCustomFieldSearchForm(TipoPlugin tipoPlugin,
  22383.             String ruolo, // applicativa/delegata o richiesta/risposta a seconda del tipo di plugin
  22384.             String fase,
  22385.             String nomeParametroSelezioneTipo,
  22386.             String nomeParametro, String label, String value, boolean hidden, List<DataElement> dati,
  22387.             boolean postBack_viaPOST) throws DriverControlStationException {
  22388.         addCustomField(tipoPlugin,
  22389.                 ruolo,
  22390.                 fase,
  22391.                 nomeParametroSelezioneTipo,
  22392.                 nomeParametro, label,
  22393.                 value, null, false,
  22394.                 hidden, dati,
  22395.                 postBack_viaPOST, false, null, null, true, null, null);
  22396.     }
  22397.    
  22398.     public void addCustomField(TipoPlugin tipoPlugin,
  22399.             String ruolo, // applicativa/delegata o richiesta/risposta a seconda del tipo di plugin
  22400.             String fase,
  22401.             String nomeParametroSelezioneTipo,
  22402.             String nomeParametro, String label, String value, boolean hidden, List<DataElement> dati,
  22403.             boolean postBack_viaPOST) throws DriverControlStationException {
  22404.         this.addCustomFieldConValoreDefault(tipoPlugin,
  22405.                 ruolo,
  22406.                 fase,
  22407.                 nomeParametroSelezioneTipo,
  22408.                 nomeParametro, label,
  22409.                 value,
  22410.                 hidden, dati,
  22411.                 postBack_viaPOST, null);
  22412.     }
  22413.    
  22414.     public void addCustomFieldConValoreDefault(TipoPlugin tipoPlugin,
  22415.             String ruolo, // applicativa/delegata o richiesta/risposta a seconda del tipo di plugin
  22416.             String fase,
  22417.             String nomeParametroSelezioneTipo,
  22418.             String nomeParametro, String label, String value, boolean hidden, List<DataElement> dati,
  22419.             boolean postBack_viaPOST, String valoreDefault) throws DriverControlStationException {
  22420.         addCustomField(tipoPlugin,
  22421.                 ruolo,
  22422.                 fase,
  22423.                 nomeParametroSelezioneTipo,
  22424.                 nomeParametro, label,
  22425.                 value, null, false,
  22426.                 hidden, dati,
  22427.                 postBack_viaPOST, false, null, null, false, valoreDefault, null);
  22428.     }
  22429.     public void addCustomFieldConValoriDaEscludere(TipoPlugin tipoPlugin,
  22430.             String ruolo, // applicativa/delegata o richiesta/risposta a seconda del tipo di plugin
  22431.             String fase,
  22432.             String nomeParametroSelezioneTipo,
  22433.             String nomeParametro, String label, String value, boolean hidden, List<DataElement> dati,
  22434.             boolean postBack_viaPOST, List<String> listaValuesDaEscludere, String messaggioErroreValoriDisponibiliTerminati) throws DriverControlStationException {
  22435.         this.addCustomFieldConValoriDaEscludereConValoreDefault(tipoPlugin,ruolo,fase,nomeParametroSelezioneTipo,nomeParametro, label,
  22436.                 value, hidden, dati,postBack_viaPOST, listaValuesDaEscludere, messaggioErroreValoriDisponibiliTerminati, null);
  22437.     }
  22438.     public void addCustomFieldConValoriDaEscludereConValoreDefault(TipoPlugin tipoPlugin,
  22439.             String ruolo, // applicativa/delegata o richiesta/risposta a seconda del tipo di plugin
  22440.             String fase,
  22441.             String nomeParametroSelezioneTipo,
  22442.             String nomeParametro, String label, String value, boolean hidden, List<DataElement> dati,
  22443.             boolean postBack_viaPOST, List<String> listaValuesDaEscludere, String messaggioErroreValoriDisponibiliTerminati, String valoreDefault) throws DriverControlStationException {
  22444.         addCustomField(tipoPlugin,
  22445.                 ruolo,
  22446.                 fase,
  22447.                 nomeParametroSelezioneTipo,
  22448.                 nomeParametro, label,
  22449.                 value, null, false,
  22450.                 hidden, dati,
  22451.                 postBack_viaPOST, true, listaValuesDaEscludere, messaggioErroreValoriDisponibiliTerminati,false, valoreDefault, null);
  22452.     }
  22453.    
  22454.     public void addMultiSelectCustomField(TipoPlugin tipoPlugin,
  22455.             String ruolo, // applicativa/delegata o richiesta/risposta a seconda del tipo di plugin
  22456.             String fase,
  22457.             String nomeParametroSelezioneTipo,
  22458.             String nomeParametro, String label, String [] value, boolean hidden, List<DataElement> dati,
  22459.             boolean postBack_viaPOST) throws DriverControlStationException {
  22460.         addMultiSelectCustomFieldConValoreDefault(tipoPlugin,
  22461.                 ruolo,
  22462.                 fase,
  22463.                 nomeParametroSelezioneTipo,
  22464.                 nomeParametro, label,
  22465.                 value,
  22466.                 hidden, dati,
  22467.                 postBack_viaPOST, null);
  22468.     }
  22469.    
  22470.     public void addMultiSelectCustomFieldConValoreDefault(TipoPlugin tipoPlugin,
  22471.             String ruolo, // applicativa/delegata o richiesta/risposta a seconda del tipo di plugin
  22472.             String fase,
  22473.             String nomeParametroSelezioneTipo,
  22474.             String nomeParametro, String label, String [] value, boolean hidden, List<DataElement> dati,
  22475.             boolean postBack_viaPOST, String [] valoriDefault) throws DriverControlStationException {
  22476.         addCustomField(tipoPlugin,
  22477.                 ruolo,
  22478.                 fase,
  22479.                 nomeParametroSelezioneTipo,
  22480.                 nomeParametro, label,
  22481.                 null, value, true,
  22482.                 hidden, dati,
  22483.                 postBack_viaPOST, false, null, null, false, null, valoriDefault);
  22484.     }
  22485.     private void addCustomField(TipoPlugin tipoPlugin,
  22486.             String ruolo, // applicativa/delegata o richiesta/risposta a seconda del tipo di plugin (o anche configurazione per gli allarmi)
  22487.             String fase,
  22488.             String nomeParametroSelezioneTipo,
  22489.             String nomeParametro, String label,
  22490.             String value, String [] multiValue, boolean multiSelect,
  22491.             boolean hidden, List<DataElement> dati,
  22492.             boolean postBack_viaPOST, boolean mostraSempreLabel, List<String> listaValuesDaEscludere,
  22493.             String messaggioErroreValoriDisponibiliTerminati, boolean isSearch, String valoreDefault, String[] valoriDefault) throws DriverControlStationException {
  22494.        
  22495.         List<String> values = new ArrayList<>();
  22496.         List<String> labels = new ArrayList<>();
  22497.         String note = null;
  22498.        
  22499.         if( this.confCore.isConfigurazionePluginsEnabled() ) {
  22500.             ConsoleSearch ricerca = new ConsoleSearch(true);
  22501.             ricerca.addFilter(Liste.CONFIGURAZIONE_PLUGINS_CLASSI,  Filtri.FILTRO_TIPO_PLUGIN_CLASSI, tipoPlugin.toString());
  22502.             switch (tipoPlugin) {
  22503.             case AUTENTICAZIONE:
  22504.             case AUTORIZZAZIONE:
  22505.             case AUTORIZZAZIONE_CONTENUTI:
  22506.             case INTEGRAZIONE:
  22507.                 if(ruolo!=null && !"".equals(ruolo)) {
  22508.                     ricerca.addFilter(Liste.CONFIGURAZIONE_PLUGINS_CLASSI,  Filtri.FILTRO_RUOLO_NOME, ruolo);
  22509.                 }
  22510.                 break;
  22511.             case SERVICE_HANDLER:{
  22512.                 if(fase!=null && !"".equals(fase)) {
  22513.                     ricerca.addFilter(Liste.CONFIGURAZIONE_PLUGINS_CLASSI,  PluginCostanti.FILTRO_SERVICE_HANDLER_NOME, fase);
  22514.                 }
  22515.                 break;
  22516.             }
  22517.             case MESSAGE_HANDLER:{
  22518.                 // message handler e ruolo
  22519.                 if(ruolo!=null && !"".equals(ruolo)) {
  22520.                     ricerca.addFilter(Liste.CONFIGURAZIONE_PLUGINS_CLASSI,  PluginCostanti.FILTRO_RUOLO_MESSAGE_HANDLER_NOME, ruolo);
  22521.                 }
  22522.                 if(fase!=null && !"".equals(fase)) {
  22523.                     ricerca.addFilter(Liste.CONFIGURAZIONE_PLUGINS_CLASSI,  PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_NOME, fase);
  22524.                 }
  22525.                 break;
  22526.             }
  22527.             case ALLARME:
  22528.                 if(ruolo!=null && !"".equals(ruolo)) {
  22529.                     ricerca.addFilter(Liste.CONFIGURAZIONE_PLUGINS_CLASSI,  Filtri.FILTRO_APPLICABILITA_NOME, ruolo);
  22530.                 }
  22531.                 break;
  22532.             case BEHAVIOUR:
  22533.             case CONNETTORE:
  22534.             case RATE_LIMITING:
  22535.             case RICERCA:
  22536.             case STATISTICA:
  22537.             case TRANSAZIONE:
  22538.             case TOKEN_DYNAMIC_DISCOVERY:
  22539.             case TOKEN_VALIDAZIONE:
  22540.             case TOKEN_NEGOZIAZIONE:
  22541.             case ATTRIBUTE_AUTHORITY:
  22542.                 break;
  22543.             }
  22544.            
  22545.            
  22546.             List<Plugin> listaTmp = null;
  22547.             try{
  22548.                 listaTmp = this.confCore.pluginsClassiList(ricerca);
  22549.             }catch(Exception e) {
  22550.                 throw new DriverControlStationException(e.getMessage(),e);
  22551.             }
  22552.             boolean nessunValueDisponibile = false;
  22553.             if(listaTmp!=null && !listaTmp.isEmpty()) {
  22554.                 if(listaValuesDaEscludere != null && !listaValuesDaEscludere.isEmpty()) {
  22555.                     for(int i = listaTmp.size() -1; i >= 0 ; i--) {
  22556.                         if(listaValuesDaEscludere.contains(listaTmp.get(i).getTipo())) {
  22557.                             listaTmp.remove(i);
  22558.                         }
  22559.                     }
  22560.                 }
  22561.                
  22562.                 for (Plugin plugin : listaTmp) {
  22563.                     if(plugin.isStato()) {
  22564.                        
  22565.                         if(values.isEmpty()) {
  22566.                             // se uso il componente in una form di ricerca imposto il valore qualsiasi
  22567.                             if(isSearch) {
  22568.                                 values.add(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_SOGGETTO_QUALSIASI);
  22569.                                 labels.add(CostantiControlStation.LABEL_PARAMETRO_SOGGETTO_QUALSIASI);
  22570.                             } else {
  22571.                                 values.add(CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_VALORE_UNDEFINED);
  22572.                                 labels.add(CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_LABEL_UNDEFINED);
  22573.                             }
  22574.                         }
  22575.                        
  22576.                         values.add(plugin.getTipo());
  22577.                         labels.add(plugin.getLabel());
  22578.                        
  22579.                         if(value!=null) {
  22580.                             if(plugin.getTipo().equals(value)) {
  22581.                                 note = plugin.getDescrizione();
  22582.                                 if(note!=null) {
  22583.                                     note = note.trim();
  22584.                                     if("".equals(note)) {
  22585.                                         note = null;
  22586.                                     }
  22587.                                 }
  22588.                             }
  22589.                         }
  22590.                     }
  22591.                 }
  22592.             }
  22593.            
  22594.             if(listaTmp ==null || listaTmp.isEmpty()) {
  22595.                 nessunValueDisponibile = true;
  22596.             }
  22597.            
  22598.             // se non ci sono valori disponibili e voglio comunicarlo all'utente imposto il messaggio di info
  22599.             if(messaggioErroreValoriDisponibiliTerminati != null && nessunValueDisponibile) {
  22600.                 this.pd.setMessage(messaggioErroreValoriDisponibiliTerminati, Costanti.MESSAGE_TYPE_INFO);
  22601.                 this.pd.disableEditMode();
  22602.             }
  22603.            
  22604.             if(values.size()==2) {
  22605.                 // se c'e' solo un plugin elimino la non selezione
  22606.                 values.remove(0);
  22607.                 labels.remove(0);
  22608.             }
  22609.         }
  22610.            
  22611.         boolean customValidType = true;
  22612.         if( this.confCore.isConfigurazionePluginsEnabled() ) {
  22613.        
  22614.             if(!multiSelect) {
  22615.                 if(value!=null && !"".equals(value) && !CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_VALORE_UNDEFINED.equals(value)) {
  22616.                     customValidType = values.contains(value); // backward compatibility
  22617.                 }
  22618.                
  22619.                 String postBackElementName = this.getPostBackElementName();
  22620.                 if(nomeParametroSelezioneTipo.equals(postBackElementName) && !customValidType) {
  22621.                     value = null;
  22622.                     customValidType = true;
  22623.                 }
  22624.             }
  22625.         }
  22626.         else {
  22627.             customValidType = false;
  22628.         }
  22629.        
  22630.         DataElement de = new DataElement();
  22631.         de.setName(nomeParametro);
  22632.         if(!multiSelect) {
  22633.             de.setValue(value);
  22634.         }
  22635.         if (hidden)
  22636.             de.setType(DataElementType.HIDDEN);
  22637.         else{
  22638.             de.setRequired(true);
  22639.             if(!customValidType) {
  22640.                 de.setLabel(label);
  22641.                 de.setType(DataElementType.TEXT_EDIT);
  22642.                 de.setValoreDefault(valoreDefault);
  22643.             }
  22644.             else {
  22645.                 if(multiSelect) {
  22646.                     de.setLabel(label);
  22647.                     de.setType(DataElementType.MULTI_SELECT);
  22648.                 }
  22649.                 else {
  22650.                     de.setType(DataElementType.SELECT);
  22651.                 }
  22652.                 de.setValues(values);
  22653.                 de.setLabels(labels);
  22654.                 if(multiSelect) {
  22655.                     de.setSelezionati(multiValue);
  22656.                     de.setValoreDefaultMultiSelect(valoriDefault);
  22657.                 }
  22658.                 else {
  22659.                     de.setSelected(value);
  22660.                     de.setValoreDefaultSelect(valoreDefault);
  22661.                 }
  22662.                 de.setNote(note);
  22663.                 if(postBack_viaPOST) {
  22664.                     de.setPostBack_viaPOST(true);
  22665.                 }
  22666.                 else {
  22667.                     de.setPostBack(true);
  22668.                 }
  22669.                 if(!multiSelect && values.size()==1) {
  22670.                     de.setRequired(false);
  22671.                 }
  22672.                 if(mostraSempreLabel) {
  22673.                     de.setLabel(label);
  22674.                 }
  22675.             }
  22676.         }
  22677.        
  22678.         dati.add(de);
  22679.        
  22680.     }
  22681.    
  22682.     public void addOpzioniAvanzateRateLimitingToDati(List<DataElement> dati,
  22683.             boolean addTitle,
  22684.             boolean nascondiSezioneOpzioniAvanzate,
  22685.             String ctModalitaSincronizzazione, String ctImplementazione, String ctContatori, String ctTipologia,
  22686.             String ctHeaderHttp, String ctHeaderHttp_limit, String ctHeaderHttp_remaining, String ctHeaderHttp_reset,
  22687.             String ctHeaderHttp_retryAfter, String ctHeaderHttp_retryAfterBackoff) throws DriverControlStationException {
  22688.        
  22689.         if(addTitle) {
  22690.             DataElement de = new DataElement();
  22691.             de.setType(DataElementType.TITLE);
  22692.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING);
  22693.             dati.add(de);
  22694.         }
  22695.        
  22696.         DataElement de = new DataElement();
  22697.         de.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_SINCRONIZZAZIONE);
  22698.         de.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_SINCRONIZZAZIONE);
  22699.         de.setValue(ctModalitaSincronizzazione);
  22700.         if(nascondiSezioneOpzioniAvanzate ){
  22701.             de.setType(DataElementType.HIDDEN);
  22702.         } else {
  22703.             de.setValues(org.openspcoop2.core.controllo_traffico.constants.Costanti.getVALUES_MODALITA_SINCRONIZZAZIONE(this.core.getControlloTrafficoPolicyRateLimitingTipiGestori()));
  22704.             de.setLabels(org.openspcoop2.core.controllo_traffico.constants.Costanti.getLABELS_MODALITA_SINCRONIZZAZIONE(this.core.getControlloTrafficoPolicyRateLimitingTipiGestori()));
  22705.             de.setSelected(ctModalitaSincronizzazione);
  22706.             de.setType(DataElementType.SELECT);
  22707.             de.setPostBack(true);
  22708.         }
  22709.         dati.add(de);
  22710.        
  22711.        
  22712.         de = new DataElement();
  22713.         de.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP);
  22714.         de.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_GENERAZIONE_HEADER_HTTP);
  22715.         de.setValue(ctHeaderHttp);
  22716.         if(nascondiSezioneOpzioniAvanzate ){
  22717.             de.setType(DataElementType.HIDDEN);
  22718.         } else {
  22719.             de.setValues(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUES_MODALITA_GENERAZIONE_HEADER_HTTP);
  22720.             de.setLabels(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABELS_MODALITA_GENERAZIONE_HEADER_HTTP);
  22721.             de.setSelected(ctHeaderHttp);
  22722.             de.setType(DataElementType.SELECT);
  22723.             de.setPostBack(true);
  22724.         }
  22725.         dati.add(de);
  22726.        
  22727.        
  22728.         List<String> implValues = null;
  22729.         if(!nascondiSezioneOpzioniAvanzate &&
  22730.                 org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_SINCRONIZZAZIONE_DISTRIBUITA.equals(ctModalitaSincronizzazione)) {
  22731.             implValues = org.openspcoop2.core.controllo_traffico.constants.Costanti.getVALUES_MODALITA_IMPLEMENTAZIONE(this.core.getControlloTrafficoPolicyRateLimitingTipiGestori());
  22732.                
  22733.             if(implValues.size()>1 || (implValues.size()==1 && org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_IMPLEMENTAZIONE_HAZELCAST.equals(implValues.get(0)))) {
  22734.                 de = new DataElement();
  22735.                 de.setType(DataElementType.SUBTITLE);
  22736.                 de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_POLICY_CONFIGURAZIONE_SICRONIZZAZIONE_DISTRIBUITA);
  22737.                 dati.add(de);
  22738.             }
  22739.         }
  22740.        
  22741.         de = new DataElement();
  22742.         de.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_IMPLEMENTAZIONE);
  22743.         de.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_IMPLEMENTAZIONE);
  22744.         de.setValue(ctImplementazione);
  22745.         if(nascondiSezioneOpzioniAvanzate ||
  22746.                 !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_SINCRONIZZAZIONE_DISTRIBUITA.equals(ctModalitaSincronizzazione)){
  22747.             de.setType(DataElementType.HIDDEN);
  22748.         } else {
  22749.             if(implValues.size()==1) {
  22750.                 ctImplementazione = implValues.get(0);
  22751.                 de.setValue(ctImplementazione);
  22752.                 de.setType(DataElementType.HIDDEN);
  22753.             }
  22754.             else {
  22755.                 de.setValues(implValues);
  22756.                 de.setLabels(org.openspcoop2.core.controllo_traffico.constants.Costanti.getLABELS_MODALITA_IMPLEMENTAZIONE(this.core.getControlloTrafficoPolicyRateLimitingTipiGestori()));
  22757.                 if(ctImplementazione==null || StringUtils.isEmpty(ctImplementazione)) {
  22758.                     ctImplementazione = implValues.get(0);
  22759.                 }
  22760.                 de.setSelected(ctImplementazione);
  22761.                 de.setType(DataElementType.SELECT);
  22762.                 de.setPostBack(true);
  22763.             }
  22764.         }
  22765.         dati.add(de);
  22766.        
  22767.        
  22768.         de = new DataElement();
  22769.         de.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_CONTATORI);
  22770.         de.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_CONTATORI);
  22771.         de.setValue(ctContatori);
  22772.         if(nascondiSezioneOpzioniAvanzate ||
  22773.                 !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_SINCRONIZZAZIONE_DISTRIBUITA.equals(ctModalitaSincronizzazione) ||
  22774.                 (!org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_IMPLEMENTAZIONE_HAZELCAST.equals(ctImplementazione) &&
  22775.                         !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_IMPLEMENTAZIONE_REDIS.equals(ctImplementazione))){
  22776.             de.setType(DataElementType.HIDDEN);
  22777.         } else {
  22778.             List<String> values = org.openspcoop2.core.controllo_traffico.constants.Costanti.getVALUES_MODALITA_CONTATORI(this.core.getControlloTrafficoPolicyRateLimitingTipiGestori(),ctImplementazione);
  22779.             if(values==null || values.size()<=0) {
  22780.                 de.setType(DataElementType.HIDDEN);
  22781.             }
  22782.             else if(values.size()==1){
  22783.                 ctContatori = values.get(0);
  22784.                 de.setValue(ctContatori);
  22785.                 de.setType(DataElementType.HIDDEN);
  22786.                
  22787.                 List<String> labels = org.openspcoop2.core.controllo_traffico.constants.Costanti.getLABELS_MODALITA_CONTATORI(this.core.getControlloTrafficoPolicyRateLimitingTipiGestori(),ctImplementazione);
  22788.                 String label = ctContatori;
  22789.                 if(ctContatori!=null) {
  22790.                     if(label!=null && !label.isEmpty() && values.size()==labels.size()) {
  22791.                         for (int i = 0; i < values.size(); i++) {
  22792.                             if(ctContatori.equals(values.get(i))){
  22793.                                 label = labels.get(i);
  22794.                             }
  22795.                         }
  22796.                     }
  22797.                 }
  22798.                 DataElement deLABEL = new DataElement();
  22799.                 deLABEL.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_CONTATORI+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  22800.                 deLABEL.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_CONTATORI);
  22801.                 deLABEL.setValue(label);
  22802.                 deLABEL.setType(DataElementType.TEXT);
  22803.                 dati.add(deLABEL);
  22804.             }
  22805.             else {
  22806.                 de.setValues(values);
  22807.                 de.setLabels(org.openspcoop2.core.controllo_traffico.constants.Costanti.getLABELS_MODALITA_CONTATORI(this.core.getControlloTrafficoPolicyRateLimitingTipiGestori(),ctImplementazione));
  22808.                 if(ctContatori==null || StringUtils.isEmpty(ctContatori)) {
  22809.                     ctContatori = values.get(0);
  22810.                 }
  22811.                 de.setSelected(ctContatori);
  22812.                 de.setType(DataElementType.SELECT);
  22813.                 de.setPostBack(true);
  22814.             }
  22815.         }
  22816.         dati.add(de);
  22817.        
  22818.        
  22819.         de = new DataElement();
  22820.         de.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_TIPOLOGIA);
  22821.         de.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_TIPOLOGIA);
  22822.         de.setValue(ctTipologia);
  22823.         if(nascondiSezioneOpzioniAvanzate ||
  22824.                 !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_MODALITA_SINCRONIZZAZIONE_DISTRIBUITA.equals(ctModalitaSincronizzazione)){
  22825.             de.setType(DataElementType.HIDDEN);
  22826.         } else {
  22827.             List<String> values = org.openspcoop2.core.controllo_traffico.constants.Costanti.getVALUES_MODALITA_TIPOLOGIA(this.core.getControlloTrafficoPolicyRateLimitingTipiGestori(),ctImplementazione, ctContatori);
  22828.             if(values==null || values.size()<=0) {
  22829.                 de.setType(DataElementType.HIDDEN);
  22830.             }
  22831.             else if(values.size()==1){
  22832.                 ctTipologia = values.get(0);
  22833.                 de.setValue(ctTipologia);
  22834.                 de.setType(DataElementType.TEXT);
  22835.             }
  22836.             else {
  22837.                 de.setValues(values);
  22838.                 de.setLabels(org.openspcoop2.core.controllo_traffico.constants.Costanti.getLABELS_MODALITA_TIPOLOGIA(this.core.getControlloTrafficoPolicyRateLimitingTipiGestori(), ctImplementazione, ctContatori));
  22839.                 if(ctTipologia==null || StringUtils.isEmpty(ctTipologia)) {
  22840.                     ctTipologia = values.get(0);
  22841.                 }
  22842.                 de.setSelected(ctTipologia);
  22843.                 de.setType(DataElementType.SELECT);
  22844.                 de.setPostBack(false);
  22845.             }
  22846.         }
  22847.         dati.add(de);
  22848.        
  22849.        
  22850.        
  22851.         if(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_RIDEFINITO.equals(ctHeaderHttp)) {
  22852.             de = new DataElement();
  22853.             de.setType(DataElementType.SUBTITLE);
  22854.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_POLICY_CONFIGURAZIONE_HEADER_HTTP);
  22855.             dati.add(de);
  22856.         }
  22857.        
  22858.        
  22859.         de = new DataElement();
  22860.         de.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_LIMIT);
  22861.         de.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_GENERAZIONE_HEADER_HTTP_LIMIT);
  22862.         de.setValue(ctHeaderHttp_limit);
  22863.         if(nascondiSezioneOpzioniAvanzate || !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_RIDEFINITO.equals(ctHeaderHttp) ){
  22864.             de.setType(DataElementType.HIDDEN);
  22865.         } else {
  22866.             de.setValues(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUES_MODALITA_GENERAZIONE_HEADER_HTTP_LIMIT);
  22867.             de.setLabels(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABELS_MODALITA_GENERAZIONE_HEADER_HTTP_LIMIT);
  22868.             de.setSelected(ctHeaderHttp_limit);
  22869.             de.setType(DataElementType.SELECT);
  22870.             de.setPostBack(false);
  22871.         }
  22872.         dati.add(de);
  22873.        
  22874.            
  22875.         de = new DataElement();
  22876.         de.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_REMAINING);
  22877.         de.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_GENERAZIONE_HEADER_HTTP_REMAINING);
  22878.         de.setValue(ctHeaderHttp_remaining);
  22879.         if(nascondiSezioneOpzioniAvanzate || !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_RIDEFINITO.equals(ctHeaderHttp) ){
  22880.             de.setType(DataElementType.HIDDEN);
  22881.         } else {
  22882.             de.setValues(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUES_MODALITA_GENERAZIONE_HEADER_HTTP_REMAINING);
  22883.             de.setLabels(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABELS_MODALITA_GENERAZIONE_HEADER_HTTP_REMAINING);
  22884.             de.setSelected(ctHeaderHttp_remaining);
  22885.             de.setType(DataElementType.SELECT);
  22886.             de.setPostBack(false);
  22887.         }
  22888.         dati.add(de);
  22889.        
  22890.        
  22891.         de = new DataElement();
  22892.         de.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_RESET);
  22893.         de.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_GENERAZIONE_HEADER_HTTP_RESET);
  22894.         de.setValue(ctHeaderHttp_reset);
  22895.         if(nascondiSezioneOpzioniAvanzate || !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_RIDEFINITO.equals(ctHeaderHttp) ){
  22896.             de.setType(DataElementType.HIDDEN);
  22897.         } else {
  22898.             de.setValues(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUES_MODALITA_GENERAZIONE_HEADER_HTTP_RESET);
  22899.             de.setLabels(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABELS_MODALITA_GENERAZIONE_HEADER_HTTP_RESET);
  22900.             de.setSelected(ctHeaderHttp_reset);
  22901.             de.setType(DataElementType.SELECT);
  22902.             de.setPostBack(false);
  22903.         }
  22904.         dati.add(de);
  22905.        
  22906.        
  22907.         de = new DataElement();
  22908.         de.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER);
  22909.         de.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER);
  22910.         de.setValue(ctHeaderHttp_retryAfter);
  22911.         if(nascondiSezioneOpzioniAvanzate || !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_RIDEFINITO.equals(ctHeaderHttp) ){
  22912.             de.setType(DataElementType.HIDDEN);
  22913.         } else {
  22914.             de.setValues(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUES_MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER);
  22915.             de.setLabels(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABELS_MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER);
  22916.             de.setSelected(ctHeaderHttp_retryAfter);
  22917.             de.setType(DataElementType.SELECT);
  22918.             de.setPostBack(true);
  22919.         }
  22920.         dati.add(de);
  22921.        
  22922.        

  22923.         de = new DataElement();
  22924.         de.setName(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER_BACKOFF_SECONDS);
  22925.         de.setLabel(org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER_BACKOFF_SECONDS);
  22926.         de.setValue(ctHeaderHttp_retryAfterBackoff);
  22927.         if(nascondiSezioneOpzioniAvanzate ||
  22928.                 !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_RIDEFINITO.equals(ctHeaderHttp) ||
  22929.                 !org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_ABILITATO_BACKOFF.equals(ctHeaderHttp_retryAfter) ){
  22930.             de.setType(DataElementType.HIDDEN);
  22931.         } else {
  22932.             de.setType(DataElementType.NUMBER);
  22933.             de.setMinValue(1);
  22934.             de.setRequired(true);
  22935.         }
  22936.         dati.add(de);
  22937.        
  22938.     }
  22939.    
  22940.    
  22941.     public boolean validaOpzioniAvanzateRateLimiting(RuoloPolicy ruoloPolicy, String nome) throws DriverControlStationException {
  22942.    
  22943.         String ctModalitaSincronizzazione = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_SINCRONIZZAZIONE);
  22944.         String ctImplementazione = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_IMPLEMENTAZIONE);
  22945.         String ctContatori = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_CONTATORI);
  22946.         String ctTipologia = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_TIPOLOGIA);
  22947.         String ctHeaderHttp = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP);
  22948.         String ctHeaderHttp_limit = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_LIMIT);
  22949.         String ctHeaderHttp_remaining = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_REMAINING);
  22950.         String ctHeaderHttp_reset = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_RESET);
  22951.         String ctHeaderHttp_retryAfter = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER);
  22952.         String ctHeaderHttp_retryAfterBackoff = this.getParameter(org.openspcoop2.core.controllo_traffico.constants.Costanti.MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER_BACKOFF_SECONDS);
  22953.        
  22954.         return validaOpzioniAvanzateRateLimiting(ruoloPolicy, nome,
  22955.                 ctModalitaSincronizzazione, ctImplementazione, ctContatori, ctTipologia,
  22956.                 ctHeaderHttp, ctHeaderHttp_limit, ctHeaderHttp_remaining, ctHeaderHttp_reset,
  22957.                 ctHeaderHttp_retryAfter, ctHeaderHttp_retryAfterBackoff);
  22958.     }
  22959.     public boolean validaOpzioniAvanzateRateLimiting(RuoloPolicy ruoloPolicy, String nome,
  22960.             String ctModalitaSincronizzazione, String ctImplementazione, String ctContatori, String ctTipologia,
  22961.             String ctHeaderHttp, String ctHeaderHttp_limit, String ctHeaderHttp_remaining, String ctHeaderHttp_reset,
  22962.             String ctHeaderHttp_retryAfter, String ctHeaderHttp_retryAfterBackoff) throws DriverControlStationException {
  22963.        
  22964.         if(org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_RIDEFINITO.equals(ctHeaderHttp) &&
  22965.                 org.openspcoop2.core.controllo_traffico.constants.Costanti.VALUE_HTTP_HEADER_ABILITATO_BACKOFF.equals(ctHeaderHttp_retryAfter) ){
  22966.             int backoffInt = -1;
  22967.             try{
  22968.                 backoffInt = Integer.parseInt(ctHeaderHttp_retryAfterBackoff);
  22969.             }catch(Exception e){
  22970.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_DATI_NON_VALIDI_INSERIRE_UN_NUMERO_INTERO_MAGGIORE_DI_ZERO, org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER_BACKOFF_SECONDS));
  22971.                 return false;
  22972.             }
  22973.             if(backoffInt <= 0){
  22974.                 this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_DATI_NON_VALIDI_INSERIRE_UN_NUMERO_INTERO_MAGGIORE_DI_ZERO, org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_GENERAZIONE_HEADER_HTTP_RETRY_AFTER_BACKOFF_SECONDS));
  22975.                 return false;
  22976.             }
  22977.         }
  22978.        
  22979.        
  22980.         PolicyConfiguration policyConfig = new PolicyConfiguration();
  22981.         policyConfig.setSyncMode(ctModalitaSincronizzazione);
  22982.         policyConfig.setImpl(ctImplementazione);
  22983.         policyConfig.setCount(ctContatori);
  22984.         policyConfig.setEngineType(ctTipologia);
  22985.         policyConfig.setHttpMode(ctHeaderHttp);
  22986.         policyConfig.setHttpMode_limit(ctHeaderHttp_limit);
  22987.         policyConfig.setHttpMode_remaining(ctHeaderHttp_remaining);
  22988.         policyConfig.setHttpMode_reset(ctHeaderHttp_reset);
  22989.         policyConfig.setHttpMode_retry_after(ctHeaderHttp_retryAfter);
  22990.         policyConfig.setHttpMode_retry_after_backoff(ctHeaderHttp_retryAfterBackoff);
  22991.         try {
  22992.             policyConfig.saveIn(new ArrayList<>()); // inizializza il tipo
  22993.         }catch(Exception e) {
  22994.             throw new DriverControlStationException(e.getMessage(),e);
  22995.         }
  22996.         PolicyGroupByActiveThreadsType type = policyConfig.getType();
  22997.        
  22998.        
  22999.         ConsoleSearch ricercaAll = new ConsoleSearch(true);
  23000.         List<TipoRisorsaPolicyAttiva> listaTipoRisorsa = this.confCore.attivazionePolicyTipoRisorsaList(ricercaAll, ruoloPolicy, nome);
  23001.         StringBuilder sb = new StringBuilder();
  23002.         for (TipoRisorsaPolicyAttiva tipoRisorsaPolicyAttiva : listaTipoRisorsa) {
  23003.             if(type!=null && !type.isSupportedResource(tipoRisorsaPolicyAttiva)) {
  23004.                 if(sb.length()>0) {
  23005.                     sb.append(", ");
  23006.                 }
  23007.                 sb.append(tipoRisorsaPolicyAttiva.getValue());
  23008.             }
  23009.         }
  23010.         if(sb.length()>0) {
  23011.             String oggetto = "globalmente";
  23012.             if(ruoloPolicy!=null) {
  23013.                 if(RuoloPolicy.APPLICATIVA.equals(ruoloPolicy)){
  23014.                     oggetto = "sull'erogazione";
  23015.                 }
  23016.                 else if(RuoloPolicy.DELEGATA.equals(ruoloPolicy)){
  23017.                     oggetto = "sulla fruizione";
  23018.                 }
  23019.             }
  23020.             this.pd.setMessage("La "+org.openspcoop2.core.controllo_traffico.constants.Costanti.LABEL_MODALITA_SINCRONIZZAZIONE+
  23021.                     " selezionata non è utilizzabile poichè non compatibile con alcune metriche associate alle policy attive "+oggetto+": "+sb.toString());
  23022.             return false;
  23023.         }
  23024.        
  23025.         return true;
  23026.     }
  23027.    
  23028.    
  23029.     public void addIntegrazioneMetadatiToDati(List<DataElement> dati, String integrazioneStato, String integrazione,
  23030.             String[] integrazioneGruppi, List<GruppoIntegrazione> integrazioneGruppiDaVisualizzare,
  23031.             Map<String, List<String>> integrazioneGruppiValoriDeiGruppi, List<DataElement> deIntegrazione,
  23032.             boolean nascondiSezioneOpzioniAvanzate, boolean isPortaDelegata,
  23033.             ServiceBinding serviceBinding) throws DriverControlStationException {
  23034.         String ruoloConfigurazione = isPortaDelegata ? Filtri.FILTRO_RUOLO_VALORE_FRUIZIONE :   Filtri.FILTRO_RUOLO_VALORE_EROGAZIONE;
  23035.        
  23036.         DataElement de;
  23037.         // stato metadati
  23038.         de = new DataElement();
  23039.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_METADATI);
  23040.         de.setValue(integrazioneStato);
  23041.         de.setName(CostantiControlStation.PARAMETRO_PORTE_INTEGRAZIONE_STATO);
  23042.         if(nascondiSezioneOpzioniAvanzate ){
  23043.             de.setType(DataElementType.HIDDEN);
  23044.             dati.add(de);
  23045.         } else {
  23046.             de.setType(DataElementType.SELECT);
  23047.             de.setValues(CostantiControlStation.VALUES_PARAMETRO_PORTE_INTEGRAZIONE_STATO);
  23048.             de.setLabels(CostantiControlStation.LABELS_PARAMETRO_PORTE_INTEGRAZIONE_STATO);
  23049.             de.setSelected(integrazioneStato);
  23050.             de.setPostBack(true);
  23051.             DataElementInfo dInfo = new DataElementInfo(CostantiControlStation.LABEL_METADATI);
  23052.             dInfo.setBody(CostantiControlStation.LABEL_METADATI_INFO);
  23053.             de.setInfo(dInfo);
  23054.             deIntegrazione.add(de);
  23055.         }
  23056.        
  23057.         if(nascondiSezioneOpzioniAvanzate ){
  23058.             de = new DataElement();
  23059.             de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_METADATI);
  23060.             de.setValue(integrazione);
  23061.             de.setName(CostantiControlStation.PARAMETRO_PORTE_INTEGRAZIONE);
  23062.             de.setType(DataElementType.HIDDEN);
  23063.             dati.add(de);
  23064.         }else{
  23065.             // valore del campo integrazione
  23066.             if(integrazioneStato.equals(CostantiControlStation.VALUE_PARAMETRO_PORTE_INTEGRAZIONE_STATO_DISABILITATO)) {
  23067.                 de = new DataElement();
  23068.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_METADATI);
  23069.                 de.setValue(integrazione);
  23070.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_INTEGRAZIONE);
  23071.                 de.setType(DataElementType.HIDDEN);
  23072.                 deIntegrazione.add(de);
  23073.             } else if(integrazioneStato.equals(CostantiControlStation.VALUE_PARAMETRO_PORTE_INTEGRAZIONE_STATO_RIDEFINITO)) {
  23074.                 de = new DataElement();
  23075.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_METADATI);
  23076.                 de.setValue(integrazione);
  23077.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_INTEGRAZIONE);
  23078.                 de.setType(DataElementType.HIDDEN);
  23079.                 deIntegrazione.add(de);
  23080.                
  23081.                 de = new DataElement();
  23082.                 de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTE_METADATI_GRUPPO);
  23083.                 de.setSelezionati(integrazioneGruppi);
  23084.                 de.setName(CostantiControlStation.PARAMETRO_PORTE_METADATI_GRUPPO);
  23085.                 de.setType(DataElementType.MULTI_SELECT);
  23086.                 de.setValues(GruppoIntegrazione.toValues(serviceBinding));
  23087.                 de.setLabels(GruppoIntegrazione.toLabels(true, serviceBinding));
  23088.                 de.setPostBack_viaPOST(true);
  23089.                 de.setRequired(true);
  23090.                 DataElementInfo dInfo = new DataElementInfo(CostantiControlStation.LABEL_METADATI);
  23091.                 switch (serviceBinding) {
  23092.                 case REST:
  23093.                     dInfo.setBody(CostantiControlStation.LABEL_METADATI_RIDEFINITI_INFO_REST);  
  23094.                     break;
  23095.                 case SOAP:
  23096.                     dInfo.setBody(CostantiControlStation.LABEL_METADATI_RIDEFINITI_INFO_SOAP);  
  23097.                     break;
  23098.                 }
  23099.                 de.setInfo(dInfo);
  23100.                 deIntegrazione.add(de);
  23101.                
  23102.                 // gruppi singoli
  23103.                 boolean subtitleOp2 = false;
  23104.                 boolean subtitleOp1 = false;
  23105.                 for (GruppoIntegrazione group : integrazioneGruppiDaVisualizzare) {
  23106.                     String [] valoriMulti = null;
  23107.                     String valoreSingolo = null;
  23108.                     List<String> listaValori = integrazioneGruppiValoriDeiGruppi.get(group.getValue());
  23109.                     if(listaValori != null && listaValori.size() > 0) {
  23110.                         valoriMulti = listaValori.toArray(new String[listaValori.size()]);
  23111.                         if(!group.isMulti()) {
  23112.                             valoreSingolo = valoriMulti[0];
  23113.                         }
  23114.                     }
  23115.                    
  23116.                    
  23117.                     if(!group.getValue().equals(GruppoIntegrazione.PLUGIN.getValue())) {
  23118.                        
  23119.                         de = new DataElement();
  23120.                                                
  23121.                         if(group.getValue().equals(GruppoIntegrazione.BACKWARD_COMPATIBILITY_OPENSPCOOP2_HTTP.getValue())
  23122.                                 ||
  23123.                             group.getValue().equals(GruppoIntegrazione.BACKWARD_COMPATIBILITY_OPENSPCOOP2_URL.getValue())
  23124.                                 ||  
  23125.                             group.getValue().equals(GruppoIntegrazione.BACKWARD_COMPATIBILITY_OPENSPCOOP2_SOAP.getValue()) ) {
  23126.                             if(!subtitleOp2) {
  23127.                                
  23128.                                 DataElement deSub = new DataElement();
  23129.                                 deSub.setLabel(CostantiControlStation.LABEL_METADATI_BACKWARD_COMPATIBILITY_OPENSPCOOP_2);
  23130.                                 deSub.setType(DataElementType.SUBTITLE);
  23131.                                 deIntegrazione.add(deSub);
  23132.                                
  23133.                                 subtitleOp2 = true;
  23134.                             }
  23135.                             if(group.getValue().equals(GruppoIntegrazione.BACKWARD_COMPATIBILITY_OPENSPCOOP2_HTTP.getValue())) {
  23136.                                 de.setLabel(GruppoIntegrazione.HTTP.getCompactLabel());
  23137.                             }
  23138.                             else if(group.getValue().equals(GruppoIntegrazione.BACKWARD_COMPATIBILITY_OPENSPCOOP2_URL.getValue())) {
  23139.                                 de.setLabel(GruppoIntegrazione.URL.getCompactLabel());  
  23140.                             }
  23141.                             else {
  23142.                                 de.setLabel(CostantiControlStation.LABEL_METADATI_BACKWARD_COMPATIBILITY_HEADER_SOAP);  
  23143.                             }
  23144.                         }
  23145.                         else if(group.getValue().equals(GruppoIntegrazione.BACKWARD_COMPATIBILITY_OPENSPCOOP1_HTTP.getValue())
  23146.                                 ||
  23147.                             group.getValue().equals(GruppoIntegrazione.BACKWARD_COMPATIBILITY_OPENSPCOOP1_URL.getValue())
  23148.                                 ||  
  23149.                             group.getValue().equals(GruppoIntegrazione.BACKWARD_COMPATIBILITY_OPENSPCOOP1_SOAP.getValue()) ) {
  23150.                             if(!subtitleOp1) {
  23151.                                
  23152.                                 DataElement deSub = new DataElement();
  23153.                                 deSub.setLabel(CostantiControlStation.LABEL_METADATI_BACKWARD_COMPATIBILITY_OPENSPCOOP_1);
  23154.                                 deSub.setType(DataElementType.SUBTITLE);
  23155.                                 deIntegrazione.add(deSub);
  23156.                                
  23157.                                 subtitleOp1 = true;
  23158.                             }
  23159.                             if(group.getValue().equals(GruppoIntegrazione.BACKWARD_COMPATIBILITY_OPENSPCOOP1_HTTP.getValue())) {
  23160.                                 de.setLabel(GruppoIntegrazione.HTTP.getCompactLabel());
  23161.                             }
  23162.                             else if(group.getValue().equals(GruppoIntegrazione.BACKWARD_COMPATIBILITY_OPENSPCOOP1_URL.getValue())) {
  23163.                                 de.setLabel(GruppoIntegrazione.URL.getCompactLabel());  
  23164.                             }
  23165.                             else {
  23166.                                 de.setLabel(CostantiControlStation.LABEL_METADATI_BACKWARD_COMPATIBILITY_HEADER_SOAP);  
  23167.                             }
  23168.                         }
  23169.                         else {
  23170.                             de.setLabel(group.getCompactLabel());  
  23171.                         }
  23172.                        
  23173.                         de.setName(CostantiControlStation.PARAMETRO_PORTE_METADATI_GRUPPO_SINGOLO+group.getValue());
  23174.                        
  23175.                         if(!group.isConfig()) {
  23176.                             de.setType(DataElementType.HIDDEN);
  23177. //                          if(group.isMulti()) {
  23178. //                              de.setValue(Arrays.asList(valoriMulti).toString());
  23179. //                          }
  23180. //                          else {
  23181.                             if(valoreSingolo==null || "".equals(valoreSingolo)) {
  23182.                                 String [] tipo = TipoIntegrazione.toValues(group); // in questo caso con config a false, dovrebbe esisterne uno solo
  23183.                                 if(tipo!=null && tipo.length==1 && tipo[0]!=null) {
  23184.                                     de.setValue(tipo[0]);
  23185.                                 }
  23186.                             }
  23187.                             else {
  23188.                                 de.setValue(valoreSingolo);
  23189.                             }
  23190. //                          }
  23191.                         }
  23192.                         else {
  23193.                             if(group.isMulti()) {
  23194.                                 de.setType(DataElementType.MULTI_SELECT);
  23195.                                 de.setSelezionati(valoriMulti);
  23196.                             } else {
  23197.                                 de.setType(DataElementType.SELECT);
  23198.                                 de.setSelected(valoreSingolo);
  23199.                             }
  23200.                             de.setValues(TipoIntegrazione.toValues(group));
  23201.                             de.setLabels(TipoIntegrazione.toLabels(group));
  23202.                             de.setRequired(true);
  23203.                         }
  23204.                         deIntegrazione.add(de);
  23205.                        
  23206.                     } else {
  23207.                         if(group.isMulti()) {
  23208.                             this.addMultiSelectCustomField(TipoPlugin.INTEGRAZIONE, ruoloConfigurazione, null,
  23209.                                     CostantiControlStation.PARAMETRO_PORTE_METADATI_GRUPPO,
  23210.                                     CostantiControlStation.PARAMETRO_PORTE_METADATI_GRUPPO_SINGOLO+group.getValue(),
  23211.                                     GruppoIntegrazione.PLUGIN.getCompactLabel(), valoriMulti, false, deIntegrazione, false);
  23212.                         } else {
  23213.                             this.addCustomField(TipoPlugin.INTEGRAZIONE, ruoloConfigurazione, null,
  23214.                                     CostantiControlStation.PARAMETRO_PORTE_METADATI_GRUPPO,
  23215.                                     CostantiControlStation.PARAMETRO_PORTE_METADATI_GRUPPO_SINGOLO+group.getValue(),
  23216.                                     GruppoIntegrazione.PLUGIN.getCompactLabel(), valoreSingolo, false, deIntegrazione, false);
  23217.                         }
  23218.                     }
  23219.                 }
  23220.             } else {
  23221.                 // quando e' default ci deve finire null                    
  23222.             }
  23223. //          deIntegrazione.addElement(de);
  23224.         }
  23225.     }
  23226.    
  23227.    
  23228.     public boolean validaIntegrazioneMetadati() throws DriverControlStationException {
  23229.         String integrazioneStato = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_INTEGRAZIONE_STATO);
  23230.                
  23231.         if(integrazioneStato!=null && !"".equals(integrazioneStato)){
  23232.             if(integrazioneStato.equals(CostantiControlStation.VALUE_PARAMETRO_PORTE_INTEGRAZIONE_STATO_RIDEFINITO)) {
  23233.                 String[] integrazioneGruppi = this.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_METADATI_GRUPPO);
  23234.                
  23235.                 if(integrazioneGruppi == null || integrazioneGruppi.length == 0) {
  23236.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_PORTE_INTEGRAZIONE_GRUPPI_VUOTI);
  23237.                     return false;
  23238.                 }
  23239.                
  23240.                 List<GruppoIntegrazione> integrazioneGruppiDaVisualizzare = new ArrayList<GruppoIntegrazione>();  
  23241.                
  23242.                 for (String gruppoSelezionato : integrazioneGruppi) {
  23243.                     integrazioneGruppiDaVisualizzare.add(GruppoIntegrazione.toEnumConstant(gruppoSelezionato));
  23244.                 }
  23245.                
  23246.                 // leggere i valori selezionati per ogni gruppo selezionato
  23247.                 Map<String, List<String>> integrazioneGruppiValoriDeiGruppi = new HashMap<>();
  23248.                 for (GruppoIntegrazione group : integrazioneGruppiDaVisualizzare) {
  23249.                     List<String> valoriGruppoList = new ArrayList<>();
  23250.                     if(group.isMulti()) {
  23251.                         String[] valoriGruppo = this.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_METADATI_GRUPPO_SINGOLO+group.getValue());
  23252.                         if(valoriGruppo == null || valoriGruppo.length == 0) {
  23253.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_PORTE_INTEGRAZIONE_GRUPPO_VUOTO, group.getCompactLabel()));
  23254.                             return false;
  23255.                         }
  23256.                        
  23257.                         valoriGruppoList.addAll(Arrays.asList(valoriGruppo));
  23258.                     } else {
  23259.                         String valoreGruppo = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_METADATI_GRUPPO_SINGOLO+group.getValue());
  23260.                         if(valoreGruppo == null) {
  23261.                             this.pd.setMessage(MessageFormat.format(CostantiControlStation.MESSAGGIO_ERRORE_PORTE_INTEGRAZIONE_GRUPPO_VUOTO, group.getCompactLabel()));
  23262.                             return false;
  23263.                         }
  23264.                         valoriGruppoList.add(valoreGruppo);
  23265.                     }
  23266.                    
  23267.                     integrazioneGruppiValoriDeiGruppi.put(group.getValue(), valoriGruppoList);  
  23268.                 }
  23269.                
  23270.                 // controllo sulla lunghezza finale del campo integrazione
  23271.                 List<String> valoriFinaliIntegrazione = new ArrayList<>();
  23272.                 for (GruppoIntegrazione group : integrazioneGruppiDaVisualizzare) {
  23273.                     valoriFinaliIntegrazione.addAll(integrazioneGruppiValoriDeiGruppi.get(group.getValue()));
  23274.                 }
  23275.                
  23276.                 String valoreFinaleCampoItegrazione = StringUtils.join(valoriFinaliIntegrazione.toArray(new String[valoriFinaliIntegrazione.size()]), ",");
  23277.                 if(valoreFinaleCampoItegrazione!=null && valoreFinaleCampoItegrazione.length()>4000) {
  23278.                     this.pd.setMessage("L'informazione fornita nel campo '"+CostantiControlStation.LABEL_PARAMETRO_PORTE_METADATI+"' deve possedere una lunghezza minore di 4000");
  23279.                     return false;
  23280.                 }
  23281.             }
  23282.         }
  23283.        
  23284.         return true;
  23285.     }
  23286.    
  23287.     public void visualizzaLinkHandlers(List<DataElement> dati, boolean isConfigurazione, TipoPdD ruoloPorta, Long idPorta, ServiceBinding serviceBinding) throws DriverConfigurazioneException {
  23288.         DataElement de;
  23289.         boolean contaListeFromSession = ServletUtils.getContaListeFromSession(this.session) != null ? ServletUtils.getContaListeFromSession(this.session) : false;
  23290.        
  23291.         de = new DataElement();
  23292.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_HANDLERS);
  23293.         de.setType(DataElementType.TITLE);
  23294.         dati.add(de);
  23295.        
  23296.         List<Parameter> listaParametriComuni = new ArrayList<>();
  23297.        
  23298.         Parameter parRuoloPorta = null;
  23299.         if(ruoloPorta!=null) {
  23300.             parRuoloPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_RUOLO_PORTA, ruoloPorta.getTipo());
  23301.             listaParametriComuni.add(parRuoloPorta);
  23302.         }
  23303.         Parameter parIdPorta = null;
  23304.         if(idPorta!=null) {
  23305.             parIdPorta = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_ID_PORTA, idPorta +"");
  23306.             listaParametriComuni.add(parIdPorta);
  23307.         }
  23308.         Parameter parServiceBinding = null;
  23309.         if(serviceBinding!=null) {
  23310.             parServiceBinding = new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_SERVICE_BINDING, serviceBinding.name());
  23311.             listaParametriComuni.add(parServiceBinding);
  23312.         }
  23313.        
  23314.        
  23315.         // handler richiesta
  23316.         de = new DataElement();
  23317.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_HANDLERS_RICHIESTA);
  23318.         de.setType(DataElementType.SUBTITLE);
  23319.         dati.add(de);
  23320.        
  23321.         for (int i = 0; i < PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_VALORI_RICHIESTA.size(); i++) {
  23322.             String valueRichiesta = PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_VALORI_RICHIESTA.get(i);
  23323.             String labelRichiesta = PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_RICHIESTA.get(i);

  23324.             int numeroHandlersRichiesta = this.confCore.numeroHandlersRichiesta(valueRichiesta, ruoloPorta, idPorta);
  23325.            
  23326.             List<Parameter> listaParametriRichiesta = new ArrayList<>();
  23327.             if(!listaParametriComuni.isEmpty()) {
  23328.                 listaParametriRichiesta.addAll(listaParametriComuni);
  23329.             }
  23330.             listaParametriRichiesta.add(new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_FASE, valueRichiesta));
  23331.            
  23332.             de = new DataElement();
  23333.             de.setType(DataElementType.LINK);
  23334.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_HANDLERS_RICHIESTA_LIST, listaParametriRichiesta.toArray(new Parameter [listaParametriRichiesta.size()]));
  23335.             if (contaListeFromSession)
  23336.                 de.setValue(labelRichiesta +" (" + numeroHandlersRichiesta + ")");
  23337.             else
  23338.                 de.setValue(labelRichiesta);
  23339.             dati.add(de);
  23340.         }
  23341.        
  23342.         // handler risposta
  23343.         de = new DataElement();
  23344.         de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_HANDLERS_RISPOSTA);
  23345.         de.setType(DataElementType.SUBTITLE);
  23346.         dati.add(de);
  23347.        
  23348.         for (int i = 0; i < PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_VALORI_RISPOSTA.size(); i++) {
  23349.             String valueRisposta = PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_VALORI_RISPOSTA.get(i);
  23350.             String labelRisposta = PluginCostanti.FILTRO_FASE_MESSAGE_HANDLER_LABEL_RISPOSTA.get(i);
  23351.            
  23352.             int numeroHandlersRisposta = this.confCore.numeroHandlersRisposta(valueRisposta, ruoloPorta, idPorta);
  23353.            
  23354.             List<Parameter> listaParametriRisposta = new ArrayList<>();
  23355.             if(!listaParametriComuni.isEmpty()) {
  23356.                 listaParametriRisposta.addAll(listaParametriComuni);
  23357.             }
  23358.             listaParametriRisposta.add(new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_FASE, valueRisposta));
  23359.            
  23360.             de = new DataElement();
  23361.             de.setType(DataElementType.LINK);
  23362.             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_HANDLERS_RISPOSTA_LIST, listaParametriRisposta.toArray(new Parameter [listaParametriRisposta.size()]));
  23363.             if (contaListeFromSession)
  23364.                 de.setValue(labelRisposta+" (" + numeroHandlersRisposta + ")");
  23365.             else
  23366.                 de.setValue(labelRisposta);
  23367.             dati.add(de);
  23368.         }
  23369.        
  23370.         if(isConfigurazione) {
  23371.             // service handler
  23372.             de = new DataElement();
  23373.             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_HANDLERS_SERVIZIO);
  23374.             de.setType(DataElementType.SUBTITLE);
  23375.             dati.add(de);
  23376.            
  23377.             boolean integrationManagerEnabled = this.confCore.isIntegrationManagerEnabled();
  23378.            
  23379.             if(integrationManagerEnabled) {
  23380.                 for (int i = 0; i < PluginCostanti.FILTRO_SERVICE_HANDLER_VALORI_CON_INTEGRATION_MANAGER.size(); i++) {
  23381.                     String valueServizio = PluginCostanti.FILTRO_SERVICE_HANDLER_VALORI_CON_INTEGRATION_MANAGER.get(i);
  23382.                     String labelServizio = PluginCostanti.FILTRO_SERVICE_HANDLER_LABEL_CON_INTEGRATION_MANAGER.get(i);
  23383.                    
  23384.                     int numeroHandlersServizio = this.confCore.numeroHandlersServizio(valueServizio);
  23385.                    
  23386.                     List<Parameter> listaParametriServizio = new ArrayList<>();
  23387.                     if(!listaParametriComuni.isEmpty()) {
  23388.                         listaParametriServizio.addAll(listaParametriComuni);
  23389.                     }
  23390.                     listaParametriServizio.add(new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_FASE, valueServizio));
  23391.                    
  23392.                     de = new DataElement();
  23393.                     de.setType(DataElementType.LINK);
  23394.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_HANDLERS_SERVIZIO_LIST, listaParametriServizio.toArray(new Parameter [listaParametriServizio.size()]));
  23395.                     if (contaListeFromSession)
  23396.                         de.setValue(labelServizio +" (" + numeroHandlersServizio + ")");
  23397.                     else
  23398.                         de.setValue(labelServizio);
  23399.                     dati.add(de);
  23400.                 }
  23401.             } else {
  23402.                 for (int i = 0; i < PluginCostanti.FILTRO_SERVICE_HANDLER_VALORI_SENZA_INTEGRATION_MANAGER.size(); i++) {
  23403.                     String valueServizio = PluginCostanti.FILTRO_SERVICE_HANDLER_VALORI_SENZA_INTEGRATION_MANAGER.get(i);
  23404.                     String labelServizio = PluginCostanti.FILTRO_SERVICE_HANDLER_LABEL_SENZA_INTEGRATION_MANAGER.get(i);
  23405.                    
  23406.                     int numeroHandlersServizio = this.confCore.numeroHandlersServizio(valueServizio);
  23407.                    
  23408.                     List<Parameter> listaParametriServizio = new ArrayList<>();
  23409.                     if(!listaParametriComuni.isEmpty()) {
  23410.                         listaParametriServizio.addAll(listaParametriComuni);
  23411.                     }
  23412.                     listaParametriServizio.add(new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_HANDLERS_FASE, valueServizio));
  23413.                    
  23414.                     de = new DataElement();
  23415.                     de.setType(DataElementType.LINK);
  23416.                     de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_HANDLERS_SERVIZIO_LIST, listaParametriServizio.toArray(new Parameter [listaParametriServizio.size()]));
  23417.                     if (contaListeFromSession)
  23418.                         de.setValue(labelServizio +" (" + numeroHandlersServizio + ")");
  23419.                     else
  23420.                         de.setValue(labelServizio);
  23421.                     dati.add(de);
  23422.                 }
  23423.             }
  23424.         }
  23425.     }
  23426.    
  23427.     public List<String> nomiProprietaPD(String protocolloPerFiltroProprieta , String soggettoPerFiltroProprieta) throws DriverRegistroServiziException, DriverConfigurazioneException {
  23428.         List<String> tipoServiziProtocollo = null;
  23429.         String filterSoggettoTipo = null;
  23430.         String filterSoggettoNome = null;
  23431.         if(soggettoPerFiltroProprieta != null) {
  23432.             if(soggettoPerFiltroProprieta!=null && !"".equals(soggettoPerFiltroProprieta)) {
  23433.                 filterSoggettoTipo = soggettoPerFiltroProprieta.split("/")[0];
  23434.                 filterSoggettoNome = soggettoPerFiltroProprieta.split("/")[1];
  23435.             }
  23436.         } else {
  23437.             try {
  23438.                 tipoServiziProtocollo = Filtri.convertToTipiServizi(protocolloPerFiltroProprieta, null);
  23439.             }catch(Exception e) {
  23440.                 throw new DriverRegistroServiziException(e.getMessage(),e);
  23441.             }
  23442.         }
  23443.         return this.porteDelegateCore.nomiProprietaPD(filterSoggettoTipo, filterSoggettoNome, tipoServiziProtocollo);
  23444.     }
  23445.    
  23446.     public List<String> nomiProprietaPA(String protocolloPerFiltroProprieta , String soggettoPerFiltroProprieta) throws DriverRegistroServiziException, DriverConfigurazioneException {
  23447.         List<String> tipoServiziProtocollo = null;
  23448.         String filterSoggettoTipo = null;
  23449.         String filterSoggettoNome = null;
  23450.         if(soggettoPerFiltroProprieta != null) {
  23451.             if(soggettoPerFiltroProprieta!=null && !"".equals(soggettoPerFiltroProprieta)) {
  23452.                 filterSoggettoTipo = soggettoPerFiltroProprieta.split("/")[0];
  23453.                 filterSoggettoNome = soggettoPerFiltroProprieta.split("/")[1];
  23454.             }
  23455.         } else {
  23456.             try {
  23457.                 tipoServiziProtocollo = Filtri.convertToTipiServizi(protocolloPerFiltroProprieta, null);
  23458.             }catch(Exception e) {
  23459.                 throw new DriverRegistroServiziException(e.getMessage(),e);
  23460.             }
  23461.         }
  23462.         return this.porteApplicativeCore.nomiProprietaPA(filterSoggettoTipo, filterSoggettoNome, tipoServiziProtocollo);
  23463.     }
  23464.    
  23465.     public List<String> nomiProprietaSA(String protocolloPerFiltroProprieta , String soggettoPerFiltroProprieta) throws DriverRegistroServiziException, DriverConfigurazioneException {
  23466.         List<String> tipoSoggettiProtocollo = null;
  23467.         String filterSoggettoTipo = null;
  23468.         String filterSoggettoNome = null;
  23469.         if(soggettoPerFiltroProprieta != null) {
  23470.             if(soggettoPerFiltroProprieta!=null && !"".equals(soggettoPerFiltroProprieta)) {
  23471.                 filterSoggettoTipo = soggettoPerFiltroProprieta.split("/")[0];
  23472.                 filterSoggettoNome = soggettoPerFiltroProprieta.split("/")[1];
  23473.             }
  23474.         } else {
  23475.             try {
  23476.                 tipoSoggettiProtocollo = Filtri.convertToTipiSoggetti(protocolloPerFiltroProprieta, null);
  23477.             }catch(Exception e) {
  23478.                 throw new DriverRegistroServiziException(e.getMessage(),e);
  23479.             }
  23480.         }
  23481.         return this.saCore.nomiProprietaSA(filterSoggettoTipo, filterSoggettoNome, tipoSoggettiProtocollo);
  23482.     }
  23483.    
  23484.     public List<String> nomiProprietaSoggetti(String protocolloPerFiltroProprieta) throws DriverRegistroServiziException, DriverConfigurazioneException {
  23485.         List<String> tipoSoggettiProtocollo = null;
  23486.         try {
  23487.             tipoSoggettiProtocollo = Filtri.convertToTipiSoggetti(protocolloPerFiltroProprieta, null);
  23488.         }catch(Exception e) {
  23489.             throw new DriverRegistroServiziException(e.getMessage(),e);
  23490.         }
  23491.         return this.soggettiCore.nomiProprietaSoggetti(tipoSoggettiProtocollo);
  23492.     }
  23493.    
  23494.     private boolean hasAlmostOneFormElementDefined(List<DataElement> form_elements_to_check) {
  23495.         if(form_elements_to_check!=null) {
  23496.             for (DataElement de : form_elements_to_check) {
  23497.                 // solo i tipi di elemento da controllare
  23498.                 if(de.isElementoDaControllarePerCheckDefaultNelleForm()) {
  23499.                     // valgono solo gli elementi con il default definito
  23500.                     if(de.getValoreDefault() != null) {
  23501.                         if(DataElementType.CHECKBOX.toString().equals(de.getType())) {
  23502.                             if(ServletUtils.isCheckBoxEnabled(de.getSelected()) != de.getValoreDefaultCheckbox()) {
  23503.                                 return true;
  23504.                             }
  23505.                         } else if(DataElementType.SELECT.toString().equals(de.getType())) {
  23506.                             if(!de.getValoreDefault().equals(de.getSelected())) {
  23507.                                 return true;
  23508.                             }
  23509.                         } else if(DataElementType.MULTI_SELECT.toString().equals(de.getType())) {
  23510.                             if(!de.getValoreDefault().equals(de.getSelezionatiAsString()))
  23511.                                 return true;
  23512.                         } else { // text, textarea, numerici e radio
  23513.                             if(!de.getValoreDefault().equals(de.getValue())) {
  23514.                                 return true;
  23515.                             }
  23516.                         }
  23517.                        
  23518.                     }
  23519.                 }
  23520.             }
  23521.         }
  23522.         return false;
  23523.     }
  23524.    
  23525.     public void impostaAperturaTitle(List<DataElement> dati, String titleName) throws DriverControlStationException{
  23526.         this.impostaAperturaTitle(dati, titleName, DataElementType.TITLE, null, this.getPostBackElementName());
  23527.     }
  23528.    
  23529.     public void impostaAperturaTitle(List<DataElement> dati, String titleName, boolean visualizzaSottosezioneAperta) throws DriverControlStationException{
  23530.         this.impostaAperturaTitle(dati, titleName, DataElementType.TITLE, visualizzaSottosezioneAperta, this.getPostBackElementName());
  23531.     }
  23532.    
  23533.     public void impostaAperturaSubTitle(List<DataElement> dati, String titleName) throws DriverControlStationException{
  23534.         this.impostaAperturaTitle(dati, titleName, DataElementType.SUBTITLE, null, this.getPostBackElementName());
  23535.     }
  23536.    
  23537.     public void impostaAperturaSubTitle(List<DataElement> dati, String titleName, boolean visualizzaSottosezioneAperta) throws DriverControlStationException{
  23538.         this.impostaAperturaTitle(dati, titleName, DataElementType.SUBTITLE, visualizzaSottosezioneAperta, this.getPostBackElementName());
  23539.     }
  23540.    
  23541.     private void impostaAperturaTitle(List<DataElement> dati, String titleName, DataElementType titleType, Boolean visualizzaSottosezioneAperta, String postbackElementName) {
  23542.         if(dati != null) {
  23543.             int idxSubtitle = -1;
  23544.             for (int i = 0; i < dati.size(); i++) {
  23545.                 if(titleName.equals(dati.get(i).getName())) {
  23546.                     idxSubtitle = i;
  23547.                     break;
  23548.                 }
  23549.             }
  23550.            
  23551.             if(visualizzaSottosezioneAperta == null) {
  23552.                 // se ho trovato il subtitle allora prendo i filtri successivi
  23553.                 // finche non trovo un altro subtitle o finisce la lista
  23554.                 if(idxSubtitle > -1) {
  23555.                     List<DataElement> filter_values_to_check = new ArrayList<DataElement>();
  23556.                    
  23557.                     for (int i = idxSubtitle + 1; i < dati.size(); i++) {
  23558.                         DataElement de = dati.get(i);
  23559.                         if(de.getType().equals(titleType.toString())) {
  23560.                             // ho trovato un'altra sezione mi fermo
  23561.                             break;
  23562.                         } else {
  23563.                             filter_values_to_check.add(de);
  23564.                         }
  23565.                     }
  23566.                     visualizzaSottosezioneAperta = this.hasAlmostOneFormElementDefined(filter_values_to_check);
  23567.                    
  23568.                     // se c'e' stata una postback la sezione dell'elemento che ha provocato il reload deve restare aperta
  23569.                     if(postbackElementName != null) {
  23570.                         for (int i = 0; i < filter_values_to_check.size(); i++) {
  23571.                             if(filter_values_to_check.get(i).getName().equals(postbackElementName)) {
  23572.                                 visualizzaSottosezioneAperta = true;
  23573.                                 break;
  23574.                             }
  23575.                         }
  23576.                     }
  23577.                 }
  23578.             }
  23579.            
  23580.             boolean v = visualizzaSottosezioneAperta!=null && visualizzaSottosezioneAperta.booleanValue();
  23581.             dati.get(idxSubtitle).setStatoAperturaSezioni(v ? STATO_APERTURA_SEZIONI.APERTO : STATO_APERTURA_SEZIONI.CHIUSO);
  23582.         }
  23583.     }
  23584.    
  23585.     public String formatInfoForView(String info) {
  23586.         if(info==null) {
  23587.             return null;
  23588.         }
  23589.         if(info.length()>this.core.getViewLunghezzaMassimaInformazione()) {
  23590.             return info.substring(0, this.core.getViewLunghezzaMassimaInformazione()) + " ...";
  23591.         }
  23592.         else {
  23593.             return info;
  23594.         }
  23595.     }
  23596.    
  23597.     public void addVerificaCertificatoSceltaAlias(List<String> aliases,List<DataElement> dati) throws DriverControlStationException {
  23598.        
  23599.         DataElement de = new DataElement();
  23600.         de.setType(DataElementType.SELECT);
  23601.         List<String> values = new ArrayList<>();
  23602.         List<String> labels = new ArrayList<>();
  23603.         values.add(CostantiControlStation.LABEL_VERIFICA_CONNETTORE_TUTTI_I_NODI);
  23604.         labels.add(CostantiControlStation.LABEL_VERIFICA_CONNETTORE_TUTTI_I_NODI);
  23605.         values.addAll(this.confCore.getJmxPdDAliases());
  23606.         for (String alias : this.confCore.getJmxPdDAliases()) {
  23607.             try {
  23608.                 labels.add(this.confCore.getJmxPdDDescrizione(alias));
  23609.             }catch(Exception e) {
  23610.                 throw new DriverControlStationException(e.getMessage(),e);
  23611.             }
  23612.         }
  23613.         de.setValues(values);
  23614.         de.setLabels(labels);
  23615.         de.setName(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER);
  23616.         de.setLabel(ConfigurazioneCostanti.LABEL_PARAMETRO_CONFIGURAZIONE_SISTEMA_NODO_CLUSTER);
  23617.         de.setSize(this.getSize());
  23618.         dati.add(de);
  23619.        
  23620.     }
  23621.    
  23622.     public void addDescrizioneVerificaConnettivitaToDati(List<DataElement> dati, Connettore connettore,
  23623.             String server, boolean registro, String aliasConnettore,
  23624.             List<Parameter> downloadCertServerParameters,
  23625.             boolean setTitle, boolean useLabelEndpoint) throws DriverControlStationException {
  23626.        
  23627.         String tipo = ConnettoreCheck.getPropertyValue(connettore, ConnettoreCheck.POLICY_TIPO_ENDPOINT);
  23628.            
  23629.         if(setTitle) {
  23630.             DataElement de = new DataElement();
  23631.             de.setType(DataElementType.TITLE);
  23632.             String label = ConnettoriCostanti.LABEL_CONNETTORE+(tipo!=null ? " "+tipo : "");
  23633.             de.setLabel(label);
  23634.             de.setValue(label);
  23635.             dati.add(de);
  23636.         }
  23637.        
  23638.         if(server!=null && !"".equals(server)) {
  23639.             DataElement de = new DataElement();
  23640.             de.setType(DataElementType.TEXT);
  23641.             de.setLabel(ConnettoriCostanti.LABEL_SERVER);
  23642.             de.setValue(server);
  23643.             dati.add(de);
  23644.         }
  23645.        
  23646.         Map<String,String> properties = connettore.getProperties();
  23647.         String location = properties!=null ? properties.get(CostantiConnettori.CONNETTORE_LOCATION) : null;
  23648.                        
  23649.         DataElement de = new DataElement();
  23650.         de.setType(DataElementType.TEXT);
  23651.         if(useLabelEndpoint) {      
  23652.             de.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_ENDPOINT);
  23653.         }
  23654.         else {
  23655.             de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE);
  23656.         }
  23657.         de.setValue(location);
  23658.         dati.add(de);
  23659.        
  23660.         if(aliasConnettore!=null && !"".equals(aliasConnettore) &&
  23661.                 (TipiConnettore.HTTP.getNome().equalsIgnoreCase(connettore.getTipo()) ||
  23662.                 TipiConnettore.HTTPS.getNome().equalsIgnoreCase(connettore.getTipo()))
  23663.                 ){
  23664.             if(location!=null && !"".equals(location) && location.toLowerCase().startsWith("https")) {
  23665.                 String nomeConnettore = null;
  23666.                 try {
  23667.                     URL url = new URL( location );
  23668.                     String host = url.getHost();
  23669.                     if(host==null || "".equals(host)) {
  23670.                         throw new DriverControlStationException("L'endpoint '"+host+"' non contiene un host");
  23671.                     }
  23672.                     nomeConnettore = host;
  23673.                     int port = url.getPort();
  23674.                     if(port>0 && port!=443) {
  23675.                         nomeConnettore=nomeConnettore+"_"+port;
  23676.                     }
  23677.                    
  23678.                     de = new DataElement();
  23679.                     de.setType(DataElementType.LINK);
  23680.                     de.setValue(ConnettoriCostanti.LABEL_DOWNLOAD_CERTIFICATI_SERVER);
  23681.                    
  23682.                     downloadCertServerParameters.add(new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_CONNETTORE_CERTIFICATO_SERVER));
  23683.                     downloadCertServerParameters.add(new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_CONNETTORE_CERTIFICATO_SERVER));
  23684.                     downloadCertServerParameters.add(new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_CERTIFICATI_SERVER_TIPO_CONNETTORE_REGISTRO, registro ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED));
  23685.                     downloadCertServerParameters.add(new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_CERTIFICATI_SERVER_ALIAS_CONNETTORE, aliasConnettore));
  23686.                     downloadCertServerParameters.add(new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_CERTIFICATI_SERVER_NOME_CONNETTORE, nomeConnettore));
  23687.                     de.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT,
  23688.                             downloadCertServerParameters.toArray(new Parameter[1]));
  23689.                     dati.add(de);
  23690.                    
  23691.                 }catch(Exception e) {
  23692.                     this.logError("Errore durante l'identificazione dell'endpoint: "+e.getMessage(),e);
  23693.                 }
  23694.             }
  23695.         }
  23696.        
  23697.         if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_CONNECTION_TIMEOUT)) {
  23698.            
  23699.             de = new DataElement();
  23700.             de.setType(DataElementType.TEXT);
  23701.             de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_CONNECTION_TIMEOUT);
  23702.             de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_CONNECTION_TIMEOUT));
  23703.             dati.add(de);
  23704.            
  23705.         }
  23706.        
  23707.         if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_USERNAME)) {
  23708.            
  23709.             de = new DataElement();
  23710.             de.setType(DataElementType.SUBTITLE);
  23711.             de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTP);
  23712.             de.setValue(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTP);
  23713.             dati.add(de);
  23714.        
  23715.             de = new DataElement();
  23716.             de.setType(DataElementType.TEXT);
  23717.             de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTP_USERNAME);
  23718.             de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_USERNAME));
  23719.             dati.add(de);
  23720.            
  23721.             /** Informazione sensibile if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_PASSWORD)) {
  23722.                
  23723.                 de = new DataElement();
  23724.                 de.setType(DataElementType.TEXT);
  23725.                 de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTP_PASSWORD);
  23726.                 String pw = connettore.getProperties().get(CostantiConnettori.CONNETTORE_PASSWORD);
  23727.                 de.setValue(pw!=null ? StringEscapeUtils.escapeHtml(pw) : pw);
  23728.                 dati.add(de);
  23729.                
  23730.             }*/
  23731.            
  23732.         }
  23733.        
  23734.         if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_TOKEN_POLICY)) {
  23735.            
  23736.             de = new DataElement();
  23737.             de.setType(DataElementType.SUBTITLE);
  23738.             de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_TOKEN);
  23739.             de.setValue(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_TOKEN);
  23740.             dati.add(de);
  23741.        
  23742.             de = new DataElement();
  23743.             de.setType(DataElementType.TEXT);
  23744.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TOKEN_POLICY);
  23745.             de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_TOKEN_POLICY));
  23746.             dati.add(de);
  23747.            
  23748.         }
  23749.        
  23750.         if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_APIKEY)) {
  23751.            
  23752.             de = new DataElement();
  23753.             de.setType(DataElementType.SUBTITLE);
  23754.             de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_API_KEY);
  23755.             de.setValue(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_API_KEY);
  23756.             dati.add(de);
  23757.        
  23758.             String apiKeyHeader = connettore.getProperties().get(CostantiConnettori.CONNETTORE_APIKEY_HEADER);
  23759.             if(apiKeyHeader==null || StringUtils.isEmpty(apiKeyHeader)) {
  23760.                 apiKeyHeader = CostantiConnettori.DEFAULT_HEADER_API_KEY;
  23761.             }
  23762.            
  23763.             de = new DataElement();
  23764.             de.setType(DataElementType.TEXT);
  23765.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_VALUE);
  23766.             de.setValue(StringEscapeUtils.escapeHtml(apiKeyHeader+": ******"));
  23767.             /**de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_APIKEY));Informazione sensibile*/
  23768.             dati.add(de);
  23769.            
  23770.             if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_APIKEY_APPID)) {
  23771.                            
  23772.                 String appIdHeader = connettore.getProperties().get(CostantiConnettori.CONNETTORE_APIKEY_APPID_HEADER);
  23773.                 if(appIdHeader==null || StringUtils.isEmpty(appIdHeader)) {
  23774.                     appIdHeader = CostantiConnettori.DEFAULT_HEADER_APP_ID;
  23775.                 }
  23776.                
  23777.                 de = new DataElement();
  23778.                 de.setType(DataElementType.TEXT);
  23779.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE);
  23780.                 de.setValue(StringEscapeUtils.escapeHtml(appIdHeader+": "+connettore.getProperties().get(CostantiConnettori.CONNETTORE_APIKEY_APPID)));
  23781.                 dati.add(de);
  23782.                
  23783.             }
  23784.         }
  23785.        
  23786.         boolean trustAllCerts = false;
  23787.         if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTPS_TRUST_ALL_CERTS)) {
  23788.             String v = connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTPS_TRUST_ALL_CERTS);
  23789.             if("true".equalsIgnoreCase(v)) {
  23790.                 trustAllCerts = true;
  23791.             }
  23792.         }
  23793.        
  23794.         if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTPS_TRUST_STORE_LOCATION) ||
  23795.                 trustAllCerts) {
  23796.        
  23797.             de = new DataElement();
  23798.             de.setType(DataElementType.SUBTITLE);
  23799.             de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS);
  23800.             de.setValue(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS);
  23801.             dati.add(de);
  23802.        
  23803.             if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTPS_SSL_TYPE)) {
  23804.                
  23805.                 de = new DataElement();
  23806.                 de.setType(DataElementType.TEXT);
  23807.                 de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS_SSL_TYPE);
  23808.                 de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTPS_SSL_TYPE));
  23809.                 dati.add(de);
  23810.                
  23811.             }
  23812.             if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTPS_HOSTNAME_VERIFIER)) {
  23813.                
  23814.                 de = new DataElement();
  23815.                 de.setType(DataElementType.TEXT);
  23816.                 de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS_HOSTNAME_VERIFIER);
  23817.                 de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTPS_HOSTNAME_VERIFIER));
  23818.                 dati.add(de);
  23819.                
  23820.             }
  23821.                
  23822.             de = new DataElement();
  23823.             de.setType(DataElementType.TEXT);
  23824.             de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS_TRUSTSTORE);
  23825.             if(trustAllCerts) {
  23826.                 de.setValue(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS_TRUST_ALL_CERTS);
  23827.             }
  23828.             else {
  23829.                 de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTPS_TRUST_STORE_LOCATION));
  23830.             }
  23831.             dati.add(de);
  23832.                
  23833.             if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTPS_TRUST_STORE_CRLS)) {
  23834.                
  23835.                 de = new DataElement();
  23836.                 de.setType(DataElementType.TEXT);
  23837.                 de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS_TRUSTSTORE_CRLS);
  23838.                 de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTPS_TRUST_STORE_CRLS));
  23839.                 dati.add(de);
  23840.                
  23841.             }
  23842.            
  23843.             if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY)) {
  23844.                
  23845.                 de = new DataElement();
  23846.                 de.setType(DataElementType.TEXT);
  23847.                 de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS_TRUSTSTORE_OCSP_POLICY);
  23848.                 String ocspPolicy = connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY);
  23849.                 String value = null;
  23850.                 try {
  23851.                     if(ocspPolicy!=null) {
  23852.                         String label = OCSPManager.getInstance().getOCSPConfig(ocspPolicy).getLabel();
  23853.                         value = ((label!=null && StringUtils.isNotEmpty(label)) ? label : ocspPolicy);
  23854.                     }
  23855.                 }catch(Throwable t) {
  23856.                     value = ocspPolicy;
  23857.                 }
  23858.                 de.setValue(value);
  23859.                 dati.add(de);
  23860.                
  23861.             }
  23862.            
  23863.             if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTPS_KEY_STORE_LOCATION)) {
  23864.                
  23865.                 de = new DataElement();
  23866.                 de.setType(DataElementType.TEXT);
  23867.                 de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS_KEYSTORE);
  23868.                 de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTPS_KEY_STORE_LOCATION));
  23869.                 dati.add(de);
  23870.                
  23871.                 if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTPS_KEY_ALIAS)) {
  23872.                    
  23873.                     de = new DataElement();
  23874.                     de.setType(DataElementType.TEXT);
  23875.                     de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS_KEY_ALIAS);
  23876.                     de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTPS_KEY_ALIAS));
  23877.                     dati.add(de);
  23878.                    
  23879.                 }
  23880.                
  23881.                 if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY)) {
  23882.                    
  23883.                     de = new DataElement();
  23884.                     de.setType(DataElementType.TEXT);
  23885.                     de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_HTTPS_KEYSTORE_BYOK_POLICY);
  23886.                     String byokPolicy = connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY);
  23887.                     String value = null;
  23888.                     try {
  23889.                         if(byokPolicy!=null) {
  23890.                             String label = BYOKManager.getInstance().getKMSConfigByType(byokPolicy).getLabel();
  23891.                             value = ((label!=null && StringUtils.isNotEmpty(label)) ? label : byokPolicy);
  23892.                         }
  23893.                     }catch(Exception t) {
  23894.                         value = byokPolicy;
  23895.                     }
  23896.                     de.setValue(value);
  23897.                     dati.add(de);
  23898.                    
  23899.                 }
  23900.                
  23901.             }
  23902.         }
  23903.        
  23904.         if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTP_PROXY_HOSTNAME)) {
  23905.            
  23906.             de = new DataElement();
  23907.             de.setType(DataElementType.SUBTITLE);
  23908.             de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_PROXY);
  23909.             de.setValue(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_PROXY);
  23910.             dati.add(de);
  23911.        
  23912.             de = new DataElement();
  23913.             de.setType(DataElementType.TEXT);
  23914.             de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_PROXY_HOSTNAME);
  23915.             de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTP_PROXY_HOSTNAME));
  23916.             dati.add(de);
  23917.            
  23918.             if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTP_PROXY_PORT)) {
  23919.                
  23920.                 de = new DataElement();
  23921.                 de.setType(DataElementType.TEXT);
  23922.                 de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_PROXY_PORT);
  23923.                 de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTP_PROXY_PORT));
  23924.                 dati.add(de);
  23925.                
  23926.             }
  23927.            
  23928.             if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTP_PROXY_USERNAME)) {
  23929.                
  23930.                 de = new DataElement();
  23931.                 de.setType(DataElementType.TEXT);
  23932.                 de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_PROXY_USERNAME);
  23933.                 de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTP_PROXY_USERNAME));
  23934.                 dati.add(de);
  23935.                
  23936.             }

  23937.             if(connettore.getProperties().containsKey(CostantiConnettori.CONNETTORE_HTTP_PROXY_PASSWORD)) {
  23938.                
  23939.                 de = new DataElement();
  23940.                 de.setType(DataElementType.TEXT);
  23941.                 de.setLabel(ConnettoriCostanti.LABEL_VERIFICA_CONNETTORE_DETAILS_PROXY_PASSWORD);
  23942.                 de.setValue(connettore.getProperties().get(CostantiConnettori.CONNETTORE_HTTP_PROXY_PASSWORD));
  23943.                 dati.add(de);
  23944.                
  23945.             }
  23946.         }
  23947.        
  23948.     }
  23949.    
  23950.    
  23951.     public void addProprietaOggetto(List<DataElement> dati, org.openspcoop2.core.registry.ProprietaOggetto pOggetto) {
  23952.         if(pOggetto!=null) {
  23953.             // Creazione
  23954.             if(pOggetto.getDataCreazione()!=null || pOggetto.getUtenteRichiedente()!=null) {
  23955.                 addProprietaOggettoCreazione(dati, pOggetto.getDataCreazione(), pOggetto.getUtenteRichiedente());
  23956.             }
  23957.            
  23958.             // Aggiornamento
  23959.             if(pOggetto.getDataUltimaModifica()!=null || pOggetto.getUtenteUltimaModifica()!=null) {
  23960.                 addProprietaOggettoAggiornamento(dati, pOggetto.getDataUltimaModifica(), pOggetto.getUtenteUltimaModifica());
  23961.             }
  23962.         }
  23963.     }
  23964.     public void addProprietaOggetto(List<DataElement> dati, org.openspcoop2.core.config.ProprietaOggetto pOggetto) {
  23965.         if(pOggetto!=null) {
  23966.             // Creazione
  23967.             if(pOggetto.getDataCreazione()!=null || pOggetto.getUtenteRichiedente()!=null) {
  23968.                 addProprietaOggettoCreazione(dati, pOggetto.getDataCreazione(), pOggetto.getUtenteRichiedente());
  23969.             }
  23970.            
  23971.             // Aggiornamento
  23972.             if(pOggetto.getDataUltimaModifica()!=null || pOggetto.getUtenteUltimaModifica()!=null) {
  23973.                 addProprietaOggettoAggiornamento(dati, pOggetto.getDataUltimaModifica(), pOggetto.getUtenteUltimaModifica());
  23974.             }
  23975.         }
  23976.     }
  23977.     private void addProprietaOggettoCreazione(List<DataElement> dati, Date dataCreazione, String utenteRichiedente) {
  23978.         DataElement de = new DataElement();
  23979.         de.setType(DataElementType.IMAGE);
  23980.         de.setLabel(CostantiControlStation.LABEL_CREAZIONE);
  23981.         if(dataCreazione!=null) {
  23982.             String data = CostantiControlStation.formatDateMinute(dataCreazione);
  23983.             String dataMs = CostantiControlStation.formatDateMs(dataCreazione);
  23984.             de.addInfoAuditDataCreazione(dataMs, data);
  23985.         }
  23986.         if(utenteRichiedente!=null) {
  23987.             de.addInfoAuditUtente(utenteRichiedente, utenteRichiedente);
  23988.         }
  23989.         dati.add(de);
  23990.     }
  23991.     private void addProprietaOggettoAggiornamento(List<DataElement> dati, Date dataUltimaModifica, String utenteUltimaModifica) {
  23992.         DataElement de = new DataElement();
  23993.         de.setType(DataElementType.IMAGE);
  23994.         de.setLabel(CostantiControlStation.LABEL_ULTIMA_MODIFICA);
  23995.         if(dataUltimaModifica!=null) {
  23996.             String data = CostantiControlStation.formatDateMinute(dataUltimaModifica);
  23997.             String dataMs = CostantiControlStation.formatDateMs(dataUltimaModifica);
  23998.             de.addInfoAuditDataAggiornamento(dataMs, data);
  23999.         }
  24000.         if(utenteUltimaModifica!=null) {
  24001.             de.addInfoAuditUtente(utenteUltimaModifica, utenteUltimaModifica);
  24002.         }
  24003.         dati.add(de);
  24004.     }
  24005.    
  24006.     public ProprietaOggetto convertToProprietaOggettoRegistro(org.openspcoop2.core.config.ProprietaOggetto pConfig) {
  24007.         ProprietaOggetto p = null;
  24008.         if(pConfig!=null) {
  24009.             p = new ProprietaOggetto();
  24010.             p.setDataCreazione(pConfig.getDataCreazione());
  24011.             p.setDataUltimaModifica(pConfig.getDataUltimaModifica());
  24012.             p.setUtenteRichiedente(pConfig.getUtenteRichiedente());
  24013.             p.setUtenteUltimaModifica(pConfig.getUtenteUltimaModifica());
  24014.         }
  24015.         return p;
  24016.     }
  24017.    
  24018.     public ProprietaOggetto mergeProprietaOggetto(ProprietaOggetto pRegistry, org.openspcoop2.core.config.ProprietaOggetto pConfigPorta, boolean consideraDataCreazioneComeDataModifica) {
  24019.         ProprietaOggetto p = null;
  24020.         if(pRegistry!=null &&
  24021.             (pRegistry.getDataCreazione()!=null || pRegistry.getUtenteRichiedente()!=null ||
  24022.                     pRegistry.getDataUltimaModifica()!=null || pRegistry.getUtenteUltimaModifica()!=null)
  24023.             ){
  24024.             p = new ProprietaOggetto();
  24025.             p.setDataCreazione(pRegistry.getDataCreazione());
  24026.             p.setUtenteRichiedente(pRegistry.getUtenteRichiedente());
  24027.             p.setDataUltimaModifica(pRegistry.getDataUltimaModifica());
  24028.             p.setUtenteUltimaModifica(pRegistry.getUtenteUltimaModifica());
  24029.         }
  24030.        
  24031.         return mergeProprietaOggettoEngine(p, pConfigPorta, consideraDataCreazioneComeDataModifica);
  24032.     }
  24033.    
  24034.     private ProprietaOggetto mergeProprietaOggettoEngine(ProprietaOggetto p, org.openspcoop2.core.config.ProprietaOggetto pConfigPorta, boolean consideraDataCreazioneComeDataModifica) {
  24035.         if(pConfigPorta!=null &&
  24036.             (pConfigPorta.getDataUltimaModifica()!=null)
  24037.             ){
  24038.             mergeProprietaOggettoEngineInitUpdate(p, pConfigPorta);
  24039.         }
  24040.         else if(consideraDataCreazioneComeDataModifica && pConfigPorta!=null &&
  24041.                 (pConfigPorta.getDataUltimaModifica()==null) &&
  24042.                 (pConfigPorta.getDataCreazione()!=null)
  24043.                 ){
  24044.             mergeProprietaOggettoEngineInitCreate(p, pConfigPorta);
  24045.         }
  24046.         return p;
  24047.     }
  24048.     private ProprietaOggetto mergeProprietaOggettoEngineInit(ProprietaOggetto p, org.openspcoop2.core.config.ProprietaOggetto pConfigPorta) {
  24049.         if(p==null) {
  24050.             p = new ProprietaOggetto();
  24051.             p.setDataCreazione(pConfigPorta.getDataCreazione());
  24052.             p.setUtenteRichiedente(pConfigPorta.getUtenteRichiedente());
  24053.             p.setDataUltimaModifica(pConfigPorta.getDataUltimaModifica());
  24054.             p.setUtenteUltimaModifica(pConfigPorta.getUtenteUltimaModifica());
  24055.         }
  24056.         return p;
  24057.     }
  24058.     private ProprietaOggetto mergeProprietaOggettoEngineInitUpdate(ProprietaOggetto p, org.openspcoop2.core.config.ProprietaOggetto pConfigPorta){
  24059.         if(p==null) {
  24060.             p = mergeProprietaOggettoEngineInit(p, pConfigPorta);
  24061.         }
  24062.         else if(p.getDataUltimaModifica()==null || p.getDataUltimaModifica().before(pConfigPorta.getDataUltimaModifica())) {
  24063.             p.setDataUltimaModifica(pConfigPorta.getDataUltimaModifica());
  24064.             if(pConfigPorta.getUtenteUltimaModifica()!=null) {
  24065.                 p.setUtenteUltimaModifica(pConfigPorta.getUtenteUltimaModifica());
  24066.             }
  24067.         }
  24068.         return p;
  24069.     }
  24070.     private ProprietaOggetto mergeProprietaOggettoEngineInitCreate(ProprietaOggetto p, org.openspcoop2.core.config.ProprietaOggetto pConfigPorta){
  24071.         if(p==null) {
  24072.             p = mergeProprietaOggettoEngineInit(p, pConfigPorta);
  24073.         }
  24074.         else if(p.getDataUltimaModifica()==null || p.getDataUltimaModifica().before(pConfigPorta.getDataCreazione())) {
  24075.             p.setDataUltimaModifica(pConfigPorta.getDataCreazione());
  24076.             if(pConfigPorta.getUtenteRichiedente()!=null) {
  24077.                 p.setUtenteUltimaModifica(pConfigPorta.getUtenteRichiedente());
  24078.             }
  24079.         }
  24080.         return p;
  24081.     }
  24082.    
  24083.     protected void impostaComandiMenuContestuale(AccordoServizioParteSpecifica asps, String protocollo, boolean gestioneFruitori,
  24084.             Fruitore fruitore,
  24085.             boolean showVerificaCertificati, List<Parameter> listaParametriChange,
  24086.             List<Parameter> listParametersVerificaCertificati,
  24087.             List<Parameter> listParametersFruitoriVerificaCertificati,
  24088.             ProprietaOggetto pOggetto, boolean visualizzaInUsoButton) throws DriverControlStationException, DriverRegistroServiziException {
  24089.         this.impostaComandiMenuContestuale(asps, protocollo, gestioneFruitori, fruitore, showVerificaCertificati, listaParametriChange,
  24090.                 listParametersVerificaCertificati, listParametersFruitoriVerificaCertificati, pOggetto, visualizzaInUsoButton, true);
  24091.     }

  24092.     protected void impostaComandiMenuContestuale(AccordoServizioParteSpecifica asps, String protocollo, boolean gestioneFruitori,
  24093.             Fruitore fruitore,
  24094.             boolean showVerificaCertificati, List<Parameter> listaParametriChange,
  24095.             List<Parameter> listParametersVerificaCertificati,
  24096.             List<Parameter> listParametersFruitoriVerificaCertificati,
  24097.             ProprietaOggetto pOggetto, boolean visualizzaInUsoButton, boolean utilizzaServizioCondiviso) throws DriverControlStationException, DriverRegistroServiziException {
  24098.        
  24099.         boolean root = pOggetto!=null;
  24100.        
  24101.         String uriASPS = this.idServizioFactory.getUriFromAccordo(asps);
  24102.        
  24103.         IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromAccordo(asps);
  24104.        
  24105.         IDSoggetto idSoggettoFruitore = null;
  24106.         if(gestioneFruitori) {
  24107.             idSoggettoFruitore = new IDSoggetto(fruitore.getTipo(), fruitore.getNome());
  24108.         }
  24109.        
  24110.         String idServizioButton = gestioneFruitori ? uriASPS+"@"+fruitore.getTipo()+"/"+fruitore.getNome() : uriASPS;
  24111.        
  24112.         String labelServizioConFruitore = this.getLabelServizio(idSoggettoFruitore, gestioneFruitori, idServizio, protocollo);
  24113.        
  24114.         // In Uso Button
  24115.         if(visualizzaInUsoButton) {
  24116.             this.addComandoInUsoInfoButton(labelServizioConFruitore,
  24117.                 idServizioButton,
  24118.                 gestioneFruitori ? InUsoType.FRUIZIONE_INFO : InUsoType.EROGAZIONE_INFO);
  24119.         }
  24120.        
  24121.         // Verifica Certificati
  24122.         if(showVerificaCertificati) {
  24123.             if(gestioneFruitori) {
  24124.                 this.addComandoVerificaCertificatiElementoButton(utilizzaServizioCondiviso, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_VERIFICA_CERTIFICATI, listParametersFruitoriVerificaCertificati, InUsoType.FRUIZIONE);
  24125.             }
  24126.             else {
  24127.                 this.addComandoVerificaCertificatiElementoButton(utilizzaServizioCondiviso, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_VERIFICA_CERTIFICATI, listParametersVerificaCertificati, InUsoType.EROGAZIONE);
  24128.             }
  24129.         }
  24130.        
  24131.         // se e' abilitata l'opzione reset cache per elemento, visualizzo il comando nell'elenco dei comandi disponibili nella lista
  24132.         if(this.core.isElenchiVisualizzaComandoResetCacheSingoloElemento()){
  24133.             this.addComandoResetCacheElementoButton(utilizzaServizioCondiviso, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_CHANGE, listaParametriChange,
  24134.                     gestioneFruitori ? InUsoType.FRUIZIONE : InUsoType.EROGAZIONE);
  24135.         }
  24136.        
  24137.         // Proprieta Button
  24138.        
  24139.         if(gestioneFruitori &&
  24140.                 root &&
  24141.                 this.existsProprietaOggetto(pOggetto, fruitore.getDescrizione())) {
  24142.             this.addComandoProprietaOggettoButton(labelServizioConFruitore, idServizioButton,
  24143.                     InUsoType.FRUIZIONE);
  24144.         }
  24145.         else if(!gestioneFruitori &&
  24146.                 root &&
  24147.                 this.existsProprietaOggetto(pOggetto, asps.getDescrizione())) {
  24148.             this.addComandoProprietaOggettoButton(labelServizioConFruitore, idServizioButton,
  24149.                     InUsoType.EROGAZIONE);
  24150.         }
  24151.     }
  24152.    
  24153.     public void impostaComandiMenuContestualePD(String idSoggFruitoreDelServizio,
  24154.             Parameter parametroTipoSoggettoFruitore, Parameter parametroNomeSoggettoFruitore,
  24155.             AccordoServizioParteSpecifica asps, String protocollo, Parameter pIdSoggettoErogatore, Fruitore fru,
  24156.             Parameter pIdFruitore, Parameter pNomeServizio, Parameter pTipoServizio)
  24157.             throws DriverRegistroServiziException, DriverControlStationException {
  24158.         // visualizzo menu' contestuale
  24159.        
  24160.         boolean showVerificaCertificati = this.core.isFruizioniVerificaCertificati();
  24161.         List<Parameter> listaParametriChange = new ArrayList<>();      
  24162.         listaParametriChange.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId() + ""));
  24163.         listaParametriChange.add(pNomeServizio);
  24164.         listaParametriChange.add(pTipoServizio);
  24165.         listaParametriChange.add(pIdSoggettoErogatore);
  24166.         listaParametriChange.add(parametroTipoSoggettoFruitore);
  24167.         listaParametriChange.add(parametroNomeSoggettoFruitore);
  24168.            
  24169.         Parameter pIdProviderFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE, idSoggFruitoreDelServizio + "");
  24170.         listaParametriChange.add(pIdProviderFruitore);
  24171.        
  24172.         List<Parameter> listParametersServizioFruitoriModificaProfiloOrVerificaCertificati = null;
  24173.         if(showVerificaCertificati) {
  24174.             listParametersServizioFruitoriModificaProfiloOrVerificaCertificati = new ArrayList<>();
  24175.             listParametersServizioFruitoriModificaProfiloOrVerificaCertificati.addAll(listaParametriChange);
  24176.             listParametersServizioFruitoriModificaProfiloOrVerificaCertificati.add(pIdFruitore);
  24177.         }
  24178.        
  24179.         this.impostaComandiMenuContestuale(asps, protocollo, true, fru, showVerificaCertificati, listaParametriChange, null, listParametersServizioFruitoriModificaProfiloOrVerificaCertificati, null, true);
  24180.     }
  24181.    
  24182.     public void impostaComandiMenuContestualePA(AccordoServizioParteSpecifica asps, String protocollo)
  24183.             throws DriverRegistroServiziException, DriverControlStationException {
  24184.    
  24185.         Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  24186.         Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  24187.         Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, asps.getIdSoggetto()+"");
  24188.        
  24189.         this.impostaComandiMenuContestualePA(asps, protocollo, pNomeServizio, pTipoServizio, pIdSoggettoErogatore);
  24190.     }
  24191.    
  24192.     public void impostaComandiMenuContestualePA(AccordoServizioParteSpecifica asps, String protocollo, Parameter pNomeServizio,
  24193.             Parameter pTipoServizio, Parameter pIdSoggettoErogatore)
  24194.             throws DriverRegistroServiziException, DriverControlStationException {
  24195.         // visualizzo menu' contestuale
  24196.         boolean gestioneFruitori = false;
  24197.        
  24198.         boolean showVerificaCertificati = this.core.isFruizioniVerificaCertificati();
  24199.         List<Parameter> listaParametriChange = new ArrayList<>();      
  24200.         listaParametriChange.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId() + ""));
  24201.         listaParametriChange.add(pNomeServizio);
  24202.         listaParametriChange.add(pTipoServizio);
  24203.         listaParametriChange.add(pIdSoggettoErogatore);
  24204.        
  24205.         List<Parameter> listParametersServizioModificaProfiloOrVerificaCertificati = null;
  24206.         if(showVerificaCertificati) {
  24207.             listParametersServizioModificaProfiloOrVerificaCertificati = new ArrayList<>();
  24208.             listParametersServizioModificaProfiloOrVerificaCertificati.addAll(listaParametriChange);
  24209.         }
  24210.        
  24211.         this.impostaComandiMenuContestuale(asps, protocollo, gestioneFruitori, null, showVerificaCertificati, listaParametriChange, listParametersServizioModificaProfiloOrVerificaCertificati, null, null, true);
  24212.     }
  24213. }