PorteDelegateHelper.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.pd;

  21. import java.text.MessageFormat;
  22. import java.util.ArrayList;
  23. import java.util.Collections;
  24. import java.util.Iterator;
  25. import java.util.List;
  26. import java.util.Map;

  27. import javax.servlet.http.HttpServletRequest;
  28. import javax.servlet.http.HttpSession;

  29. import org.apache.commons.lang.StringUtils;
  30. import org.openspcoop2.core.commons.ISearch;
  31. import org.openspcoop2.core.commons.Liste;
  32. import org.openspcoop2.core.commons.ModalitaIdentificazione;
  33. import org.openspcoop2.core.config.CorrelazioneApplicativaElemento;
  34. import org.openspcoop2.core.config.CorrelazioneApplicativaRispostaElemento;
  35. import org.openspcoop2.core.config.MessageSecurity;
  36. import org.openspcoop2.core.config.MessageSecurityFlowParameter;
  37. import org.openspcoop2.core.config.MtomProcessorFlowParameter;
  38. import org.openspcoop2.core.config.PortaDelegata;
  39. import org.openspcoop2.core.config.PortaDelegataServizioApplicativo;
  40. import org.openspcoop2.core.config.Proprieta;
  41. import org.openspcoop2.core.config.ResponseCachingConfigurazioneRegola;
  42. import org.openspcoop2.core.config.ServizioApplicativo;
  43. import org.openspcoop2.core.config.TrasformazioneRegola;
  44. import org.openspcoop2.core.config.TrasformazioneRegolaApplicabilitaRichiesta;
  45. import org.openspcoop2.core.config.TrasformazioneRegolaApplicabilitaRisposta;
  46. import org.openspcoop2.core.config.TrasformazioneRegolaApplicabilitaServizioApplicativo;
  47. import org.openspcoop2.core.config.TrasformazioneRegolaParametro;
  48. import org.openspcoop2.core.config.TrasformazioneRegolaRisposta;
  49. import org.openspcoop2.core.config.Trasformazioni;
  50. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  51. import org.openspcoop2.core.config.constants.CredenzialeTipo;
  52. import org.openspcoop2.core.config.constants.MTOMProcessorType;
  53. import org.openspcoop2.core.config.constants.PortaDelegataAzioneIdentificazione;
  54. import org.openspcoop2.core.config.constants.RuoloContesto;
  55. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  56. import org.openspcoop2.core.config.constants.TipoAutenticazione;
  57. import org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal;
  58. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  59. import org.openspcoop2.core.config.driver.DriverConfigurazioneNotFound;
  60. import org.openspcoop2.core.constants.TipoPdD;
  61. import org.openspcoop2.core.controllo_traffico.constants.RuoloPolicy;
  62. import org.openspcoop2.core.id.IDPortaDelegata;
  63. import org.openspcoop2.core.id.IDServizio;
  64. import org.openspcoop2.core.id.IDServizioApplicativo;
  65. import org.openspcoop2.core.id.IDSoggetto;
  66. import org.openspcoop2.core.mapping.MappingFruizionePortaDelegata;
  67. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  68. import org.openspcoop2.core.registry.Fruitore;
  69. import org.openspcoop2.core.registry.Ruolo;
  70. import org.openspcoop2.core.registry.Scope;
  71. import org.openspcoop2.core.registry.Soggetto;
  72. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  73. import org.openspcoop2.core.registry.constants.CostantiRegistroServizi;
  74. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  75. import org.openspcoop2.core.registry.driver.DriverRegistroServiziNotFound;
  76. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  77. import org.openspcoop2.message.constants.ServiceBinding;
  78. import org.openspcoop2.pdd.config.UrlInvocazioneAPI;
  79. import org.openspcoop2.pdd.core.dynamic.DynamicHelperCostanti;
  80. import org.openspcoop2.pdd.core.integrazione.GruppoIntegrazione;
  81. import org.openspcoop2.protocol.basic.config.SubscriptionConfiguration;
  82. import org.openspcoop2.protocol.engine.ProtocolFactoryManager;
  83. import org.openspcoop2.protocol.sdk.ProtocolException;
  84. import org.openspcoop2.protocol.sdk.constants.ConsoleInterfaceType;
  85. import org.openspcoop2.protocol.sdk.constants.FunzionalitaProtocollo;
  86. import org.openspcoop2.utils.certificate.byok.BYOKManager;
  87. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  88. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  89. import org.openspcoop2.web.ctrlstat.core.ControlStationCoreException;
  90. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  91. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationNotFound;
  92. import org.openspcoop2.web.ctrlstat.plugins.IExtendedListServlet;
  93. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCostanti;
  94. import org.openspcoop2.web.ctrlstat.servlet.aps.erogazioni.ErogazioniCostanti;
  95. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCostanti;
  96. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriHelper;
  97. import org.openspcoop2.web.ctrlstat.servlet.protocol_properties.ProtocolPropertiesUtilities;
  98. import org.openspcoop2.web.ctrlstat.servlet.ruoli.RuoliCostanti;
  99. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCostanti;
  100. import org.openspcoop2.web.ctrlstat.servlet.scope.ScopeCostanti;
  101. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCostanti;
  102. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  103. import org.openspcoop2.web.lib.mvc.CheckboxStatusType;
  104. import org.openspcoop2.web.lib.mvc.DataElement;
  105. import org.openspcoop2.web.lib.mvc.DataElementImage;
  106. import org.openspcoop2.web.lib.mvc.DataElementInfo;
  107. import org.openspcoop2.web.lib.mvc.DataElementType;
  108. import org.openspcoop2.web.lib.mvc.PageData;
  109. import org.openspcoop2.web.lib.mvc.Parameter;
  110. import org.openspcoop2.web.lib.mvc.ServletUtils;
  111. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  112. /**
  113.  * PorteDelegateHelper
  114.  *
  115.  * @author Poli Andrea (apoli@link.it)
  116.  * @author $Author$
  117.  * @version $Rev$, $Date$
  118.  */
  119. public class PorteDelegateHelper extends ConnettoriHelper {
  120.    
  121.    
  122.     public PorteDelegateHelper(HttpServletRequest request, PageData pd,
  123.             HttpSession session) throws Exception {
  124.         super(request, pd,  session);
  125.     }
  126.     public PorteDelegateHelper(ControlStationCore core, HttpServletRequest request, PageData pd,
  127.             HttpSession session) throws Exception {
  128.         super(core, request, pd,  session);
  129.     }
  130.    
  131.     public List<DataElement> addPorteDelegateToDati(TipoOperazione tipoOp, String idsogg,
  132.             String nomePorta, List<DataElement> dati, String idPorta,
  133.             String descr, String autenticazione,
  134.             String autorizzazione, String soggid,
  135.             String[] soggettiList, String[] soggettiListLabel, String sp,
  136.             String tiposp, String patternErogatore,
  137.             String servid, String[] serviziList, String[] serviziListLabel,
  138.             String servizio, String tiposervizio,String versioneServizio, String patternServizio,
  139.             String modeaz, String azid, String[] azioniListLabel,
  140.             String[] azioniList, String azione, String patternAzione,
  141.             long totAzioni,  String stateless, String localForward, String paLocalForward, String ricsim,
  142.             String ricasim, String statoValidazione, String tipoValidazione,
  143.             int numCorrApp, String scadcorr, String gestBody,
  144.             String gestManifest, String integrazioneStato, String integrazione,
  145.             String[] integrazioneGruppi, List<GruppoIntegrazione> integrazioneGruppiDaVisualizzare, Map<String, List<String>> integrazioneGruppiValoriDeiGruppi,
  146.             String autenticazioneOpzionale, TipoAutenticazionePrincipal autenticazionePrincipal, List<String> autenticazioneParametroList, String autenticazioneCustom,
  147.             String autorizzazioneCustom,String autorizzazioneAutenticati,String autorizzazioneRuoli,String autorizzazioneRuoliTipologia,
  148.             String autorizzazioneContenutiStato, String autorizzazioneContenuti, String autorizzazioneContenutiProperties, String idsogg2, String protocollo,
  149.             int numSA, int numRuoli, String ruoloMatch, String statoMessageSecurity,String statoMTOM ,int numCorrelazioneReq ,
  150.             int numCorrelazioneRes,String forceWsdlBased, String applicaMTOM,
  151.             boolean riusoId,
  152.             AccordoServizioParteSpecifica asps, AccordoServizioParteComuneSintetico aspc,ServiceBinding serviceBinding,
  153.             String statoPorta, boolean usataInConfigurazioni, boolean usataInConfigurazioneDefault,
  154.             boolean ricercaPortaAzioneDelegata, String nomePortaDelegante, String gestioneToken, String[] gestioneTokenPolicyLabels, String[] gestioneTokenPolicyValues,
  155.             String gestioneTokenPolicy, String gestioneTokenOpzionale,
  156.             String gestioneTokenValidazioneInput, String gestioneTokenIntrospection, String gestioneTokenUserInfo, String gestioneTokenForward,
  157.             String autenticazioneTokenIssuer,String autenticazioneTokenClientId,String autenticazioneTokenSubject,String autenticazioneTokenUsername,String autenticazioneTokenEMail,
  158.             String autorizzazioneToken, String autorizzazioneTokenOptions,
  159.             String autorizzazioneScope, int numScope, String autorizzazioneScopeMatch, BinaryParameter allegatoXacmlPolicy,
  160.             String messageEngine, String canale,
  161.             String identificazioneAttributiStato, String[] attributeAuthorityLabels, String[] attributeAuthorityValues, String [] attributeAuthoritySelezionate, String attributeAuthorityAttributi,
  162.             String autorizzazioneAutenticatiToken, String urlAutorizzazioneAutenticatiToken, int numAutenticatiToken,
  163.             String autorizzazioneRuoliToken,  String urlAutorizzazioneRuoliToken, int numRuoliToken, String autorizzazioneRuoliTipologiaToken, String autorizzazioneRuoliMatchToken,
  164.             String ctModalitaSincronizzazione, String ctImplementazione, String ctContatori, String ctTipologia,
  165.             String ctHeaderHttp, String ctHeaderHttpLimit, String ctHeaderHttpRemaining, String ctHeaderHttpReset,
  166.             String ctHeaderHttpRetryAfter, String ctHeaderHttpRetryAfterBackoff) throws Exception {

  167.         if(sp!=null && tiposp!=null && patternErogatore!=null && servizio!=null && tiposervizio!=null && versioneServizio!=null &&
  168.                 patternServizio!=null && totAzioni>0 && statoMessageSecurity!=null && statoMTOM!=null){
  169.             // nop
  170.         }
  171.        
  172.         boolean multitenant = this.pddCore.isMultitenant();

  173.         Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  174.        
  175.         // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  176.         Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  177.         if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  178.        
  179.         boolean isConfigurazione = parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE;
  180.        
  181.         boolean datiInvocazione = false;
  182.         boolean modificaDescrizione = false;
  183.         boolean datiAltroPorta = false;
  184.         boolean datiAltroApi = false; // indipendente dalla porta (viene utilizzata sempre la porta di default)
  185.         if(isConfigurazione) {
  186.             if(usataInConfigurazioneDefault) {
  187.                 datiInvocazione = ServletUtils.isCheckBoxEnabled(this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_DATI_INVOCAZIONE));
  188.             }
  189.             modificaDescrizione = ServletUtils.isCheckBoxEnabled(this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_DESCRIZIONE));
  190.             datiAltroPorta = ServletUtils.isCheckBoxEnabled(this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_ALTRO_PORTA));
  191.             datiAltroApi = ServletUtils.isCheckBoxEnabled(this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_ALTRO_API));
  192.            
  193.             DataElement de = new DataElement();
  194.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_DATI_INVOCAZIONE);
  195.             de.setType(DataElementType.HIDDEN);
  196.             de.setValue(datiInvocazione+"");
  197.             dati.add(de);
  198.            
  199.             de = new DataElement();
  200.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_DESCRIZIONE);
  201.             de.setType(DataElementType.HIDDEN);
  202.             de.setValue(modificaDescrizione+"");
  203.             dati.add(de);
  204.            
  205.             de = new DataElement();
  206.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_ALTRO_PORTA);
  207.             de.setType(DataElementType.HIDDEN);
  208.             de.setValue(datiAltroPorta+"");
  209.             dati.add(de);
  210.            
  211.             de = new DataElement();
  212.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_ALTRO_API);
  213.             de.setType(DataElementType.HIDDEN);
  214.             de.setValue(datiAltroApi+"");
  215.             dati.add(de);
  216.         }
  217.        

  218.         int alternativeSize = 80;
  219.                
  220.         DataElement de = null;
  221.        
  222.         de = new DataElement();
  223.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  224.         de.setValue(idsogg2);
  225.         de.setType(DataElementType.HIDDEN);
  226.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  227.         dati.add(de);

  228.         de = new DataElement();
  229.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ID);
  230.         de.setValue(idPorta);
  231.         de.setType(DataElementType.HIDDEN);
  232.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  233.         dati.add(de);
  234.        
  235.         // servicebinding hidden
  236.         dati.add(this.getServiceBindingDataElement(serviceBinding));
  237.        
  238.         // *************** Dati Generali: Nome/Descrizione *********************
  239.        
  240.         if(datiInvocazione || (!datiAltroPorta && !datiAltroApi)) {
  241.             de = new DataElement();
  242.             if(datiInvocazione) {
  243.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_TITOLO_PORTE_DELEGATE_DATI_INVOCAZIONE);
  244.             }
  245.             else if(modificaDescrizione) {
  246.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_TITOLO_PORTE_DELEGATE_DESCRIZIONE);
  247.             }
  248.             else {
  249.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_TITOLO_PORTE_DELEGATE_DATI_GENERALI);
  250.             }
  251.             de.setType(DataElementType.TITLE);
  252.             dati.add(de);
  253.         }

  254.         de = new DataElement();
  255.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  256.         de.setValue(nomePorta);
  257.        
  258.         if(isConfigurazione) {
  259.             de.setType(DataElementType.HIDDEN);
  260.         }
  261.         else {              
  262.             de.setType(DataElementType.TEXT_EDIT);
  263.             de.setRequired(true);
  264.         }
  265.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA);
  266.         de.setSize(alternativeSize);
  267.         dati.add(de);
  268.        
  269.         if(datiInvocazione) {
  270.            
  271.             IDSoggetto soggettoOperativo = null;
  272.             if(this.porteDelegateCore.isRegistroServiziLocale()){
  273.                 org.openspcoop2.core.registry.Soggetto soggetto = this.soggettiCore.getSoggettoRegistro(Long.valueOf(idsogg2));
  274.                 soggettoOperativo = new IDSoggetto( soggetto.getTipo() , soggetto.getNome() );
  275.             }else{
  276.                 org.openspcoop2.core.config.Soggetto soggetto = this.soggettiCore.getSoggetto(Long.valueOf(idsogg2));
  277.                 soggettoOperativo = new IDSoggetto( soggetto.getTipo() , soggetto.getNome() );
  278.             }
  279.             boolean analizeProxyPassRules = true;
  280.             UrlInvocazioneAPI urlInvocazione = this.confCore.getConfigurazioneUrlInvocazione(protocollo, RuoloContesto.PORTA_DELEGATA, serviceBinding, nomePorta, soggettoOperativo,
  281.                     aspc, canale,
  282.                     analizeProxyPassRules);
  283.            
  284.             de = new DataElement();
  285.             if(ServiceBinding.SOAP.equals(serviceBinding)) {
  286.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_URL_INVOCAZIONE);
  287.             }
  288.             else {
  289.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_BASE_URL_INVOCAZIONE);
  290.             }
  291.             String urlInvocazioneAPI = urlInvocazione.getUrl();
  292.             de.setValue(urlInvocazioneAPI);
  293.             de.setType(DataElementType.TEXT);
  294.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA+"___LABEL");
  295.             dati.add(de);
  296.            
  297.             UrlInvocazioneAPI urlInvocazioneDefault = this.confCore.getConfigurazioneUrlInvocazione(protocollo, RuoloContesto.PORTA_DELEGATA, serviceBinding, nomePorta, soggettoOperativo,
  298.                     aspc, canale,
  299.                     !analizeProxyPassRules);
  300.            
  301.             if(urlInvocazioneDefault!=null && urlInvocazioneDefault.getUrl()!=null && !urlInvocazioneDefault.getUrl().equals(urlInvocazioneAPI)) {
  302.                
  303.                 de = new DataElement();
  304.                 if(ServiceBinding.SOAP.equals(serviceBinding)) {
  305.                     de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_URL_INVOCAZIONE_INTERNA);
  306.                 }
  307.                 else {
  308.                     de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_BASE_URL_INVOCAZIONE_INTERNA);
  309.                 }
  310.                 String urlInvocazioneAPIdefault = urlInvocazioneDefault.getUrl();
  311.                 de.setValue(urlInvocazioneAPIdefault);
  312.                 de.setType(DataElementType.TEXT);
  313.                 de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA+"___LABEL_INTERNA");
  314.                 dati.add(de);
  315.                
  316.             }
  317.         }

  318.         de = new DataElement();
  319.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_DESCRIZIONE);
  320.         if(modificaDescrizione && SubscriptionConfiguration.isDescriptionDefault(descr)) {
  321.             de.setValue(null);
  322.         }
  323.         else {
  324.             de.setValue(descr);
  325.         }
  326.         if(isConfigurazione && !modificaDescrizione) {
  327.             de.setType(DataElementType.HIDDEN);
  328.         } else {
  329.             if(modificaDescrizione) {
  330.                 de.setType(DataElementType.TEXT_AREA);
  331.                 de.setRows(CostantiControlStation.TEXT_AREA_DESCRIZIONE_ROWS);
  332.                 de.setLabel(CostantiControlStation.LABEL_PROPRIETA_DESCRIZIONE_EMPTY);
  333.             }
  334.             else {
  335.                 de.setType(DataElementType.TEXT_EDIT);
  336.             }
  337.         }
  338.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_DESCRIZIONE);
  339.         de.setSize(alternativeSize);
  340.         dati.add(de);
  341.        
  342.         de = new DataElement();
  343.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_STATO_PORTA);
  344.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_STATO_PORTA);
  345.         if(!isConfigurazione) {
  346.             List<String> statoValues = new ArrayList<>();
  347.             statoValues.add(CostantiConfigurazione.ABILITATO.toString());
  348.             statoValues.add(CostantiConfigurazione.DISABILITATO.toString());
  349.             de.setValues(statoValues);
  350.             if(statoPorta==null || "".equals(statoPorta)){
  351.                 statoPorta = CostantiConfigurazione.ABILITATO.toString();
  352.             }
  353.             de.setSelected(statoPorta);
  354.             de.setType(DataElementType.SELECT);
  355.         }
  356.         else {
  357.             de.setValue(statoPorta);
  358.             de.setType(DataElementType.HIDDEN);
  359.         }
  360.         dati.add(de);

  361.        
  362.         // *************** Dati Servizio *********************
  363.        
  364.         if(!isConfigurazione) {
  365.             de = new DataElement();
  366.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_TITOLO_PORTE_DELEGATE_DATI_SERVIZIO);
  367.             de.setType(DataElementType.TITLE);
  368.             dati.add(de);
  369.         }
  370.        
  371.        
  372.        
  373.         // *************** Soggetto Erogatore *********************
  374.        
  375.         if(!isConfigurazione) {
  376.             de = new DataElement();
  377.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SOGGETTO_EROGATORE);
  378.             de.setType(DataElementType.SUBTITLE);
  379.             dati.add(de);
  380.         }

  381.         de = new DataElement();
  382.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  383.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_SOGGETTO_ID);
  384.         if(!usataInConfigurazioni) {
  385.             de.setPostBack(true);
  386.             de.setType(DataElementType.SELECT);
  387.             de.setValues(soggettiList);
  388.             de.setLabels(soggettiListLabel);
  389.             de.setSelected(soggid);
  390.         } else {
  391.             de.setType(DataElementType.HIDDEN);
  392.             de.setValue(soggid);
  393.             dati.add(de);
  394.            
  395.             if(this.isModalitaCompleta()) {
  396.                 de = new DataElement();
  397.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  398.                 de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_SOGGETTO);
  399.                 de.setType(DataElementType.TEXT);
  400.                 String tipoSoggetto = soggid.split("/")[0];
  401.                 String nomeSoggetto = soggid.split("/")[1];
  402.                 de.setValue(this.getLabelNomeSoggetto(protocollo, tipoSoggetto, nomeSoggetto));
  403.             }
  404.         }
  405.         dati.add(de);


  406.         // *************** Servizio *********************
  407.        
  408.         if(!isConfigurazione) {
  409.             de = new DataElement();
  410.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZIO);
  411.             de.setType(DataElementType.SUBTITLE);
  412.             dati.add(de);
  413.         }

  414.         de = new DataElement();
  415.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  416.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_SERVIZIO_ID);
  417.         if(!usataInConfigurazioni) {
  418.             de.setPostBack(true);
  419.             de.setType(DataElementType.SELECT);
  420.             de.setValues(serviziList);
  421.             de.setLabels(serviziListLabel);
  422.             de.setSelected(servid);
  423.         } else {
  424.             de.setType(DataElementType.HIDDEN);
  425.             de.setValue(servid);
  426.             dati.add(de);
  427.            
  428.             if(this.isModalitaCompleta()) {
  429.                 de = new DataElement();
  430.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  431.                 de.setType(DataElementType.TEXT);
  432.                 for (int i = 0; i < serviziList.length; i++) {
  433.                     if(serviziList[i]!=null && serviziList[i].equals(servid)){
  434.                         de.setValue(serviziListLabel[i]);
  435.                         break;
  436.                     }
  437.                 }
  438.             }
  439.         }
  440.         dati.add(de);
  441.        
  442.         // *************** Azione *********************
  443.        
  444.         List<PortaDelegataAzioneIdentificazione> allSubscriptionIdentificationResourceModes = getModalitaIdentificazionePorta(protocollo, serviceBinding);
  445.        
  446.        
  447.         // se servizio register-input e azioneList==null e
  448.         // mode_azione=register-input allora nn c'e' azione
  449.         List<String> azTmp = new ArrayList<>();
  450.         String[] tipoModeAzione = null;
  451.         String[] tipoModeAzioneLabel = null;
  452.        
  453.         if(tipoOp.equals(TipoOperazione.ADD) || (tipoOp.equals(TipoOperazione.CHANGE) && !usataInConfigurazioni)) {
  454.             azTmp.add(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT);
  455.         }
  456.         else if(datiInvocazione && ServiceBinding.SOAP.equals(serviceBinding)) {
  457.             if(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT.equals(modeaz)) {
  458.                 azTmp.add(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT); // era stata impostata precedentemente
  459.             }
  460.             else {
  461.                 Map<String,String> azioni = this.porteApplicativeCore.getAzioniConLabel(asps, aspc, false, true, new ArrayList<>());
  462.                 if(azioni==null || azioni.size()<=1) {
  463.                     azTmp.add(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT);
  464.                 }
  465.             }
  466.         }
  467.        
  468.        
  469.         if(allSubscriptionIdentificationResourceModes != null && allSubscriptionIdentificationResourceModes.size() >0) {
  470.            
  471.            
  472.             for (int i = 0; i < allSubscriptionIdentificationResourceModes.size(); i++) {
  473.                 PortaDelegataAzioneIdentificazione pdAi = allSubscriptionIdentificationResourceModes.get(i);
  474.                 azTmp.add(pdAi.toString());
  475.             }
  476.            
  477.             Collections.sort(azTmp);
  478.                        
  479.             tipoModeAzione = new String [azTmp.size()];
  480.             tipoModeAzioneLabel = new String [azTmp.size()];
  481.            
  482.             for (int i = 0; i < azTmp.size(); i++) {
  483.                 String azMod = azTmp.get(i);
  484.                 tipoModeAzione[i] = azMod;
  485.                 tipoModeAzioneLabel[i] = this.getPortaDelegataAzioneIdentificazioneLabel(azMod);
  486.             }
  487.         }
  488.        
  489.         boolean disableSaveButtonForDatiInvocazione = true;
  490.        
  491.         if(!isConfigurazione || datiInvocazione) {
  492.             de = new DataElement();
  493.             if(datiInvocazione) {
  494.                 if(ServiceBinding.REST.equals(serviceBinding)) {
  495.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTA_RISORSA_MODALITA);
  496.                 }
  497.                 else {
  498.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_PORTA_AZIONE_MODALITA);
  499.                 }
  500.             }
  501.             else {
  502.                 if(ServiceBinding.REST.equals(serviceBinding)) {
  503.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_RISORSA);
  504.                 }
  505.                 else {
  506.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_AZIONE);
  507.                 }
  508.             }
  509.             de.setType(DataElementType.SUBTITLE);
  510.             dati.add(de);
  511.         }

  512.         boolean viewOnlyModeDatiAzione = datiInvocazione && modeaz!=null && !"".equals(modeaz) && this.isModalitaStandard() &&
  513.                 !azTmp.contains(modeaz);
  514.         // se true viewOnlyModeDatiAzione e' stato usato un valore modificato in avanzato e non supportato in standard
  515.        
  516.         // Fix per standard visualizzazione anche su soap
  517.         // fornisco interfaceMode direttamente come per rest se cmq è abilitato sia il riconoscimento per url che anche per forceInterface.
  518.         boolean visualizzazioneSpecialeSoapPerEssereUgualeARest = false;
  519.         if(this.isModalitaStandard() && ServiceBinding.SOAP.equals(serviceBinding) &&
  520.                 PortaDelegataAzioneIdentificazione.URL_BASED.getValue().equals(modeaz) &&
  521.                 (ServletUtils.isCheckBoxEnabled(forceWsdlBased) || CostantiRegistroServizi.ABILITATO.equals(forceWsdlBased))
  522.                 && (aspc.getByteWsdlConcettuale()!=null)
  523.                 ) {
  524.             visualizzazioneSpecialeSoapPerEssereUgualeARest = true;
  525.         }
  526.        
  527.         de = new DataElement();
  528.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODALITA_IDENTIFICAZIONE);
  529.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_AZIONE);
  530.         if(!usataInConfigurazioni || datiInvocazione) {
  531.             if(viewOnlyModeDatiAzione || (tipoModeAzione!=null && tipoModeAzione.length==1) || visualizzazioneSpecialeSoapPerEssereUgualeARest) {
  532.                 de.setType(DataElementType.HIDDEN);
  533.                 de.setValue(modeaz);
  534.                 dati.add(de);
  535.                
  536.                 de = new DataElement();
  537.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODALITA_IDENTIFICAZIONE);
  538.                 de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_AZIONE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  539.                 de.setType(DataElementType.TEXT);
  540.                 if(visualizzazioneSpecialeSoapPerEssereUgualeARest) {
  541.                     de.setValue(this.getPortaDelegataAzioneIdentificazioneLabel(PortaDelegataAzioneIdentificazione.INTERFACE_BASED.getValue()));
  542.                 }
  543.                 else {
  544.                     de.setValue(this.getPortaDelegataAzioneIdentificazioneLabel(modeaz));
  545.                 }
  546.             }
  547.             else {
  548.                 de.setType(DataElementType.SELECT);
  549.                 de.setValues(tipoModeAzione);
  550.                 de.setLabels(tipoModeAzioneLabel);
  551.                 de.setSelected(modeaz);
  552.                 de.setPostBack(true);
  553.                
  554.                 disableSaveButtonForDatiInvocazione = false;
  555.             }
  556.         } else {
  557.             de.setType(DataElementType.HIDDEN);
  558.             de.setValue(modeaz);
  559.         }
  560.        
  561.         dati.add(de);
  562.        
  563.         boolean addHiddenAzione = false;
  564.        
  565.         if(!usataInConfigurazioni || datiInvocazione) {
  566.    
  567.             if(!usataInConfigurazioni && PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_DELEGATED_BY.equals(modeaz)) {
  568.                
  569.                 // azione non modificabile, metto la lista delle azioni
  570.                 de = new DataElement();
  571.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  572.                 de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_AZIONE);
  573.                 de.setValue(azione);
  574.                 dati.add(de);
  575.                
  576.                 addHiddenAzione = true;
  577.                
  578.             }
  579.             else {
  580.            
  581.                 if ( (!visualizzazioneSpecialeSoapPerEssereUgualeARest) &&
  582.                         (modeaz != null) &&
  583.                         modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT)) {
  584.                     de = new DataElement();
  585.                     de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  586.                     de.setType(DataElementType.SELECT);
  587.                     de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_AZIONE_ID);
  588.                     de.setValues(azioniList);
  589.                     de.setLabels(azioniListLabel);
  590.                     de.setSelected(azid);
  591.                     dati.add(de);
  592.                    
  593.                     disableSaveButtonForDatiInvocazione = false;
  594.                    
  595.                 } else {
  596.        
  597.                     de = new DataElement();
  598.                     if ((modeaz != null) && (modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_URL_BASED))) {
  599.                         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ESPRESSIONE_REGOLARE);
  600.                         de.setValue(patternAzione);
  601.                         de.setRequired(true);
  602.                     }
  603.                     else if ((modeaz != null) && (modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_CONTENT_BASED))) {
  604.                         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTENT_PATTERN);
  605.                         de.setValue(patternAzione);
  606.                         de.setRequired(true);
  607.                     }
  608.                     else if ((modeaz != null) && (modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_HEADER_BASED))) {
  609.                         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  610.                         de.setValue(patternAzione);
  611.                         de.setRequired(true);
  612.                     }
  613.                     else {
  614.                         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  615.                         de.setValue(azione);
  616.                     }
  617.        
  618.                     if ( (!visualizzazioneSpecialeSoapPerEssereUgualeARest) &&
  619.                             !PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_INPUT_BASED.equals(modeaz) &&
  620.                             !PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_SOAP_ACTION_BASED.equals(modeaz) &&
  621.                             !PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_INTERFACE_BASED.equals(modeaz) ){
  622.                         if(viewOnlyModeDatiAzione) {
  623.                             de.setType(DataElementType.TEXT);
  624.                             de.setRequired(false);
  625.                         }
  626.                         else {
  627.                             if(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_URL_BASED.equals(modeaz) ||
  628.                                     PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_CONTENT_BASED.equals(modeaz) ) {
  629.                                 de.setType(DataElementType.TEXT_AREA);
  630.                             }
  631.                             else {
  632.                                 de.setType(DataElementType.TEXT_EDIT);
  633.                             }
  634.                             disableSaveButtonForDatiInvocazione = false;
  635.                         }
  636.                     }else
  637.                         de.setType(DataElementType.HIDDEN);
  638.                     de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_AZIONE);
  639.                     de.setSize(alternativeSize);
  640.                     dati.add(de);
  641.                 }
  642.        
  643.                 // se non e' selezionata la modalita userInput / wsdlbased / registerInput faccio vedere il check box forceWsdlbased
  644.                 de = new DataElement();
  645.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_FORCE_INTERFACE_BASED_LEFT);
  646.                 if( (!visualizzazioneSpecialeSoapPerEssereUgualeARest) &&
  647.                         modeaz!= null &&
  648.                         (
  649.                             !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT) &&
  650.                             !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_INTERFACE_BASED)
  651.                         )
  652.                     ){
  653.        
  654.                     if(viewOnlyModeDatiAzione) {
  655.                         de.setType(DataElementType.TEXT);
  656.                         if( ServletUtils.isCheckBoxEnabled(forceWsdlBased) || CostantiRegistroServizi.ABILITATO.equals(forceWsdlBased) ){
  657.                             de.setValue(CostantiConfigurazione.ABILITATO.getValue());
  658.                         }
  659.                         else {
  660.                             de.setValue(CostantiConfigurazione.DISABILITATO.getValue());
  661.                         }
  662.                     }
  663.                     else {
  664.                         de.setType(DataElementType.CHECKBOX);
  665.                         de.setLabelRight(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_FORCE_INTERFACE_BASED_RIGHT);
  666.                         if( ServletUtils.isCheckBoxEnabled(forceWsdlBased) || CostantiRegistroServizi.ABILITATO.equals(forceWsdlBased) ){
  667.                             de.setSelected(true);
  668.                         }
  669.                         disableSaveButtonForDatiInvocazione = false;
  670.                     }
  671.                 }
  672.                 else{
  673.                     de.setType(DataElementType.HIDDEN);
  674.                     de.setValue(forceWsdlBased);
  675.                 }
  676.                 de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_FORCE_INTERFACE_BASED);
  677.                 dati.add(de);
  678.                
  679.                 if( (!visualizzazioneSpecialeSoapPerEssereUgualeARest) &&
  680.                         modeaz!= null &&
  681.                         (
  682.                             !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT) &&
  683.                             !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_INTERFACE_BASED)
  684.                         )
  685.                 ){
  686.                     de = new DataElement();
  687.                     de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_LIST_AZIONI_READ_ONLY);
  688.                     de.setLabel(this.getLabelAzioni(serviceBinding));
  689.                     Map<String,String> azioni = this.porteDelegateCore.getAzioniConLabel(asps, aspc, false, true, new ArrayList<>());
  690.                     StringBuilder bf = new StringBuilder();
  691.                     for (String az : azioni.keySet()) {
  692.                         if(bf.length()>0) {
  693.                             bf.append("\n");
  694.                         }
  695.                         bf.append(azioni.get(az));
  696.                     }
  697.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  698.                     if(azioni.size()<=CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_AZIONI_SIZE) {
  699.                         de.setRows(azioni.size());
  700.                     }
  701.                     else {
  702.                         de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_AZIONI_SIZE);
  703.                     }
  704.                     de.setValue(bf.toString());
  705.                     dati.add(de);
  706.                 }
  707.                
  708.             }
  709.        
  710.         } else {
  711.            
  712.             addHiddenAzione = true;
  713.            
  714.         }
  715.        
  716.         if(addHiddenAzione) {
  717.            
  718.             de = new DataElement();
  719.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  720.             de.setType(DataElementType.HIDDEN);
  721.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_AZIONE_ID);
  722.             de.setValue(azid);
  723.             dati.add(de);
  724.            
  725.             if(this.isModalitaCompleta()) {
  726.                 DataElement deLabel = new DataElement();
  727.                 deLabel.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODALITA_IDENTIFICAZIONE);
  728.                 deLabel.setType(DataElementType.TEXT);
  729.                 deLabel.setValue(modeaz);
  730.                 dati.add(deLabel);
  731.             }
  732.            
  733.             de = new DataElement();
  734.             if ((modeaz != null) && (modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_URL_BASED)
  735.                     || modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_CONTENT_BASED))) {
  736.                 de.setValue(patternAzione);
  737.             }
  738.             else if ((modeaz != null) && modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_HEADER_BASED)
  739.                     ) {
  740.                 de.setValue(patternAzione);
  741.             }
  742.             else {
  743.                 de.setValue(azione);
  744.             }
  745.             de.setType(DataElementType.HIDDEN);
  746.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_AZIONE);
  747.             dati.add(de);
  748.            
  749.             if(this.isModalitaCompleta()) {
  750.                 DataElement deLabel = new DataElement();
  751.                 deLabel.setType(DataElementType.TEXT);
  752.                 if ((modeaz != null) && (modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_URL_BASED))) {
  753.                     deLabel.setType(DataElementType.TEXT_AREA_NO_EDIT);
  754.                     deLabel.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ESPRESSIONE_REGOLARE);
  755.                     deLabel.setValue(patternAzione);
  756.                 }
  757.                 else if ((modeaz != null) && (modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_CONTENT_BASED))) {
  758.                     deLabel.setType(DataElementType.TEXT_AREA_NO_EDIT);
  759.                     deLabel.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTENT_PATTERN);
  760.                     deLabel.setValue(patternAzione);
  761.                 }
  762.                 else if ((modeaz != null) && modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_HEADER_BASED)
  763.                         ) {
  764.                     deLabel.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  765.                     deLabel.setValue(patternAzione);
  766.                 }
  767.                 else {
  768.                     deLabel.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  769.                     deLabel.setValue(azione);
  770.                 }
  771.                 dati.add(deLabel);
  772.             }
  773.            
  774.             if(this.isModalitaCompleta()) {
  775.                 if ((modeaz != null) && (modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_DELEGATED_BY))){
  776.                     de = new DataElement();
  777.                     de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RICERCA_PORTA_AZIONE_DELEGATA);
  778.                     de.setType(DataElementType.TEXT);
  779.                     de.setValue(nomePortaDelegante);
  780.                     dati.add(de);
  781.                 }
  782.                 else {
  783.                     DataElement deLabel = new DataElement();
  784.                     deLabel.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RICERCA_PORTA_AZIONE_DELEGATA);
  785.                     deLabel.setType(DataElementType.TEXT);
  786.                     deLabel.setValue(ricercaPortaAzioneDelegata ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue() );
  787.                     dati.add(deLabel);
  788.                 }
  789.             }
  790.            
  791.             de = new DataElement();
  792.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_FORCE_INTERFACE_BASED_LEFT);
  793.             de.setType(DataElementType.HIDDEN);
  794.             de.setValue(forceWsdlBased);
  795.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_FORCE_INTERFACE_BASED);
  796.             dati.add(de);
  797.            
  798.             if(this.isModalitaCompleta()) {
  799.                 if( modeaz!= null && (
  800.                         !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT) &&
  801.                         !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_INTERFACE_BASED))
  802.                 ){
  803.                     DataElement deLabel = new DataElement();
  804.                     deLabel.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_FORCE_INTERFACE_BASED_LEFT);
  805.                     deLabel.setType(DataElementType.TEXT);
  806.                     deLabel.setValue(ServletUtils.isCheckBoxEnabled(forceWsdlBased) ? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue() );
  807.                     dati.add(deLabel);
  808.                 }
  809.             }
  810.            
  811.         }
  812.        
  813.         if(datiInvocazione && disableSaveButtonForDatiInvocazione) {
  814.             this.pd.disableEditMode();
  815.         }
  816.        
  817.        
  818.        
  819.        
  820.        
  821.         // *************** Controllo degli Accessi *********************
  822.        
  823.        
  824.        
  825.         // Pintori 11/12/2017 Gestione Accessi spostata nella servlet PorteDelegateControlloAccessi,  in ADD devo mostrare comunque la form.
  826.         if(!tipoOp.equals(TipoOperazione.ADD)) {
  827.             if(!isConfigurazione) {
  828.                
  829.                 // Il link richiede ulteriori parametri.
  830.                
  831. //              this.controlloAccessi(dati);
  832. //              // controllo accessi
  833. //              de = new DataElement();
  834. //              de.setType(DataElementType.LINK);
  835. //              de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONTROLLO_ACCESSI, pIdSogg, pIdPorta, pIdAsps, pIdFruizione);
  836. //              String statoControlloAccessi = this.getLabelStatoControlloAccessi(gestioneToken,autenticazione, autenticazioneOpzionale, autenticazioneCustom, autorizzazione, autorizzazioneContenuti,autorizzazioneCustom);
  837. //              ServletUtils.setDataElementCustomLabel(de, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI, statoControlloAccessi);
  838. //              dati.add(de);
  839.             }
  840.         }else {
  841.            
  842.             String servletChiamante = PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_ADD;
  843.            
  844.             boolean isSupportatoAutenticazioneSoggetti = true; // sempre nelle porte delegate
  845.             Boolean confPers = ServletUtils.getObjectFromSession(this.request, this.session, Boolean.class, CostantiControlStation.SESSION_PARAMETRO_GESTIONE_CONFIGURAZIONI_PERSONALIZZATE);
  846.            
  847.             this.controlloAccessiGestioneToken(dati, tipoOp, gestioneToken, gestioneTokenPolicyLabels, gestioneTokenPolicyValues,
  848.                     gestioneTokenPolicy, gestioneTokenOpzionale,
  849.                     gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenForward, null,protocollo,true,
  850.                     false);
  851.            
  852.             this.controlloAccessiAutenticazione(dati, tipoOp, servletChiamante,null,protocollo,
  853.                     autenticazione, autenticazioneCustom, autenticazioneOpzionale,
  854.                     autenticazionePrincipal, autenticazioneParametroList,
  855.                     confPers , isSupportatoAutenticazioneSoggetti,true,
  856.                     gestioneToken, gestioneTokenPolicy, autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  857.                     false, null, 0,
  858.                     false, false);
  859.            
  860.             String urlAutorizzazioneAutenticati = null;
  861.             String urlAutorizzazioneRuoli = null;
  862.             String urlAutorizzazioneScope = null;
  863.            
  864.             this.controlloAccessiAutorizzazione(dati, tipoOp, servletChiamante,null,protocollo,
  865.                     autenticazione, autenticazioneCustom,
  866.                     autorizzazione, autorizzazioneCustom,
  867.                     autorizzazioneAutenticati, urlAutorizzazioneAutenticati, numSA, null, null,
  868.                     autorizzazioneRuoli,  urlAutorizzazioneRuoli, numRuoli, null,
  869.                     autorizzazioneRuoliTipologia, ruoloMatch,
  870.                     confPers, isSupportatoAutenticazioneSoggetti, contaListe, true, false,autorizzazioneScope,urlAutorizzazioneScope,numScope,null,autorizzazioneScopeMatch,
  871.                     gestioneToken, gestioneTokenPolicy,
  872.                     autorizzazioneToken, autorizzazioneTokenOptions,allegatoXacmlPolicy,
  873.                     null, 0, null, 0,
  874.                     identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  875.                     autorizzazioneAutenticatiToken, urlAutorizzazioneAutenticatiToken, numAutenticatiToken,
  876.                     autorizzazioneRuoliToken,  urlAutorizzazioneRuoliToken, numRuoliToken, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);
  877.            
  878.                
  879.             this.controlloAccessiAutorizzazioneContenuti(dati, tipoOp, true, null,protocollo,
  880.                     autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties,
  881.                     serviceBinding, false, null, 0,
  882.                     confPers);
  883.         }
  884.        
  885.        
  886.         // *************** Validazione Contenuti *********************
  887.        
  888.        
  889.         // Pintori 08/02/2018 Validazione Contenuti spostata nella servlet PorteDelegateValidazione, in ADD devo mostrare comunque la form.
  890.        
  891.         if(!tipoOp.equals(TipoOperazione.ADD)) {
  892.             if(!isConfigurazione) {
  893.                
  894.                 // Il link richiede ulteriori parametri.
  895.            
  896. //              de = new DataElement();
  897. //              de.setType(DataElementType.TITLE);
  898. //              de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_CONTENUTI);
  899. //              dati.add(de);
  900. //              
  901. //              // validazione contenuti
  902. //              de = new DataElement();
  903. //              de.setType(DataElementType.LINK);
  904. //              de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_VALIDAZIONE_CONTENUTI, pIdSogg, pIdPorta, pIdAsps, pIdFruizione);
  905. //              ServletUtils.setDataElementCustomLabel(de, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_CONTENUTI, statoValidazione);
  906. //              dati.add(de);
  907.             }
  908.         } else {
  909.                 this.validazioneContenuti(tipoOp, dati, true, statoValidazione, tipoValidazione, applicaMTOM,
  910.                         serviceBinding, aspc.getFormatoSpecifica());
  911.         }
  912.        
  913.        
  914.         // *************** Integrazione *********************
  915.        
  916.         List<DataElement> deIntegrazione = new ArrayList<>();
  917.        
  918.         boolean nascondiSezioneOpzioniAvanzate = this.isModalitaStandard() || (isConfigurazione && !datiAltroPorta);

  919.         if (tipoOp.equals(TipoOperazione.CHANGE)) {
  920.             this.addIntegrazioneMetadatiToDati(dati, integrazioneStato, integrazione, integrazioneGruppi, integrazioneGruppiDaVisualizzare, integrazioneGruppiValoriDeiGruppi, deIntegrazione, nascondiSezioneOpzioniAvanzate, true, serviceBinding);
  921.         }

  922.         String[] tipoStateless = { PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_STATELESS_DEFAULT,
  923.                 PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_STATELESS_ABILITATO,
  924.                 PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_STATELESS_DISABILITATO };
  925.         de = new DataElement();
  926.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_STATELESS);
  927.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_STATELESS);
  928.         if(!this.core.isShowJ2eeOptions() || (isConfigurazione && !datiAltroPorta)){
  929.             de.setType(DataElementType.HIDDEN);
  930.             de.setValue(stateless);
  931.             dati.add(de);
  932.         }else {
  933.             de.setType(DataElementType.SELECT);
  934.             de.setValues(tipoStateless);
  935.             de.setSelected(stateless);
  936.             deIntegrazione.add(de);
  937.         }
  938.        

  939.         // LocalForward
  940.         boolean localForwardShow = true;
  941.         Soggetto soggettoErogatoreLocalForward  = null;
  942.         try{
  943.             if(soggid!=null && soggid.contains("/")){
  944.                 soggettoErogatoreLocalForward = this.soggettiCore.getSoggettoRegistro(new IDSoggetto(soggid.split("/")[0], soggid.split("/")[1]));
  945.             }
  946.             else if(soggid!=null && !"".equals(soggid)){
  947.                 soggettoErogatoreLocalForward = this.soggettiCore.getSoggettoRegistro(Long.parseLong(soggid));
  948.             }
  949.         }catch(DriverRegistroServiziNotFound dNot){}
  950.        
  951.         if(soggettoErogatoreLocalForward!=null){
  952.             if(this.pddCore.isRegistroServiziLocale()){
  953.                 if(soggettoErogatoreLocalForward.getPortaDominio()!=null){
  954.                     try{
  955.                         if(this.pddCore.getPdDControlStation(soggettoErogatoreLocalForward.getPortaDominio()).getTipo().equals(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_ESTERNO)){
  956.                             localForwardShow = false;
  957.                         }
  958.                     }catch(DriverControlStationNotFound dNot){}
  959.                 }
  960.             }
  961.             else{
  962.                 // se il soggetto erogatore non e' locale non puo' esistere il localForward.
  963.                 // Comunque sia lo devo far vedere lo stesso poiche' magari e' una configurazione errata indicata nella console centrale.
  964. //              if(soggettoErogatoreLocalForward.getTipo()!=null && soggettoErogatoreLocalForward.getNome()!=null){
  965. //                  try{
  966. //                      IDSoggetto idSoggetto = new IDSoggetto(soggettoErogatoreLocalForward.getTipo(), soggettoErogatoreLocalForward.getNome());
  967. //                      if(!this.soggettiCore.existsSoggetto(idSoggetto)){
  968. //                          localForwardShow = false;
  969. //                      }
  970. //                  }catch(Exception dNot){
  971. //                      this.logError(dNot.getMessage(), dNot);
  972. //                  }
  973. //              }
  974.             }
  975.         }          
  976.        
  977.         if(deIntegrazione.size()>0){
  978.            
  979.             if(!isConfigurazione || datiAltroPorta) {
  980.                 de = new DataElement();
  981.                 de.setType(DataElementType.TITLE);
  982.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_INTEGRAZIONE);
  983.                 dati.add(de);
  984.                
  985.                 for (int i = 0; i < deIntegrazione.size(); i++) {
  986.                     dati.add(deIntegrazione.get(i));
  987.                 }
  988.             }
  989.         }
  990.        
  991.        
  992.         // Rate Limiting
  993.         if(tipoOp.equals(TipoOperazione.CHANGE) && datiAltroPorta) {
  994.             addOpzioniAvanzateRateLimitingToDati(dati,
  995.                     true,
  996.                     nascondiSezioneOpzioniAvanzate,
  997.                     ctModalitaSincronizzazione, ctImplementazione, ctContatori, ctTipologia,
  998.                     ctHeaderHttp, ctHeaderHttpLimit, ctHeaderHttpRemaining, ctHeaderHttpReset,
  999.                     ctHeaderHttpRetryAfter, ctHeaderHttpRetryAfterBackoff);
  1000.         }
  1001.        
  1002.        
  1003.        
  1004.         // Message Handlers
  1005.         if (tipoOp.equals(TipoOperazione.CHANGE)) {
  1006.             boolean visualizzaHandlers = this.confCore.isConfigurazioneHandlersEnabled();
  1007.             if(!nascondiSezioneOpzioniAvanzate && visualizzaHandlers) {
  1008.                 this.visualizzaLinkHandlers(dati, false, TipoPdD.DELEGATA, Long.parseLong(idPorta), serviceBinding);
  1009.             }
  1010.         }
  1011.        
  1012.         boolean localForwardDisable = !this.porteDelegateCore.isShowPortaDelegataLocalForward() || this.isModalitaStandard() || !multitenant || localForwardShow==false || (isConfigurazione && !datiAltroPorta);
  1013.        
  1014.         if(!localForwardDisable) {
  1015.             de = new DataElement();
  1016.             de.setType(DataElementType.TITLE);
  1017.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_LOCAL_FORWARD);
  1018.             dati.add(de);
  1019.         }
  1020.        
  1021.         de = new DataElement();
  1022.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_LOCAL_FORWARD_STATO);
  1023.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_LOCAL_FORWARD);
  1024.         de.setSize(alternativeSize);
  1025.         if (localForwardDisable) {
  1026.             de.setType(DataElementType.HIDDEN);
  1027.         }else{
  1028.             String[] tipoLocalForward = { PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_LOCAL_FORWARD_ABILITATO,
  1029.                     PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_LOCAL_FORWARD_DISABILITATO };
  1030.             de.setType(DataElementType.SELECT);
  1031.             de.setValues(tipoLocalForward);
  1032.             de.setSelected(localForward);
  1033.             de.setPostBack(true);
  1034.         }
  1035.         de.setValue(localForward);
  1036.         dati.add(de);
  1037.        
  1038.         de = new DataElement();
  1039.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_LOCAL_FORWARD_PA);
  1040.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_LOCAL_FORWARD_PA);
  1041.         de.setValue(paLocalForward);
  1042.         if (localForwardDisable || !PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_LOCAL_FORWARD_ABILITATO.equals(localForward)) {
  1043.             de.setType(DataElementType.HIDDEN);
  1044.         }
  1045.         else {
  1046.             de.setType(DataElementType.TEXT_EDIT);
  1047.         }
  1048.         dati.add(de);
  1049.        
  1050.        
  1051.        
  1052.        
  1053.         // *************** CorrelazioneApplicativa *********************
  1054.         boolean show = false; // aggiunto link in trattamento messaggio    
  1055.         if (show &&
  1056.                 !idsogg.equals(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_NEW_ID)
  1057.                 && !idPorta.equals(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_NEW_ID)) {

  1058.             de = new DataElement();
  1059.             de.setType(DataElementType.TITLE);
  1060.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA);
  1061.             dati.add(de);
  1062.            
  1063.             if (tipoOp == TipoOperazione.CHANGE) {

  1064.                 if (riusoId && numCorrApp != 0) {
  1065.                     de = new DataElement();
  1066.                     de.setLabel(CostantiControlStation.LABEL_PARAMETRO_SCADENZA_CORRELAZIONE_APPLICATIVA_LABEL);
  1067.                     de.setNote(CostantiControlStation.LABEL_PARAMETRO_SCADENZA_CORRELAZIONE_APPLICATIVA_NOTE);
  1068.                     de.setValue(scadcorr);
  1069.                     de.setType(DataElementType.TEXT_EDIT);
  1070.                     de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_SCADENZA_CORRELAZIONE_APPLICATIVA);
  1071.                     de.setSize(alternativeSize);
  1072.                     dati.add(de);
  1073.                 }
  1074.             }
  1075.            
  1076.             de = new DataElement();
  1077.             de.setType(DataElementType.LINK);
  1078.             de.setUrl(
  1079.                     PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_REQUEST_LIST,
  1080.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg),
  1081.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+idPorta),
  1082.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME,nomePorta));

  1083.             if (contaListe) {
  1084.                 ServletUtils.setDataElementCustomLabel(de,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_RICHIESTA,Long.valueOf(numCorrelazioneReq));
  1085.             } else
  1086.                 ServletUtils.setDataElementCustomLabel(de,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_RICHIESTA);

  1087.             dati.add(de);

  1088.             de = new DataElement();
  1089.             de.setType(DataElementType.LINK);
  1090.             de.setUrl(
  1091.                     PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_RESPONSE_LIST,
  1092.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg),
  1093.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+idPorta),
  1094.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME,nomePorta));

  1095.             if (contaListe) {
  1096.                 ServletUtils.setDataElementCustomLabel(de,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_RISPOSTA,Long.valueOf(numCorrelazioneRes));
  1097.             } else
  1098.                 ServletUtils.setDataElementCustomLabel(de,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_RISPOSTA);

  1099.             dati.add(de);
  1100.         }
  1101.        
  1102.        
  1103.        
  1104.        
  1105.        
  1106.        
  1107.        
  1108.        
  1109.        
  1110.         // *************** Gestione Messaggio *********************
  1111.        
  1112.         if (!idsogg.equals(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_NEW_ID)
  1113.                 && !idPorta.equals(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_NEW_ID)) {
  1114.             if(!isConfigurazione) {
  1115.                
  1116.                 // Il link richiede ulteriori parametri.
  1117.                
  1118. //              de = new DataElement();
  1119. //              de.setType(DataElementType.TITLE);
  1120. //              de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_GESTIONE_MESSAGGIO);
  1121. //              dati.add(de);
  1122. //              
  1123. //              de = new DataElement();
  1124. //              de.setType(DataElementType.LINK);
  1125. //              de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA +"?" +
  1126. //                      PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO + "=" + idsogg + "&"
  1127. //                      + PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID + "=" + idPorta+ "&"
  1128. //                      + PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME + "=" + nomePorta);
  1129. //              String statoCorrelazioneApplicativa = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_DISABILITATA;
  1130. //              if(numCorrelazioneReq>0 || numCorrelazioneRes>0){
  1131. //                  statoCorrelazioneApplicativa = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_ABILITATA;
  1132. //              }
  1133. //              ServletUtils.setDataElementCustomLabel(de, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA, statoCorrelazioneApplicativa);
  1134. //              dati.add(de);
  1135. //              
  1136. //              de = new DataElement();
  1137. //              de.setType(DataElementType.LINK);
  1138. //              de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY +"?" +
  1139. //                      PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO + "=" + idsogg + "&"
  1140. //                      + PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID + "=" + idPorta);
  1141. //              ServletUtils.setDataElementCustomLabel(de, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY, statoMessageSecurity);
  1142. //              dati.add(de);
  1143. //  
  1144. //              //if(InterfaceType.AVANZATA.equals(ServletUtils.getUserFromSession(this.session).getInterfaceType())){
  1145. //              de = new DataElement();
  1146. //              de.setType(DataElementType.LINK);
  1147. //              de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM +"?" +
  1148. //                      PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO + "=" + idsogg + "&"
  1149. //                      + PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID + "=" + idPorta);
  1150. //              ServletUtils.setDataElementCustomLabel(de, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM, statoMTOM);
  1151. //              dati.add(de);
  1152. //              //}
  1153.             }  
  1154.         }
  1155.        
  1156.        
  1157.         // *************** Asincroni *********************
  1158.        
  1159.         boolean supportoAsincroni = this.core.isProfiloDiCollaborazioneAsincronoSupportatoDalProtocollo(protocollo,serviceBinding);
  1160.         if(supportoAsincroni) {
  1161.             de = new DataElement();
  1162.             if ( nascondiSezioneOpzioniAvanzate) {
  1163.                 de.setType(DataElementType.HIDDEN);
  1164.             }else{
  1165.                 de.setType(DataElementType.TITLE);
  1166.             }
  1167.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_GESTIONE_ASINCRONA );
  1168.             dati.add(de);
  1169.    
  1170.             String[] tipoRicsim = {PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_RICEVUTA_ASINCRONA_SIMMETRICA_ABILITATO
  1171.                     , PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_RICEVUTA_ASINCRONA_SIMMETRICA_DISABILITATO};
  1172.             de = new DataElement();
  1173.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RICEVUTA_ASINCRONA_SIMMETRICA);
  1174.             if (nascondiSezioneOpzioniAvanzate) {
  1175.                 de.setType(DataElementType.HIDDEN);
  1176.                 de.setValue(ricsim);
  1177.             }else{
  1178.                 de.setType(DataElementType.SELECT);
  1179.                 de.setValues(tipoRicsim);
  1180.                 de.setSelected(ricsim);
  1181.             }
  1182.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_RICEVUTA_ASINCRONA_SIMMETRICA);
  1183.             dati.add(de);
  1184.    
  1185.             String[] tipoRicasim = { PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_RICEVUTA_ASINCRONA_ASIMMETRICA_ABILITATO
  1186.                     , PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_RICEVUTA_ASINCRONA_ASIMMETRICA_DISABILITATO};
  1187.             de = new DataElement();
  1188.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RICEVUTA_ASINCRONA_ASIMMETRICA);
  1189.             if (nascondiSezioneOpzioniAvanzate) {
  1190.                 de.setType(DataElementType.HIDDEN);
  1191.                 de.setValue(ricasim);
  1192.             }else{
  1193.                 de.setType(DataElementType.SELECT);
  1194.                 de.setValues(tipoRicasim);
  1195.                 de.setSelected(ricasim);
  1196.             }
  1197.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_RICEVUTA_ASINCRONA_ASIMMETRICA);
  1198.             dati.add(de);
  1199.         }
  1200.        
  1201.        
  1202.        
  1203.        
  1204.        
  1205.         // ***************  SOAP With Attachments *********************

  1206.         boolean viewSoapWithAttachments = this.isModalitaAvanzata() && (!isConfigurazione || datiAltroPorta) && ServiceBinding.SOAP.equals(serviceBinding);
  1207.        
  1208.         if (viewSoapWithAttachments) {
  1209.        
  1210.             de = new DataElement();
  1211.             de.setType(DataElementType.TITLE);
  1212.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SOAP_WITH_ATTACHMENTS);
  1213.             dati.add(de);
  1214.            
  1215.         }
  1216.    
  1217.         String[] tipoGestBody = {PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_GEST_BODY_NONE ,
  1218.                 PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_GEST_BODY_ALLEGA,
  1219.                 PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_GEST_BODY_SCARTA };
  1220.         de = new DataElement();
  1221.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_GESTIONE_BODY);
  1222.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_GESTIONE_BODY);
  1223.         if (viewSoapWithAttachments) {
  1224.             de.setType(DataElementType.SELECT);
  1225.             de.setValues(tipoGestBody);
  1226.             de.setSelected(gestBody);
  1227.         }
  1228.         else {
  1229.             de.setType(DataElementType.HIDDEN);
  1230.             de.setValue(gestBody);
  1231.         }
  1232.         dati.add(de);

  1233.         String[] tipoGestManifest = {
  1234.                 PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_GEST_MANIFEST_DEFAULT,
  1235.                 PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_GEST_MANIFEST_ABILITATO,
  1236.                 PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_GEST_MANIFEST_DISABILITATO };
  1237.         de = new DataElement();
  1238.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_GESTIONE_MANIFEST);
  1239.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_GESTIONE_MANIFEST);
  1240.         if(isFunzionalitaProtocolloSupportataDalProtocollo(protocollo, serviceBinding, FunzionalitaProtocollo.MANIFEST_ATTACHMENTS)){
  1241.             if(viewSoapWithAttachments) {
  1242.                 de.setType(DataElementType.SELECT);
  1243.                 de.setValues(tipoGestManifest);
  1244.                 de.setSelected(gestManifest);
  1245.             }
  1246.             else {
  1247.                 de.setType(DataElementType.HIDDEN);
  1248.                 de.setValue(gestManifest);
  1249.             }
  1250.         }else {
  1251.             de.setType(DataElementType.HIDDEN);
  1252.             de.setValue(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_GEST_MANIFEST_DISABILITATO );
  1253.         }
  1254.         dati.add(de);
  1255.        
  1256.    
  1257. //      if(configurazioneStandardNonApplicabile){
  1258. //          this.pd.setMessage(CostantiControlStation.LABEL_CONFIGURAZIONE_IMPOSTATA_MODALITA_AVANZATA_LONG_MESSAGE, Costanti.MESSAGE_TYPE_INFO);
  1259. //          this.pd.disableEditMode();
  1260. //      }
  1261.        
  1262.        
  1263.        
  1264.        
  1265.        
  1266.        
  1267.        
  1268.        
  1269.         // ***************  MESSAGE FACTORY *********************
  1270.        
  1271.         if(!this.isModalitaStandard() && datiAltroApi) {
  1272.             de = new DataElement();
  1273.             de.setType(DataElementType.TITLE);
  1274.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_ENGINE);
  1275.             dati.add(de);
  1276.         }
  1277.        
  1278.         de = new DataElement();
  1279.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_GESTIONE_MESSAGE_ENGINE);
  1280.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_GESTIONE_MESSAGE_ENGINE);
  1281.         if(!this.isModalitaStandard() && datiAltroApi) {
  1282.             de.setType(DataElementType.SELECT);
  1283.             List<String> lS = new ArrayList<>();
  1284.             lS.add(CostantiControlStation.GESTIONE_MESSAGE_ENGINE_DEFAULT);
  1285.             lS.addAll(this.porteDelegateCore.getMessageEngines());
  1286.             de.setValues(lS);
  1287.             if(messageEngine==null || !lS.contains(messageEngine)) {
  1288.                 messageEngine = CostantiControlStation.GESTIONE_MESSAGE_ENGINE_DEFAULT;
  1289.             }
  1290.             de.setSelected(messageEngine);
  1291.         }
  1292.         else {
  1293.             de.setType(DataElementType.HIDDEN);
  1294.             de.setValue(messageEngine);
  1295.         }
  1296.         dati.add(de);
  1297.        
  1298.        
  1299.        
  1300.        
  1301.        
  1302.         return dati;
  1303.     }

  1304.     public List<PortaDelegataAzioneIdentificazione> getModalitaIdentificazionePorta(String protocollo, ServiceBinding serviceBinding)
  1305.             throws ProtocolException, DriverConfigurazioneException {
  1306.         return getModalitaIdentificazionePorta(protocollo, serviceBinding, ProtocolPropertiesUtilities.getTipoInterfaccia(this));
  1307.     }
  1308.    
  1309.     public List<PortaDelegataAzioneIdentificazione> getModalitaIdentificazionePorta(String protocollo, ServiceBinding serviceBinding, ConsoleInterfaceType consoleInterfaceType)
  1310.             throws ProtocolException, DriverConfigurazioneException {
  1311.        
  1312.         if(consoleInterfaceType==null) {
  1313.             consoleInterfaceType = ProtocolPropertiesUtilities.getTipoInterfaccia(this);
  1314.         }
  1315.        
  1316.         if(serviceBinding == null) {
  1317.             List<ServiceBinding> serviceBindingListProtocollo = this.core.getServiceBindingListProtocollo(protocollo);
  1318.            
  1319.             List<PortaDelegataAzioneIdentificazione> listaModalita = new ArrayList<PortaDelegataAzioneIdentificazione>();
  1320.             if(serviceBindingListProtocollo != null && serviceBindingListProtocollo.size() > 0) {
  1321.                 for (ServiceBinding serviceBinding2 : serviceBindingListProtocollo) {
  1322.                     List<PortaDelegataAzioneIdentificazione> listaModalitaTmp = ProtocolFactoryManager.getInstance().getProtocolFactoryByName(protocollo).
  1323.                             createProtocolIntegrationConfiguration().getAllSubscriptionIdentificationResourceModes(serviceBinding2,
  1324.                                     consoleInterfaceType);
  1325.                    
  1326.                     for (PortaDelegataAzioneIdentificazione tipoTmp : listaModalitaTmp) {
  1327.                         if(!listaModalita.contains(tipoTmp))
  1328.                             listaModalita.add(tipoTmp);
  1329.                     }
  1330.                 }
  1331.             }
  1332.             return listaModalita;
  1333.         } else {
  1334.             return ProtocolFactoryManager.getInstance().getProtocolFactoryByName(protocollo).
  1335.                     createProtocolIntegrationConfiguration().getAllSubscriptionIdentificationResourceModes(serviceBinding,
  1336.                             consoleInterfaceType);
  1337.         }
  1338.     }
  1339.    
  1340.     public boolean reuseIdProtocol(String protocollo) throws ProtocolException{
  1341.         return ProtocolFactoryManager.getInstance().getProtocolFactoryByName(protocollo).
  1342.                 createProtocolConfiguration().isAbilitatoRiusoIdCorrelazioneApplicativa();
  1343.     }


  1344.     public List<DataElement> addPorteDelegateCorrelazioneApplicativaRequestToDati(TipoOperazione tipoOp,
  1345.             PageData pd,   String elemxml, String mode,
  1346.             String pattern, String gif, String riusoIdMessaggio, List<DataElement> dati, String idcorr,
  1347.             String protocollo, org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding) throws ProtocolException {

  1348.         DataElement de = new DataElement();
  1349.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA);
  1350.         de.setType(DataElementType.TITLE);
  1351.         dati.add(de);
  1352.        
  1353.         dati.add(this.getDataElementNotCorrelazioneApplicativa());
  1354.         de = new DataElement();
  1355.         de.setLabel("");
  1356.         de.setValue("");
  1357.         de.setType(DataElementType.NOTE);
  1358.         dati.add(de);
  1359.        
  1360.         de = new DataElement();
  1361.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML);
  1362.         de.setNote(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML_NOTE);
  1363.         de.setType(DataElementType.TEXT_EDIT);
  1364.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML);
  1365.         de.setSize(80);
  1366.         if (elemxml == null || CostantiControlStation.LABEL_PORTE_CORRELAZIONE_APPLICATIVA_QUALSIASI.equals(elemxml)) {
  1367.             de.setValue("");
  1368.         } else {
  1369.             de.setValue(elemxml);
  1370.         }
  1371.         DataElementInfo dInfoPattern = new DataElementInfo(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML);
  1372.         dInfoPattern.setHeaderBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_APPLICABILITA);
  1373.         if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  1374.             dInfoPattern.setListBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_APPLICABILITA_VALORI_REST);
  1375.         }
  1376.         else {
  1377.             dInfoPattern.setListBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_APPLICABILITA_VALORI_SOAP);
  1378.         }
  1379.         de.setInfo(dInfoPattern);
  1380.         dati.add(de);

  1381.         String[] tipoMode = {
  1382.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_URL_BASED,
  1383.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_HEADER_BASED,
  1384.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_CONTENT_BASED,
  1385.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_INPUT_BASED,
  1386.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_TEMPLATE,
  1387.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE,
  1388.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE,
  1389.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_DISABILITATO
  1390.         };
  1391.         List<String> labels = ModalitaIdentificazione.getLabels(
  1392.                 ModalitaIdentificazione.URL_BASED,
  1393.                 ModalitaIdentificazione.HEADER_BASED,
  1394.                 ModalitaIdentificazione.CONTENT_BASED,
  1395.                 ModalitaIdentificazione.INPUT_BASED,
  1396.                 ModalitaIdentificazione.GOVWAY_TEMPLATE,
  1397.                 ModalitaIdentificazione.FREEMARKER_TEMPLATE,
  1398.                 ModalitaIdentificazione.VELOCITY_TEMPLATE);
  1399.         labels.add(CostantiControlStation.LABEL_PARAMETRO_MODE_CORRELAZIONE_DISABILITATO);
  1400.                
  1401.         //String[] tipoMode = { "contentBased", "disabilitato" };
  1402.         de = new DataElement();
  1403.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODALITA_IDENTIFICAZIONE);
  1404.         de.setType(DataElementType.SELECT);
  1405.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE);
  1406.         de.setValues(tipoMode);
  1407.         de.setLabels(labels);
  1408.         de.setSelected(mode);
  1409.         //              de.setOnChange("CambiaModeCorrApp('add','')");
  1410.         de.setPostBack(true);
  1411.         dati.add(de);

  1412.         if (PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_URL_BASED.equals(mode) ||
  1413.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_HEADER_BASED.equals(mode) ||
  1414.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_CONTENT_BASED.equals(mode) ||
  1415.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_TEMPLATE.equals(mode) ||
  1416.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE.equals(mode) ||
  1417.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE.equals(mode) ) {
  1418.             de = new DataElement();
  1419.             if(mode.equals(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_HEADER_BASED)) {
  1420.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  1421.                 de.setType(DataElementType.TEXT_EDIT);
  1422.             }
  1423.             else if(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_TEMPLATE.equals(mode) ||
  1424.                     PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE.equals(mode) ||
  1425.                     PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE.equals(mode) ) {
  1426.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TEMPLATE);
  1427.                 de.setType(DataElementType.TEXT_AREA);
  1428.                
  1429.                 if(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_TEMPLATE.equals(mode)) {
  1430.                     dInfoPattern = new DataElementInfo(ModalitaIdentificazione.GOVWAY_TEMPLATE.getLabel());
  1431.                     dInfoPattern.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TRASPORTO);
  1432.                     if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  1433.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_REST_VALORI(this.isProfiloModIPA(protocollo), true, false));
  1434.                     }
  1435.                     else {
  1436.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_SOAP_VALORI(this.isProfiloModIPA(protocollo), true, false));
  1437.                     }
  1438.                 }
  1439.                 else if(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE.equals(mode)) {
  1440.                     dInfoPattern = new DataElementInfo(ModalitaIdentificazione.FREEMARKER_TEMPLATE.getLabel());
  1441.                     dInfoPattern.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_OBJECT_TEMPLATE_FREEMARKER);
  1442.                     if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  1443.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_REST_VALORI_FREEMARKER(this.isProfiloModIPA(protocollo), true, false));
  1444.                     }
  1445.                     else {
  1446.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_SOAP_VALORI_FREEMARKER(this.isProfiloModIPA(protocollo), true, false));
  1447.                     }
  1448.                 }
  1449.                 else {
  1450.                     dInfoPattern = new DataElementInfo(ModalitaIdentificazione.VELOCITY_TEMPLATE.getLabel());
  1451.                     dInfoPattern.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_OBJECT_TEMPLATE_VELOCITY);
  1452.                     if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  1453.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_REST_VALORI_VELOCITY(this.isProfiloModIPA(protocollo), true, false));
  1454.                     }
  1455.                     else {
  1456.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_SOAP_VALORI_VELOCITY(this.isProfiloModIPA(protocollo), true, false));
  1457.                     }
  1458.                 }
  1459.                 de.setInfo(dInfoPattern);
  1460.             }
  1461.             else {
  1462.                 if(mode.equals(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_URL_BASED)) {
  1463.                     de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ESPRESSIONE_REGOLARE);
  1464.                 }
  1465.                 else {
  1466.                     de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTENT_PATTERN);
  1467.                 }
  1468.                 de.setType(DataElementType.TEXT_AREA);
  1469.                
  1470.                 if(mode.equals(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_CONTENT_BASED)) {
  1471.                     dInfoPattern = new DataElementInfo(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTENT_PATTERN);
  1472.                     if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  1473.                         dInfoPattern.setHeaderBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_PATTERN_REST);
  1474.                         dInfoPattern.setListBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_PATTERN_VALORI_REST);
  1475.                     }
  1476.                     else {
  1477.                         dInfoPattern.setBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_PATTERN_SOAP);
  1478.                     }
  1479.                     de.setInfo(dInfoPattern);
  1480.                 }
  1481.             }
  1482.             if (pattern == null) {
  1483.                 de.setValue("");
  1484.             } else {
  1485.                 de.setValue(pattern);
  1486.             }
  1487.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_PATTERN);
  1488.             de.setRequired(true);
  1489.             dati.add(de);
  1490.         }

  1491.         if(!PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_DISABILITATO.equals(mode)){
  1492.             String[] tipiGIF = { CostantiConfigurazione.BLOCCA.toString(), CostantiConfigurazione.ACCETTA.toString()};
  1493.             de = new DataElement();
  1494.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_GESTIONE_IDENTIFICAZIONE_FALLITA);
  1495.             de.setType(DataElementType.SELECT);
  1496.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_GESTIONE_IDENTIFICAZIONE_FALLITA);
  1497.             de.setValues(tipiGIF);
  1498.             de.setSelected(gif);
  1499.             dati.add(de);

  1500.             String[] tipiRiusoIdMessaggio = { CostantiConfigurazione.DISABILITATO.toString(), CostantiConfigurazione.ABILITATO.toString()};
  1501.             de = new DataElement();
  1502.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RIUSO_ID_MESSAGGIO);
  1503.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_RIUSO_ID_MESSAGGIO);
  1504.             if(this.reuseIdProtocol(protocollo)) {
  1505.                 de.setType(DataElementType.SELECT);
  1506.                 de.setValues(tipiRiusoIdMessaggio);
  1507.                 de.setSelected(riusoIdMessaggio);
  1508.             }
  1509.             else {
  1510.                 de.setType(DataElementType.HIDDEN);
  1511.                 de.setValue(CostantiConfigurazione.DISABILITATO.toString());
  1512.             }
  1513.             dati.add(de);

  1514.         }

  1515.         if(idcorr != null){
  1516.             de = new DataElement();
  1517.             de.setValue(idcorr);
  1518.             de.setType(DataElementType.HIDDEN);
  1519.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_CORRELAZIONE);
  1520.             dati.add(de);
  1521.         }

  1522.         return dati;

  1523.     }

  1524.     public List<DataElement> addPorteDelegateCorrelazioneApplicativaResponseToDati(TipoOperazione tipoOp,
  1525.             PageData pd, String elemxml, String mode,
  1526.             String pattern, String gif,
  1527.             //          String riuso,
  1528.             List<DataElement> dati, String idcorr, org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding,
  1529.             String protocollo) {

  1530.         DataElement de = new DataElement();
  1531.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA);
  1532.         de.setType(DataElementType.TITLE);
  1533.         dati.add(de);
  1534.        
  1535.         dati.add(this.getDataElementNotCorrelazioneApplicativa());
  1536.         de = new DataElement();
  1537.         de.setLabel("");
  1538.         de.setValue("");
  1539.         de.setType(DataElementType.NOTE);
  1540.         dati.add(de);
  1541.        
  1542.         de = new DataElement();
  1543.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML);
  1544.         de.setNote(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML_NOTE);
  1545.         de.setType(DataElementType.TEXT_EDIT);
  1546.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML);
  1547.         de.setSize(80);
  1548.         if (elemxml == null || CostantiControlStation.LABEL_PORTE_CORRELAZIONE_APPLICATIVA_QUALSIASI.equals(elemxml)) {
  1549.             de.setValue("");
  1550.         } else {
  1551.             de.setValue(elemxml);
  1552.         }
  1553.         DataElementInfo dInfoPattern = new DataElementInfo(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML);
  1554.         dInfoPattern.setHeaderBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_APPLICABILITA);
  1555.         if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  1556.             dInfoPattern.setListBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_APPLICABILITA_VALORI_REST);
  1557.         }
  1558.         else {
  1559.             dInfoPattern.setListBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_APPLICABILITA_VALORI_SOAP);
  1560.         }
  1561.         de.setInfo(dInfoPattern);
  1562.         dati.add(de);

  1563.         String[] tipoMode = {
  1564.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_HEADER_BASED,
  1565.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_CONTENT_BASED,
  1566.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_INPUT_BASED,
  1567.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_TEMPLATE,
  1568.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE,
  1569.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE,
  1570.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_DISABILITATO
  1571.         };
  1572.         List<String> labels = ModalitaIdentificazione.getLabels(
  1573.                 ModalitaIdentificazione.HEADER_BASED,
  1574.                 ModalitaIdentificazione.CONTENT_BASED,
  1575.                 ModalitaIdentificazione.INPUT_BASED,
  1576.                 ModalitaIdentificazione.GOVWAY_TEMPLATE,
  1577.                 ModalitaIdentificazione.FREEMARKER_TEMPLATE,
  1578.                 ModalitaIdentificazione.VELOCITY_TEMPLATE);
  1579.         labels.add(CostantiControlStation.LABEL_PARAMETRO_MODE_CORRELAZIONE_DISABILITATO);
  1580.        
  1581.         //String[] tipoMode = { "contentBased", "disabilitato" };
  1582.         de = new DataElement();
  1583.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODALITA_IDENTIFICAZIONE);
  1584.         de.setType(DataElementType.SELECT);
  1585.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE);
  1586.         de.setValues(tipoMode);
  1587.         de.setLabels(labels);
  1588.         de.setSelected(mode);
  1589.         //              de.setOnChange("CambiaModeCorrApp('add','')");
  1590.         de.setPostBack(true);
  1591.         dati.add(de);

  1592.         if (PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_URL_BASED.equals(mode) ||
  1593.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_HEADER_BASED.equals(mode) ||
  1594.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_CONTENT_BASED.equals(mode) ||
  1595.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_TEMPLATE.equals(mode) ||
  1596.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE.equals(mode) ||
  1597.                 PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE.equals(mode)) {
  1598.             de = new DataElement();
  1599.             if(mode.equals(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_HEADER_BASED)) {
  1600.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  1601.                 de.setType(DataElementType.TEXT_EDIT);
  1602.             }
  1603.             else if(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_TEMPLATE.equals(mode) ||
  1604.                     PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE.equals(mode) ||
  1605.                     PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_VELOCITY_TEMPLATE.equals(mode) ) {
  1606.                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TEMPLATE);
  1607.                 de.setType(DataElementType.TEXT_AREA);
  1608.                
  1609.                 if(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_TEMPLATE.equals(mode)) {
  1610.                     dInfoPattern = new DataElementInfo(ModalitaIdentificazione.GOVWAY_TEMPLATE.getLabel());
  1611.                     dInfoPattern.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TRASPORTO);
  1612.                     if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  1613.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_REST_VALORI_CON_RISPOSTE(this.isProfiloModIPA(protocollo), true, false));
  1614.                     }
  1615.                     else {
  1616.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_TRASFORMAZIONI_TRASPORTO_SOAP_VALORI_CON_RISPOSTE(this.isProfiloModIPA(protocollo), true, false));
  1617.                     }
  1618.                 }
  1619.                 else if(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_FREEMARKER_TEMPLATE.equals(mode)) {
  1620.                     dInfoPattern = new DataElementInfo(ModalitaIdentificazione.FREEMARKER_TEMPLATE.getLabel());
  1621.                     dInfoPattern.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_OBJECT_TEMPLATE_FREEMARKER);
  1622.                     if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  1623.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_REST_VALORI_CON_RISPOSTE_FREEMARKER(this.isProfiloModIPA(protocollo), true, false));
  1624.                     }
  1625.                     else {
  1626.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_SOAP_VALORI_CON_RISPOSTE_FREEMARKER(this.isProfiloModIPA(protocollo), true, false));
  1627.                     }
  1628.                 }
  1629.                 else {
  1630.                     dInfoPattern = new DataElementInfo(ModalitaIdentificazione.VELOCITY_TEMPLATE.getLabel());
  1631.                     dInfoPattern.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_OBJECT_TEMPLATE_VELOCITY);
  1632.                     if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  1633.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_REST_VALORI_CON_RISPOSTE_VELOCITY(this.isProfiloModIPA(protocollo), true, false));
  1634.                     }
  1635.                     else {
  1636.                         dInfoPattern.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_OBJECT_SOAP_VALORI_CON_RISPOSTE_VELOCITY(this.isProfiloModIPA(protocollo), true, false));
  1637.                     }
  1638.                 }
  1639.                 de.setInfo(dInfoPattern);
  1640.             }
  1641.             else {
  1642.                 if(mode.equals(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_URL_BASED)) {
  1643.                     de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ESPRESSIONE_REGOLARE);
  1644.                 }
  1645.                 else {
  1646.                     de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTENT_PATTERN);
  1647.                 }
  1648.                 de.setType(DataElementType.TEXT_AREA);
  1649.                
  1650.                 if(mode.equals(PorteDelegateCostanti.VALUE_PARAMETRO_PORTE_DELEGATE_TIPO_MODE_CORRELAZIONE_CONTENT_BASED)) {
  1651.                     dInfoPattern = new DataElementInfo(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTENT_PATTERN);
  1652.                     if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(serviceBinding)) {
  1653.                         dInfoPattern.setHeaderBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_PATTERN_REST);
  1654.                         dInfoPattern.setListBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_PATTERN_VALORI_REST);
  1655.                     }
  1656.                     else {
  1657.                         dInfoPattern.setBody(CostantiControlStation.LABEL_CONFIGURAZIONE_CORRELAZIONE_APPLICATIVA_INFO_PATTERN_SOAP);
  1658.                     }
  1659.                     de.setInfo(dInfoPattern);
  1660.                 }
  1661.             }
  1662.             if (pattern == null) {
  1663.                 de.setValue("");
  1664.             } else {
  1665.                 de.setValue(pattern);
  1666.             }
  1667.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_PATTERN);
  1668.             de.setRequired(true);
  1669.             dati.add(de);
  1670.         }

  1671.         if(!PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_DISABILITATO.equals(mode)){
  1672.             String[] tipiGIF = { CostantiConfigurazione.BLOCCA.toString(), CostantiConfigurazione.ACCETTA.toString()};
  1673.             de = new DataElement();
  1674.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_GESTIONE_IDENTIFICAZIONE_FALLITA);
  1675.             de.setType(DataElementType.SELECT);
  1676.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_GESTIONE_IDENTIFICAZIONE_FALLITA);
  1677.             de.setValues(tipiGIF);
  1678.             de.setSelected(gif);
  1679.             dati.add(de);

  1680.             //          String[] tipiRiusoID = { CostantiConfigurazione.DISABILITATO, CostantiConfigurazione.ABILITATO};
  1681.             //          de = new DataElement();
  1682.             //          de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RIUSO_ID_MESSAGGIO);
  1683.             //          de.setType(DataElementType.SELECT);
  1684.             //          de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_RIUSO_ID_MESSAGGIO);
  1685.             //          de.setValues(tipiRiusoID);
  1686.             //          de.setSelected(riuso);
  1687.             //          dati.add(de);

  1688.         }

  1689.         if(idcorr != null){
  1690.             de = new DataElement();
  1691.             de.setValue(idcorr);
  1692.             de.setType(DataElementType.HIDDEN);
  1693.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_CORRELAZIONE);
  1694.             dati.add(de);
  1695.         }


  1696.         return dati;

  1697.     }

  1698.     // Controlla i dati del message-security response-flow della porta delegata
  1699.     public boolean porteDelegateMessageSecurityResponseCheckData(TipoOperazione tipoOp) throws ControlStationCoreException {
  1700.         try {
  1701.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  1702.             int idInt = Integer.parseInt(id);
  1703.             String nome = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME);
  1704.             String valore = this.getLockedParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_VALORE, false);

  1705.             // Campi obbligatori
  1706.             if (nome.equals("") || valore.equals("")) {
  1707.                 String tmpElenco = "";
  1708.                 if (nome.equals("")) {
  1709.                     tmpElenco = "Nome";
  1710.                 }
  1711.                 if (valore.equals("")) {
  1712.                     if (tmpElenco.equals("")) {
  1713.                         tmpElenco = "Valore";
  1714.                     } else {
  1715.                         tmpElenco = tmpElenco + ", Valore";
  1716.                     }
  1717.                 }
  1718.                 this.pd.setMessage(MessageFormat.format(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, tmpElenco));
  1719.                 return false;
  1720.             }

  1721.             // Controllo che non ci siano spazi nei campi di testo
  1722.             if ((nome.indexOf(" ") != -1) ) {
  1723.                 this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_NOMI);
  1724.                 return false;
  1725.             }
  1726.             if(
  1727.                     (!this.core.getDriverBYOKUtilities().isEnabledBYOK() || !this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(valore))
  1728.                     &&
  1729.                     (valore.startsWith(" ") || valore.endsWith(" "))
  1730.                 ){
  1731.                 this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_ALL_INIZIO_O_ALLA_FINE_DEI_VALORI);
  1732.                 return false;
  1733.             }
  1734.             if(!this.checkLength255(nome, PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME)) {
  1735.                 return false;
  1736.             }

  1737.             // Se tipoOp = add, controllo che il message-security non sia gia' stato
  1738.             // registrato per la porta delegata
  1739.             if (tipoOp.equals(TipoOperazione.ADD)) {
  1740.                 boolean giaRegistrato = false;
  1741.                 PortaDelegata pde = this.porteDelegateCore.getPortaDelegata(idInt);
  1742.                 String nomeporta = pde.getNome();
  1743.                 MessageSecurity messageSecurity = pde.getMessageSecurity();

  1744.                 if(messageSecurity!=null &&
  1745.                     messageSecurity.getResponseFlow()!=null){
  1746.                     for (int i = 0; i < messageSecurity.getResponseFlow().sizeParameterList(); i++) {
  1747.                         MessageSecurityFlowParameter tmpMessageSecurity =messageSecurity.getResponseFlow().getParameter(i);
  1748.                         if (nome.equals(tmpMessageSecurity.getNome())) {
  1749.                             giaRegistrato = true;
  1750.                             break;
  1751.                         }
  1752.                     }
  1753.                 }

  1754.                 if (giaRegistrato) {
  1755.                     this.pd.setMessage(MessageFormat.format(PorteDelegateCostanti.MESSAGGIO_ERRORE_LA_PROPRIETA_DI_MESSAGE_SECURITY_XX_E_GIA_STATO_ASSOCIATA_ALLA_PORTA_DELEGATA_YY,    nome, nomeporta));
  1756.                     return false;
  1757.                 }
  1758.             }

  1759.             return true;

  1760.         } catch (Exception e) {
  1761.             this.logError(e.getMessage(), e);
  1762.             throw new ControlStationCoreException(e.getMessage(),e);
  1763.         }
  1764.     }






  1765.     // Controlla i dati della porta delegata
  1766.     public boolean porteDelegateCheckData(TipoOperazione tipoOp, String oldNomePD, boolean datiAltroPorta,
  1767.             ServiceBinding serviceBinding)
  1768.             throws Exception {
  1769.         try {
  1770.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  1771.             String nomePD = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA);
  1772.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  1773.             int soggInt = Integer.parseInt(idsogg);
  1774.             String descr = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_DESCRIZIONE);
  1775.             String autenticazione = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE);
  1776.             String autenticazioneCustom = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM);
  1777.             String autenticazioneOpzionale = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_OPZIONALE);
  1778.             String autenticazionePrincipalTipo = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TIPO);
  1779.             TipoAutenticazionePrincipal autenticazionePrincipal = TipoAutenticazionePrincipal.toEnumConstant(autenticazionePrincipalTipo, false);
  1780.             List<String> autenticazioneParametroList = this.convertFromDataElementValue_parametroAutenticazioneList(autenticazione, autenticazionePrincipal);
  1781.             String autorizzazione = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE);
  1782.             String autorizzazioneCustom = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM);
  1783.             String autorizzazioneAutenticati = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE);
  1784.             String autorizzazioneRuoli = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI);
  1785.             String autorizzazioneRuoliTipologia = this.getParameter(CostantiControlStation.PARAMETRO_RUOLO_TIPOLOGIA);
  1786.             String ruoloMatch = this.getParameter(CostantiControlStation.PARAMETRO_RUOLO_MATCH);
  1787.             String soggid = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_SOGGETTO_ID);
  1788.             String servid = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_SERVIZIO_ID);
  1789.             String azid = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_AZIONE_ID);
  1790.             String modeaz = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_AZIONE);
  1791.             String azione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_AZIONE);
  1792.             String statoValidazione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_XSD);

  1793.             String autorizzazioneContenutiStato = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_STATO);
  1794.             String autorizzazioneContenuti = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI);
  1795.             String autorizzazioneContenutiProperties = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_PROPERTIES);
  1796.            
  1797.            
  1798.             // Campi obbligatori
  1799.             if (nomePD==null || nomePD.equals("")) {
  1800.                 this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_EGRAVE_NECESSARIO_INDICARE_IL_NOME);
  1801.                 return false;
  1802.             }

  1803.             if (soggid == null) {
  1804.                 this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_NON_E_STATO_TROVATO_NESSUN_SOGGETTO_EROGATORE_SCEGLIERE_UNA_DELLE_ALTRE_MODALITA);
  1805.                 return false;
  1806.             }

  1807.             if (servid == null) {
  1808.                 this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_NON_E_STATO_TROVATO_NESSUN_SERVIZIO_ASSOCIATO_AL_SOGGETTO_EROGATORE_SCEGLIERE_UNA_DELLE_ALTRE_MODALITA);
  1809.                 return false;
  1810.             }
  1811.            
  1812.             if (modeaz == null) {
  1813.                 this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_NON_E_STATA_TROVATA_NESSUNA_MODALITA_AZIONE);
  1814.                 return false;
  1815.             }

  1816.             if (modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT) && (azid == null)) {
  1817.                 this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_NON_E_STATA_TROVATA_NESSUNA_AZIONE_ASSOCIATA_AL_SERVIZIO_SCEGLIERE_UNA_DELLE_ALTRE_MODALITA);
  1818.                 return false;
  1819.             }
  1820.             if ((modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_URL_BASED) ||
  1821.                     modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_HEADER_BASED) ||
  1822.                     modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_CONTENT_BASED)) && (azione==null || azione.equals(""))) {
  1823.                 this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_PATTERN_AZIONE);
  1824.                 return false;
  1825.             }
  1826.            
  1827.             if (modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_URL_BASED)) {
  1828.                 if(this.checkRegexp(azione,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ESPRESSIONE_REGOLARE)==false){
  1829.                     return false;
  1830.                 }
  1831.             }
  1832.             if (modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_CONTENT_BASED)) {
  1833.                 if(ServiceBinding.SOAP.equals(serviceBinding)) {
  1834.                     if(this.checkXPath(azione,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTENT_PATTERN)==false){
  1835.                         return false;
  1836.                     }
  1837.                 }
  1838.                 else {
  1839.                     if(this.checkXPathOrJsonPath(azione,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTENT_PATTERN)==false){
  1840.                         return false;
  1841.                     }
  1842.                 }
  1843.             }

  1844.             // Controllo che non ci siano spazi nei campi di testo
  1845.             if ((nomePD.indexOf(" ") != -1) ) {
  1846.                 this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_CAMPI_DI_TESTO);
  1847.                 return false;
  1848.             }
  1849.             if(this.checkIntegrationEntityName(nomePD,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME)==false){
  1850.                 return false;
  1851.             }
  1852.             if ((modeaz != null) && !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT) &&
  1853.                     !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_INPUT_BASED) &&
  1854.                     !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_SOAP_ACTION_BASED) &&
  1855.                     !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_CONTENT_BASED) &&
  1856.                     !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_DELEGATED_BY) &&
  1857.                     (azione != null && azione.indexOf(" ") != -1)) {
  1858.                 this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_CAMPI_DI_TESTO);
  1859.                 return false;
  1860.             }

  1861.             // descrizione
  1862.             if( (tipoOp.equals(TipoOperazione.CHANGE))
  1863.                     &&
  1864.                 (descr!=null && StringUtils.isNotEmpty(descr))
  1865.                     &&
  1866.                 (!this.checkLength4000(descr, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_DESCRIZIONE))
  1867.                 ){
  1868.                 return false;
  1869.             }
  1870.            
  1871.             // integrazione metadati
  1872.             if(tipoOp == TipoOperazione.CHANGE && datiAltroPorta) {
  1873.                 boolean validazioneIntegrazione = this.validaIntegrazioneMetadati();
  1874.                 if(!validazioneIntegrazione)
  1875.                     return false;
  1876.             }
  1877.            
  1878.             // rate limiting
  1879.             if(tipoOp == TipoOperazione.CHANGE && datiAltroPorta) {
  1880.                 boolean validazioneRT = this.validaOpzioniAvanzateRateLimiting(RuoloPolicy.DELEGATA,nomePD);
  1881.                 if(!validazioneRT)
  1882.                     return false;
  1883.             }
  1884.            
  1885. //          // Controllo che i campi "select" abbiano uno dei valori ammessi
  1886. //          if ((modeaz != null) && !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_HEADER_BASED) &&
  1887. //                  !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT) &&
  1888. //                  !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_URL_BASED) &&
  1889. //                  !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_CONTENT_BASED) &&
  1890. //                  !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_INPUT_BASED) &&
  1891. //                  !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_SOAP_ACTION_BASED) &&
  1892. //                  !modeaz.equals(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_WSDL_BASED)) {
  1893. //              this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_MODE_AZIONE_DEV_ESSERE_USER_INPUT_REGISTER_INPUT_URL_BASED_CONTENT_BASED_INPUT_BASED_SOAP_ACTION_BASED_O_WSDL_BASED);
  1894. //              return false;
  1895. //          }
  1896.             if(tipoOp.equals(TipoOperazione.ADD)) {
  1897.                 if (!statoValidazione.equals(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_ABILITATO) &&
  1898.                         !statoValidazione.equals(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_DISABILITATO) &&
  1899.                         !statoValidazione.equals(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_WARNING_ONLY)) {
  1900.                     this.pd.setMessage(PorteDelegateCostanti.MESSAGGIO_ERRORE_VALIDAZIONE_XSD_DEV_ESSERE_ABILITATO_DISABILITATO_O_WARNING_ONLY);
  1901.                     return false;
  1902.                 }
  1903.             }

  1904.             // Se autenticazione = custom, nomeauth dev'essere specificato
  1905.             if (CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM.equals(autenticazione) &&
  1906.                     (autenticazioneCustom == null || autenticazioneCustom.equals(""))) {
  1907.                 this.pd.setMessage(MessageFormat.format(PorteDelegateCostanti.MESSAGGIO_ERRORE_INDICARE_UN_NOME_PER_L_AUTENTICAZIONE_XX, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM));
  1908.                 return false;
  1909.             }

  1910.             // Se autorizzazione = custom, nomeautor dev'essere specificato
  1911.             if (CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM.equals(autorizzazione) &&
  1912.                     (autorizzazioneCustom == null || autorizzazioneCustom.equals(""))) {
  1913.                 this.pd.setMessage(MessageFormat.format(PorteDelegateCostanti.MESSAGGIO_ERRORE_INDICARE_UN_NOME_PER_L_AUTORIZZAZIONE_XX, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM));
  1914.                 return false;
  1915.             }
  1916.            
  1917.             PortaDelegata pdDatabase = null;
  1918.             if (TipoOperazione.CHANGE.equals(tipoOp)){
  1919.                 pdDatabase = this.porteDelegateCore.getPortaDelegata(Long.parseLong(id));
  1920.             }
  1921.            
  1922.             List<String> ruoli = new ArrayList<>();
  1923.             if(pdDatabase!=null && pdDatabase.getRuoli()!=null && pdDatabase.getRuoli().sizeRuoloList()>0){
  1924.                 for (int i = 0; i < pdDatabase.getRuoli().sizeRuoloList(); i++) {
  1925.                     ruoli.add(pdDatabase.getRuoli().getRuolo(i).getNome());
  1926.                 }
  1927.             }
  1928.            
  1929.             if(tipoOp.equals(TipoOperazione.ADD)) {
  1930.                 String gestioneToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN);
  1931.                 String gestioneTokenPolicy = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  1932.                 String gestioneTokenValidazioneInput = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  1933.                 String gestioneTokenIntrospection = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  1934.                 String gestioneTokenUserInfo = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  1935.                 String gestioneTokenTokenForward = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  1936.                 String autorizzazione_token = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN);
  1937.                 String autorizzazione_tokenOptions = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_OPTIONS);
  1938.                 String autorizzazioneScope = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE);
  1939.                 String autorizzazioneScopeMatch = this.getParameter(CostantiControlStation.PARAMETRO_SCOPE_MATCH);
  1940.                 BinaryParameter allegatoXacmlPolicy = this.getBinaryParameter(CostantiControlStation.PARAMETRO_DOCUMENTO_SICUREZZA_XACML_POLICY);
  1941.                
  1942.                 String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  1943.                 if(idAsps == null)
  1944.                     idAsps = "";
  1945.                
  1946.                 AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Long.parseLong(idAsps));
  1947.                
  1948.                 String protocollo = ProtocolFactoryManager.getInstance().getProtocolByServiceType(asps.getTipo());
  1949.                
  1950.                 String identificazioneAttributiStato = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO);
  1951.                 String [] attributeAuthoritySelezionate = this.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  1952.                 String attributeAuthorityAttributi = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI);
  1953.                
  1954.                 String autorizzazioneAutenticatiToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE_TOKEN);
  1955.                 String autorizzazioneRuoliToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_TOKEN);
  1956.                
  1957.                 if(this.controlloAccessiCheck(tipoOp, autenticazione, autenticazioneOpzionale, autenticazionePrincipal, autenticazioneParametroList,
  1958.                         autorizzazione, autorizzazioneAutenticati, autorizzazioneRuoli,
  1959.                         autorizzazioneRuoliTipologia, ruoloMatch,
  1960.                         true, true, null, ruoli,gestioneToken, gestioneTokenPolicy,
  1961.                         gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  1962.                         autorizzazioneAutenticatiToken, autorizzazioneRuoliToken,
  1963.                         autorizzazione_token,autorizzazione_tokenOptions,
  1964.                         autorizzazioneScope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  1965.                         autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties,
  1966.                         protocollo,
  1967.                         identificazioneAttributiStato, attributeAuthoritySelezionate, attributeAuthorityAttributi)==false){
  1968.                     return false;
  1969.                 }
  1970.             }

  1971.             IDSoggetto idSoggettoFruitore = null;
  1972.             if(this.core.isRegistroServiziLocale()){
  1973.                 // Soggetto Fruitore
  1974.                 Soggetto soggettoFruitore = null;
  1975.                 soggettoFruitore = this.soggettiCore.getSoggettoRegistro(soggInt);
  1976.                 idSoggettoFruitore = new IDSoggetto(soggettoFruitore.getTipo(), soggettoFruitore.getNome());
  1977.             }
  1978.             else{
  1979.                 // Soggetto Fruitore
  1980.                 org.openspcoop2.core.config.Soggetto soggettoFruitore = null;
  1981.                 soggettoFruitore = this.soggettiCore.getSoggetto(soggInt);
  1982.                 idSoggettoFruitore = new IDSoggetto(soggettoFruitore.getTipo(), soggettoFruitore.getNome());
  1983.             }
  1984.            
  1985.             IDPortaDelegata idPD = new IDPortaDelegata();
  1986.             idPD.setNome(nomePD);

  1987.             // Se tipoOp = add, controllo che la porta delegata non sia gia'
  1988.             // stata registrata
  1989.             if (TipoOperazione.ADD.equals(tipoOp)) {
  1990.                 boolean giaRegistrato = false;
  1991.                 long idPDGiaRegistrata = -1;
  1992.                 try {
  1993.                     // controllo puntuale su nome
  1994.                     idPDGiaRegistrata = this.porteDelegateCore.getIdPortaDelegata(nomePD);
  1995.                     giaRegistrato = idPDGiaRegistrata > 0;
  1996.                     // controllo su location e nome
  1997.                     if (!giaRegistrato)
  1998.                         giaRegistrato = this.porteDelegateCore.getPortaDelegata(idPD) != null;
  1999.                 } catch (DriverConfigurazioneNotFound e) {
  2000.                     giaRegistrato = false;
  2001.                 }

  2002.                 if (giaRegistrato) {
  2003.                     PortaDelegata pd = this.porteDelegateCore.getPortaDelegata(idPDGiaRegistrata);
  2004.                     String soggettoProprietarioMessaggio = pd.getTipoSoggettoProprietario()+"/"+pd.getNomeSoggettoProprietario();
  2005.                     this.pd.setMessage(MessageFormat.format(
  2006.                             PorteDelegateCostanti.MESSAGGIO_ERRORE_ESISTE_GIA_UNA_PORTA_DELEGATA_CON_NOME_XX_ASSOCIATA_AL_SOGGETTO_YY, nomePD,
  2007.                             soggettoProprietarioMessaggio));
  2008.                     return false;
  2009.                 }
  2010.             } else if (TipoOperazione.CHANGE.equals(tipoOp)) {
  2011.                 PortaDelegata portaDelegata = null;
  2012.                 try {
  2013.                     // controllo su nome (non possono esistere 2 pd con stesso
  2014.                     // nome dello stesso fruitore)
  2015.                     if (!nomePD.equals(oldNomePD)) {
  2016.                         long curID = this.porteDelegateCore.getIdPortaDelegata(nomePD);
  2017.                         if (curID > 0) {
  2018.                             PortaDelegata pd = this.porteDelegateCore.getPortaDelegata(curID);
  2019.                             String soggettoProprietarioMessaggio = pd.getTipoSoggettoProprietario()+"/"+pd.getNomeSoggettoProprietario();
  2020.                             this.pd.setMessage(MessageFormat.format(
  2021.                                     PorteDelegateCostanti.MESSAGGIO_ERRORE_ESISTE_GIA_UNA_PORTA_DELEGATA_CON_NOME_XX_ASSOCIATA_AL_SOGGETTO_YY,
  2022.                                     nomePD, soggettoProprietarioMessaggio));
  2023.                             return false;
  2024.                         }
  2025.                     }

  2026.                     // controllo porta delegata per location (questo controlla
  2027.                     // anche il nome in caso di location non presente)
  2028.                     portaDelegata = this.porteDelegateCore.getPortaDelegata(idPD);

  2029.                 } catch (DriverConfigurazioneNotFound e) {
  2030.                     // ok non esiste un altra porta delegata del fruitore con
  2031.                     // questa location
  2032.                 }

  2033.                 // controllo se la pdd che ho ottenuto e' quella che sto
  2034.                 // modificando
  2035.                 // in tal caso procedo con l update altrimenti non posso fare
  2036.                 // update in quanto pdd gia esistente
  2037.                 long oldIDpd =  this.porteDelegateCore.getIdPortaDelegata(oldNomePD);
  2038.                 if (portaDelegata != null) {
  2039.                     if (oldIDpd != portaDelegata.getId()) {
  2040.                         PortaDelegata pd = this.porteDelegateCore.getPortaDelegata(oldIDpd);
  2041.                         String soggettoProprietarioMessaggio = pd.getTipoSoggettoProprietario()+"/"+pd.getNomeSoggettoProprietario();
  2042.                         this.pd.setMessage(MessageFormat.format(
  2043.                                 PorteDelegateCostanti.MESSAGGIO_ERRORE_ESISTE_GIA_UNA_PORTA_DELEGATA_CON_NOME_XX_ASSOCIATA_AL_SOGGETTO_YY,
  2044.                                 portaDelegata.getNome(), soggettoProprietarioMessaggio));
  2045.                         return false;
  2046.                     }
  2047.                 }
  2048.                
  2049.                 // Controllo che se e' stato cambiato il tipo di autenticazione, non devono essere presenti serviziApplicativi incompatibili
  2050.                 if(portaDelegata==null){
  2051.                     // la prelevo con il vecchio nome
  2052.                     portaDelegata = this.porteDelegateCore.getPortaDelegata(oldIDpd);
  2053.                 }
  2054.                 if(autenticazione!=null && autenticazione.equals(portaDelegata.getAutenticazione())==false){
  2055.                     CredenzialeTipo c = CredenzialeTipo.toEnumConstant(autenticazione);
  2056.                     if(c!=null){
  2057.                         if(portaDelegata.sizeServizioApplicativoList()>0){
  2058.                            
  2059.                             boolean saCompatibili = true;
  2060.                             for (int i = 0; i < portaDelegata.sizeServizioApplicativoList(); i++) {
  2061.                                
  2062.                                 IDServizioApplicativo idServizioApplicativo = new IDServizioApplicativo();
  2063.                                 idServizioApplicativo.setNome(portaDelegata.getServizioApplicativo(i).getNome());
  2064.                                 idServizioApplicativo.setIdSoggettoProprietario(idSoggettoFruitore);
  2065.                                 ServizioApplicativo saTmp = this.saCore.getServizioApplicativo(idServizioApplicativo);
  2066.                                
  2067.                                 if(saTmp.getInvocazionePorta()==null){
  2068.                                     saCompatibili=false;
  2069.                                     break;
  2070.                                 }
  2071.                                 if(saTmp.getInvocazionePorta().sizeCredenzialiList()<=0){
  2072.                                     saCompatibili=false;
  2073.                                     break;
  2074.                                 }
  2075.                                
  2076.                                 boolean ok = false;
  2077.                                 for (int j = 0; j < saTmp.getInvocazionePorta().sizeCredenzialiList(); j++) {
  2078.                                     CredenzialeTipo cSA =saTmp.getInvocazionePorta().getCredenziali(j).getTipo();
  2079.                                     if( c.equals(cSA) ){
  2080.                                         ok = true;
  2081.                                         break;
  2082.                                     }
  2083.                                 }
  2084.                                 if(!ok){
  2085.                                     saCompatibili=false;
  2086.                                     break;
  2087.                                 }
  2088.                             }
  2089.                            
  2090.                             if(saCompatibili==false){
  2091.                                 this.pd.setMessage(MessageFormat.format(
  2092.                                         PorteDelegateCostanti.MESSAGGIO_ERRORE_NON_E_POSSIBILE_MODIFICARE_IL_TIPO_DI_AUTENTICAZIONE_DA_XX_A_YY_POICHE_RISULTANO_ASSOCIATI_ALLA_PORTA_DELEGATA_DEI_SERVIZI_APPLICATIVI_NON_COMPATIBILI_NELLA_MODALITA_DI_ACCESSO_CON_IL_NUOVO_TIPO_DI_AUTENTICAZIONE,
  2093.                                         portaDelegata.getAutenticazione(), autenticazione));
  2094.                                 return false;
  2095.                             }
  2096.                         }
  2097.                     }
  2098.                 }
  2099.             }

  2100.             return true;
  2101.         } catch (Exception e) {
  2102.             this.logError(e.getMessage(), e);
  2103.             throw new ControlStationCoreException(e.getMessage(),e);
  2104.         }
  2105.     }

  2106.     // Controlla i dati del servizioApplicativo della porta delegata
  2107.     public boolean porteDelegateServizioApplicativoCheckData(TipoOperazione tipoOp)
  2108.             throws Exception {
  2109.         try {
  2110.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  2111.             int idInt = Integer.parseInt(id);
  2112.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  2113.             int soggInt = Integer.parseInt(idsogg);
  2114.             String servizioApplicativo = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_SERVIZIO_APPLICATIVO);

  2115.             // Campi obbligatori
  2116.             if (servizioApplicativo.equals("")) {
  2117.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare un Servizio Applicativo");
  2118.                 return false;
  2119.             }

  2120.             // Controllo che il servizioApplicativo appartenga alla lista di
  2121.             // servizioApplicativo disponibili per il soggetto
  2122.             boolean trovatoServizioApplicativo = false;

  2123.             // Prendo il nome e il tipo del soggetto
  2124.             String nomeprov = null;
  2125.             String tipoprov = null;
  2126.             if(this.core.isRegistroServiziLocale()){
  2127.                 Soggetto mySogg = this.soggettiCore.getSoggettoRegistro(soggInt);
  2128.                 nomeprov = mySogg.getNome();
  2129.                 tipoprov = mySogg.getTipo();
  2130.             }else{
  2131.                 org.openspcoop2.core.config.Soggetto mySogg = this.soggettiCore.getSoggetto(soggInt);
  2132.                 nomeprov = mySogg.getNome();
  2133.                 tipoprov = mySogg.getTipo();
  2134.             }

  2135.             IDSoggetto ids = new IDSoggetto(tipoprov, nomeprov);
  2136.             IDServizioApplicativo idSA = new IDServizioApplicativo();
  2137.             idSA.setIdSoggettoProprietario(ids);
  2138.             idSA.setNome(servizioApplicativo);
  2139.             trovatoServizioApplicativo = this.saCore.existsServizioApplicativo(idSA);
  2140.             if (!trovatoServizioApplicativo) {
  2141.                 this.pd.setMessage("Il Servizio Applicativo dev'essere scelto tra quelli definiti nel pannello Servizi Applicativi ed associati al soggetto " + tipoprov + "/" + nomeprov);
  2142.                 return false;
  2143.             }

  2144.             // Se tipoOp = add, controllo che il servizioApplicativo non sia
  2145.             // gia'
  2146.             // stato
  2147.             // registrato per la porta delegata
  2148.             if (tipoOp.equals(TipoOperazione.ADD)) {
  2149.                 boolean giaRegistrato = false;

  2150.                 // Prendo il nome della porta delegata
  2151.                 PortaDelegata pde = this.porteDelegateCore.getPortaDelegata(idInt);
  2152.                 String nomeporta = pde.getNome();

  2153.                 for (int i = 0; i < pde.sizeServizioApplicativoList(); i++) {
  2154.                     PortaDelegataServizioApplicativo tmpSA = pde.getServizioApplicativo(i);
  2155.                     if (servizioApplicativo.equals(tmpSA.getNome())) {
  2156.                         giaRegistrato = true;
  2157.                         break;
  2158.                     }
  2159.                 }

  2160.                 if (giaRegistrato) {
  2161.                     this.pd.setMessage("Il Servizio Applicativo " + servizioApplicativo + " &egrave; gi&agrave; stato associato alla porta delegata " + nomeporta);
  2162.                     return false;
  2163.                 }
  2164.             }

  2165.             return true;
  2166.         } catch (Exception e) {
  2167.             this.logError(e.getMessage(), e);
  2168.             throw new ControlStationCoreException(e.getMessage(),e);
  2169.         }
  2170.     }

  2171.     // Prepara la lista di porte delegate
  2172.     public void preparePorteDelegateList(ISearch ricerca, List<PortaDelegata> lista,int idLista)
  2173.             throws Exception {
  2174.         try {
  2175.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  2176.            
  2177.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  2178.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  2179.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  2180.            
  2181.             IExtendedListServlet extendedServletList = this.core.getExtendedServletPortaDelegata();
  2182.            
  2183.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  2184.             if(idAsps == null)
  2185.                 idAsps = "";
  2186.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);

  2187.             int limit = ricerca.getPageSize(idLista);
  2188.             int offset = ricerca.getIndexIniziale(idLista);
  2189.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);
  2190.            
  2191.             this.pd.setIndex(offset);
  2192.             this.pd.setPageSize(limit);
  2193.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  2194.             List<Parameter> lstParam = new ArrayList<>();
  2195.             boolean useIdSogg = false;
  2196.            
  2197.             switch (parentPD) {
  2198.             case PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE:
  2199.                 // In teoria non dovrei mai trovarmi qui
  2200.                 break;
  2201.             case PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_SOGGETTO:
  2202.                 ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE,
  2203.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, id));
  2204.                
  2205.                 String soggettoTitle = null;
  2206.                 if(this.core.isRegistroServiziLocale()){
  2207.                     org.openspcoop2.core.registry.Soggetto soggetto = this.soggettiCore.getSoggettoRegistro(Integer.parseInt(id));
  2208.                     String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(soggetto.getTipo());
  2209.                     soggettoTitle = this.getLabelNomeSoggetto(protocollo, soggetto.getTipo() , soggetto.getNome());
  2210.                 }else{
  2211.                     org.openspcoop2.core.config.Soggetto soggetto = this.soggettiCore.getSoggetto(Integer.parseInt(id));
  2212.                     String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(soggetto.getTipo());
  2213.                     soggettoTitle = this.getLabelNomeSoggetto(protocollo, soggetto.getTipo() , soggetto.getNome());
  2214.                 }
  2215.                
  2216.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SOGGETTI, SoggettiCostanti.SERVLET_NAME_SOGGETTI_LIST));

  2217.                 if(search.equals("")){
  2218.                     this.pd.setSearchDescription("");
  2219.                     lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PORTE_DELEGATE_DI + soggettoTitle,null));
  2220.                 }
  2221.                 else{
  2222.                     lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PORTE_DELEGATE_DI + soggettoTitle, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_LIST + "?"
  2223.                             + PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO + "=" + id
  2224.                             ));
  2225.                     lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));

  2226.                 }
  2227.                 useIdSogg = true;
  2228.                 break;
  2229.             case PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE:
  2230.             default:
  2231.                 ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE);
  2232.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PORTE_DELEGATE, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_LIST));
  2233.                 if(search.equals("")){
  2234.                     this.pd.setSearchDescription("");
  2235.                 }
  2236.                 else{
  2237.                     lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));

  2238.                 }
  2239.                 break;
  2240.             }

  2241.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));

  2242.             if(useIdSogg==false){
  2243.                 addFilterProtocol(ricerca, idLista);
  2244.             }
  2245.                        
  2246.             // controllo eventuali risultati ricerca
  2247.             this.pd.setSearchLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  2248.             if (!search.equals("")) {
  2249.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PORTE_DELEGATE, search);
  2250.             }

  2251.             boolean showProtocolli = this.core.countProtocolli(this.request, this.session)>1;
  2252.            
  2253.             // setto le label delle colonne
  2254.             List<String> labelsList= new ArrayList<>();

  2255.             labelsList.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  2256.             if(useIdSogg==false){
  2257.                 labelsList.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SOGGETTO);
  2258.                 if( showProtocolli ) {
  2259.                     labelsList.add(CostantiControlStation.LABEL_PARAMETRO_PROTOCOLLO);
  2260.                 }
  2261.             }

  2262.            
  2263.             labelsList.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI);
  2264.            
  2265.             labelsList.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY);

  2266.             labelsList.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM);

  2267.             labelsList.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA);
  2268.            
  2269.             if((this.isModalitaAvanzata() || this.porteDelegateCore.isProprietaFruizioniShowModalitaStandard()))
  2270.                 labelsList.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PROTOCOL_PROPERTIES);
  2271.            
  2272.             if(extendedServletList!=null && extendedServletList.showExtendedInfo(this, null)){
  2273.                 labelsList.add(extendedServletList.getListTitle(this));
  2274.             }
  2275.            
  2276.             labelsList.add(PorteDelegateCostanti.LABEL_COLUMN_PORTE_DELEGATE_STATO_PORTA);
  2277.            
  2278.             String[] labels = labelsList.toArray(new String[labelsList.size()]);

  2279.             this.pd.setLabels(labels);

  2280.             // preparo i dati
  2281.             List<List<DataElement>> dati = new ArrayList<>();

  2282.             if (lista != null) {
  2283.                 Iterator<PortaDelegata> it = lista.iterator();



  2284.                 while (it.hasNext()) {
  2285.                     PortaDelegata pd = it.next();

  2286.                     Parameter pIdPD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + pd.getId());
  2287.                     Parameter pNomePD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, pd.getNome());
  2288.                     Parameter pIdSoggPD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, pd.getIdSoggetto() + "");
  2289.                    
  2290.                     IDServizio idServizioObject = IDServizioFactory.getInstance().getIDServizioFromValues(pd.getServizio().getTipo(), pd.getServizio().getNome(),
  2291.                             pd.getSoggettoErogatore().getTipo(), pd.getSoggettoErogatore().getNome(),
  2292.                             pd.getServizio().getVersione());
  2293.                     AccordoServizioParteSpecifica asps = this.apsCore.getServizio(idServizioObject);
  2294.                    
  2295.                     Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, asps.getId()+"");
  2296.                     @SuppressWarnings("unused")
  2297.                     Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, asps.getIdSoggetto()+"");
  2298.                    
  2299.                     long idFruzione = -1;
  2300.                     for (Fruitore fruitore : asps.getFruitoreList()) {
  2301.                         if(fruitore.getTipo().equals(pd.getTipoSoggettoProprietario()) &&
  2302.                                 fruitore.getNome().equals(pd.getNomeSoggettoProprietario())) {
  2303.                             idFruzione = fruitore.getId();
  2304.                             break;
  2305.                         }
  2306.                     }
  2307.                     Parameter pIdFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, idFruzione+ "");
  2308.                    
  2309.                     String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(pd.getTipoSoggettoProprietario());
  2310.                    
  2311.                     List<DataElement> e = new ArrayList<>();

  2312.                     DataElement de = new DataElement();
  2313.                     de.setType(DataElementType.HIDDEN);
  2314.                     de.setValue("" + pd.getId());
  2315.                     e.add(de);

  2316.                     de = new DataElement();
  2317.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,
  2318.                             pIdSoggPD,
  2319.                             pNomePD,
  2320.                             pIdPD
  2321.                             );
  2322.                     de.setValue(pd.getNome());
  2323.                     de.setIdToRemove(pd.getId().toString());
  2324.                     de.setToolTip(pd.getDescrizione());
  2325.                     e.add(de);

  2326.                     if(useIdSogg==false){
  2327.                         de = new DataElement();
  2328.                         de.setValue(this.getLabelNomeSoggetto(protocollo, pd.getTipoSoggettoProprietario() , pd.getNomeSoggettoProprietario()));
  2329.                         e.add(de);
  2330.                                            
  2331.                         if( showProtocolli ) {
  2332.                             de = new DataElement();
  2333.                             de.setValue(this.getLabelProtocollo(protocollo));
  2334.                             e.add(de);
  2335.                         }
  2336.                     }
  2337.                    
  2338.                     // Controllo Accessi
  2339.                     de = new DataElement();
  2340.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONTROLLO_ACCESSI, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore);
  2341.                     String statoControlloAccessi = this.getStatoControlloAccessiPortaDelegata(protocollo, pd);
  2342.                     de.setValue(statoControlloAccessi);
  2343.                     e.add(de);
  2344.                    

  2345.                     de = new DataElement();
  2346.                     de.setUrl(
  2347.                             PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY,
  2348.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  2349.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId()),
  2350.                             pIdAsps, pIdFruitore
  2351.                             );
  2352.                     de.setValue(pd.getStatoMessageSecurity());
  2353.                     e.add(de);

  2354.                     //if(InterfaceType.AVANZATA.equals(ServletUtils.getUserFromSession(this.session).getInterfaceType())){
  2355.                     de = new DataElement();
  2356.                     de.setUrl(
  2357.                             PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM,
  2358.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  2359.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId()),
  2360.                             pIdAsps, pIdFruitore
  2361.                             );

  2362.                     boolean isMTOMAbilitatoReq = false;
  2363.                     boolean isMTOMAbilitatoRes= false;
  2364.                     if(pd.getMtomProcessor()!= null){
  2365.                         if(pd.getMtomProcessor().getRequestFlow() != null){
  2366.                             if(pd.getMtomProcessor().getRequestFlow().getMode() != null){
  2367.                                 MTOMProcessorType mode = pd.getMtomProcessor().getRequestFlow().getMode();
  2368.                                 if(!mode.equals(MTOMProcessorType.DISABLE))
  2369.                                     isMTOMAbilitatoReq = true;
  2370.                             }
  2371.                         }

  2372.                         if(pd.getMtomProcessor().getResponseFlow() != null){
  2373.                             if(pd.getMtomProcessor().getResponseFlow().getMode() != null){
  2374.                                 MTOMProcessorType mode = pd.getMtomProcessor().getResponseFlow().getMode();
  2375.                                 if(!mode.equals(MTOMProcessorType.DISABLE))
  2376.                                     isMTOMAbilitatoRes = true;
  2377.                             }
  2378.                         }
  2379.                     }

  2380.                     if(isMTOMAbilitatoReq || isMTOMAbilitatoRes)
  2381.                         de.setValue(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_ABILITATO);
  2382.                     else
  2383.                         de.setValue(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_DISABILITATO);
  2384.                     e.add(de);
  2385.                     //}

  2386.                     de = new DataElement();
  2387.                     de.setUrl(
  2388.                             PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA,
  2389.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  2390.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId()),
  2391.                             pIdAsps, pIdFruitore );
  2392.                    
  2393.                     boolean isCorrelazioneApplicativaAbilitataReq = false;
  2394.                     boolean isCorrelazioneApplicativaAbilitataRes = false;
  2395.                    
  2396.                     if (pd.getCorrelazioneApplicativa() != null)
  2397.                         isCorrelazioneApplicativaAbilitataReq = pd.getCorrelazioneApplicativa().sizeElementoList() > 0;

  2398.                     if (pd.getCorrelazioneApplicativaRisposta() != null)
  2399.                         isCorrelazioneApplicativaAbilitataRes = pd.getCorrelazioneApplicativaRisposta().sizeElementoList() > 0;
  2400.                        
  2401.                     if(isCorrelazioneApplicativaAbilitataReq || isCorrelazioneApplicativaAbilitataRes)
  2402.                         de.setValue(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_ABILITATA);
  2403.                     else
  2404.                         de.setValue(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_DISABILITATA);
  2405.                     e.add(de);
  2406.                    
  2407.                     // Protocol Properties
  2408.                     if((this.isModalitaAvanzata() || this.porteDelegateCore.isProprietaFruizioniShowModalitaStandard())){
  2409.                         de = new DataElement();
  2410.                         //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  2411.                         de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_PROPRIETA_PROTOCOLLO_LIST, pIdSoggPD, pIdPD,
  2412.                                 pIdAsps, pIdFruitore);
  2413.                         if (contaListe) {
  2414.                             int numProp = pd.sizeProprietaList();
  2415.                             ServletUtils.setDataElementVisualizzaLabel(de, (long) numProp );
  2416.                         } else
  2417.                             ServletUtils.setDataElementVisualizzaLabel(de);
  2418.                         e.add(de);
  2419.                     }

  2420.                     if(extendedServletList!=null && extendedServletList.showExtendedInfo(this, null)){
  2421.                         de = new DataElement();
  2422.                         de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_EXTENDED_LIST,
  2423.                                 new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  2424.                                 new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId()),
  2425.                                 new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME,pd.getNome(),
  2426.                                 pIdAsps, pIdFruitore)
  2427.                                 );
  2428.                         if (contaListe) {
  2429.                             int numExtended = extendedServletList.sizeList(pd);
  2430.                             ServletUtils.setDataElementVisualizzaLabel(de,Long.valueOf(numExtended));
  2431.                         } else
  2432.                             ServletUtils.setDataElementVisualizzaLabel(de);
  2433.                         e.add(de);
  2434.                     }
  2435.                    
  2436.                     de = new DataElement();
  2437.                     boolean abilitatoPorta = pd.getStato()!=null ? CostantiConfigurazione.ABILITATO.equals(pd.getStato()) : true;
  2438.                     de.setType(DataElementType.CHECKBOX);
  2439.                     de.setSelected(abilitatoPorta);
  2440.                     de.setToolTip(abilitatoPorta?CostantiConfigurazione.ABILITATO.getValue():CostantiConfigurazione.DISABILITATO.getValue());
  2441.                     de.setValue(abilitatoPorta+"");
  2442.                     e.add(de);
  2443.                    
  2444.                     dati.add(e);
  2445.                 }
  2446.             }

  2447.             this.pd.setDati(dati);
  2448.             // le porte delegate non si possono piu' creare dalle liste PD e PD di un soggetto
  2449.             if(!this.isModalitaCompleta() || !useIdSogg) {
  2450.                 this.pd.setAddButton(false);
  2451.             }
  2452.            
  2453.             if (useIdSogg){
  2454.                 if(!this.isModalitaAvanzata()){
  2455.                     this.pd.setRemoveButton(false);
  2456.                     this.pd.setSelect(false);
  2457.                 }
  2458.             }
  2459.         } catch (Exception e) {
  2460.             this.logError(e.getMessage(), e);
  2461.             throw new ControlStationCoreException(e.getMessage(),e);
  2462.         }
  2463.     }


  2464.     // Prepara la lista di sil delle porte delegate
  2465.     public void preparePorteDelegateServizioApplicativoList(String nomePorta, ISearch ricerca, List<ServizioApplicativo> lista)
  2466.             throws Exception {
  2467.         try {
  2468.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  2469.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  2470.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  2471.            
  2472.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  2473.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  2474.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  2475.             if(idAsps == null)
  2476.                 idAsps = "";
  2477.            
  2478.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  2479.             if(idFruizione == null)
  2480.                 idFruizione = "";
  2481.            
  2482.             String token = this.getParameter(CostantiControlStation.PARAMETRO_TOKEN_AUTHORIZATION);
  2483.            
  2484.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  2485.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  2486.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  2487.             Parameter pIdFrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  2488.             List<Parameter> listP = new ArrayList<>();
  2489.             listP.add(pId);
  2490.             listP.add(pIdSoggetto);
  2491.             listP.add(pIdAsps);
  2492.             listP.add(pIdFrizione);
  2493.             if(token!=null) {
  2494.                 listP.add(new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_TOKEN_AUTHORIZATION, token));
  2495.             }
  2496.             ServletUtils.addListElementIntoSession(this.request, this.session,  PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_SERVIZIO_APPLICATIVO,
  2497.                     listP);
  2498.            
  2499.             boolean isToken = token!=null && !"".equals(token) && Boolean.valueOf(token);
  2500.            
  2501.             int idLista = Liste.PORTE_DELEGATE_SERVIZIO_APPLICATIVO;
  2502.             if(isToken) {
  2503.                 idLista = Liste.PORTE_DELEGATE_TOKEN_SERVIZIO_APPLICATIVO;
  2504.             }
  2505.             int limit = ricerca.getPageSize(idLista);
  2506.             int offset = ricerca.getIndexIniziale(idLista);
  2507.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  2508.             this.pd.setIndex(offset);
  2509.             this.pd.setPageSize(limit);
  2510.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  2511.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  2512.             String idporta = myPD.getNome();

  2513.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  2514.            
  2515.             String labelPerPorta = null;
  2516.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  2517.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  2518.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI,
  2519.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  2520.                         myPD);
  2521.             }
  2522.             else {
  2523.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI+idporta;
  2524.             }
  2525.            
  2526.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  2527.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + myPD.getId()),
  2528.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome()),
  2529.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, myPD.getIdSoggetto() + ""),
  2530.                     pIdAsps, new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione+ "")));
  2531.            
  2532.             String labelApp = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZIO_APPLICATIVO_CONFIG;
  2533.             if(!this.isModalitaCompleta() || isToken) {
  2534.                 labelApp = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVO_CONFIG;
  2535.             }
  2536.             String labelPagLista =
  2537.                     (
  2538.                             isToken ?
  2539.                             CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN
  2540.                             :
  2541.                             CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TRASPORTO
  2542.                     )
  2543.                     + " - " +
  2544.                     labelApp;
  2545.            
  2546.             this.pd.setSearchLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  2547.             if(search.equals("")){
  2548.                 this.pd.setSearchDescription("");
  2549.                 lstParam.add(new Parameter(labelPagLista,null));
  2550.             }
  2551.             else{
  2552.                 lstParam.add(new Parameter(labelPagLista,
  2553.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_SERVIZIO_APPLICATIVO_LIST, pId, pIdSoggetto, pIdAsps, pIdFrizione,
  2554.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_TOKEN_AUTHORIZATION, isToken+"")   ));
  2555.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));
  2556.             }

  2557.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  2558.            
  2559.             // imposto menu' contestuale
  2560.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  2561.             // controllo eventuali risultati ricerca
  2562.             if (!search.equals("")) {
  2563.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZI_APPLICATIVI, search);
  2564.             }

  2565.             // setto le label delle colonne
  2566.             String[] labels = new String[1];
  2567.             if(this.isModalitaCompleta()) {
  2568.                 labels[0] = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZIO_APPLICATIVO;
  2569.             }
  2570.             else {
  2571.                 labels[0] = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVO;
  2572.             }
  2573.             this.pd.setLabels(labels);

  2574.             // preparo i dati
  2575.             List<List<DataElement>> dati = new ArrayList<>();

  2576.             if (lista != null) {
  2577.                 Iterator<ServizioApplicativo> it = lista.iterator();
  2578.                 while (it.hasNext()) {
  2579.                     ServizioApplicativo sa = it.next();

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

  2581.                     DataElement de = new DataElement();
  2582.                     String url = new Parameter("", ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_CHANGE,
  2583.                             new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID, sa.getId()+""),
  2584.                             new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER, idsogg)).getValue();
  2585.                    
  2586.                     if(this.isModalitaCompleta()) {
  2587.                         de.setUrl(url);
  2588.                     } else {
  2589.                         String tooltip = sa.getNome();
  2590.                         this.newDataElementVisualizzaInNuovoTab(de, url, tooltip);
  2591.                     }
  2592.                     de.setValue(sa.getNome());
  2593.                     de.setIdToRemove(sa.getNome());
  2594.                     e.add(de);

  2595.                     dati.add(e);
  2596.                 }
  2597.             }

  2598.             this.pd.setDati(dati);
  2599.             this.pd.setAddButton(true);

  2600.         } catch (Exception e) {
  2601.             this.logError(e.getMessage(), e);
  2602.             throw new ControlStationCoreException(e.getMessage(),e);
  2603.         }
  2604.     }
  2605.    
  2606.    
  2607.    
  2608.     public void preparePorteDelegateRuoliList(String nomePorta, ISearch ricerca, List<String> lista)
  2609.             throws Exception {
  2610.         try {
  2611.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  2612.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  2613.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  2614.            
  2615.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  2616.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  2617.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  2618.             if(idAsps == null)
  2619.                 idAsps = "";
  2620.            
  2621.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  2622.             if(idFruizione == null)
  2623.                 idFruizione = "";
  2624.            
  2625.             String token = this.getParameter(CostantiControlStation.PARAMETRO_TOKEN_AUTHORIZATION);
  2626.            
  2627.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  2628.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  2629.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  2630.             Parameter pIdFrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);
  2631.            
  2632.             List<Parameter> listP = new ArrayList<>();
  2633.             listP.add(pId);
  2634.             listP.add(pIdSoggetto);
  2635.             listP.add(pIdAsps);
  2636.             listP.add(pIdFrizione);
  2637.             if(token!=null) {
  2638.                 listP.add(new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_TOKEN_AUTHORIZATION, token));
  2639.             }
  2640.             ServletUtils.addListElementIntoSession(this.request, this.session,  PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_RUOLI,
  2641.                     listP);

  2642.             boolean isToken = token!=null && !"".equals(token) && Boolean.valueOf(token);
  2643.            
  2644.             int idLista = Liste.PORTE_DELEGATE_RUOLI;
  2645.             if(isToken) {
  2646.                 idLista = Liste.PORTE_DELEGATE_TOKEN_RUOLI;
  2647.             }
  2648.             int limit = ricerca.getPageSize(idLista);
  2649.             int offset = ricerca.getIndexIniziale(idLista);
  2650.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  2651.             this.pd.setIndex(offset);
  2652.             this.pd.setPageSize(limit);
  2653.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  2654.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  2655.             String idporta = myPD.getNome();

  2656.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  2657.            
  2658.             String labelPerPorta = null;
  2659.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  2660.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  2661.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI,
  2662.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  2663.                         myPD);
  2664.             }
  2665.             else {
  2666.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI+idporta;
  2667.             }
  2668.            
  2669.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  2670.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + myPD.getId()),
  2671.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome()),
  2672.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, myPD.getIdSoggetto() + ""),
  2673.                     pIdAsps, new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione+ "")));
  2674.            
  2675.             String labelPagLista =
  2676.                     (
  2677.                             isToken ?
  2678.                             CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN
  2679.                             :
  2680.                             CostantiControlStation.LABEL_PARAMETRO_PORTE_AUTORIZZAZIONE_TRASPORTO
  2681.                     )
  2682.                     + " - " +
  2683.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RUOLI_CONFIG;

  2684.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);

  2685.             this.pd.setSearchLabel(CostantiControlStation.LABEL_PARAMETRO_RUOLO);
  2686.             if(search.equals("")){
  2687.                 this.pd.setSearchDescription("");
  2688.                 lstParam.add(new Parameter(labelPagLista,null));
  2689.             }
  2690.             else{
  2691.                 lstParam.add(new Parameter(labelPagLista,
  2692.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_RUOLI_LIST, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione,
  2693.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_TOKEN_AUTHORIZATION, isToken+"")   ));
  2694.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));

  2695.             }

  2696.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  2697.            
  2698.             // imposto menu' contestuale
  2699.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  2700.             // controllo eventuali risultati ricerca
  2701.             if (!search.equals("")) {
  2702.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RUOLI, search);
  2703.             }

  2704.             // setto le label delle colonne
  2705.             String[] labels = {CostantiControlStation.LABEL_PARAMETRO_RUOLO };
  2706.             this.pd.setLabels(labels);

  2707.             // preparo i dati
  2708.             List<List<DataElement>> dati = new ArrayList<>();

  2709.             if (lista != null) {
  2710.                 Iterator<String> it = lista.iterator();
  2711.                 while (it.hasNext()) {
  2712.                     String ruolo = it.next();
  2713.        
  2714.                     List<DataElement> e = new ArrayList<>();
  2715.        
  2716.                     DataElement de = new DataElement();
  2717.                     de.setValue(ruolo);
  2718.                     de.setIdToRemove(ruolo);
  2719.                    
  2720.                     if(!this.isModalitaCompleta()) {
  2721.                         Ruolo ruoloObj = this.ruoliCore.getRuolo(ruolo);
  2722.                         Parameter pIdRuolo = new Parameter(RuoliCostanti.PARAMETRO_RUOLO_ID, ruoloObj.getId()+"");
  2723.                        
  2724.                         String url = new Parameter("", RuoliCostanti.SERVLET_NAME_RUOLI_CHANGE , pIdRuolo).getValue();
  2725.                         String tooltip = ruolo;
  2726.                        
  2727.                         this.newDataElementVisualizzaInNuovoTab(de, url, tooltip);
  2728.                     }
  2729.                    
  2730.                     e.add(de);
  2731.        
  2732.                     dati.add(e);
  2733.                 }
  2734.             }

  2735.             this.pd.setDati(dati);
  2736.             this.pd.setAddButton(true);

  2737.         } catch (Exception e) {
  2738.             this.logError(e.getMessage(), e);
  2739.             throw new ControlStationCoreException(e.getMessage(),e);
  2740.         }
  2741.     }
  2742.    
  2743.     public void preparePorteDelegateScopeList(String nomePorta, ISearch ricerca, List<String> lista)
  2744.             throws Exception {
  2745.         try {
  2746.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  2747.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  2748.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  2749.            
  2750.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  2751.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  2752.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  2753.             if(idAsps == null)
  2754.                 idAsps = "";
  2755.            
  2756.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  2757.             if(idFruizione == null)
  2758.                 idFruizione = "";
  2759.            
  2760.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  2761.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  2762.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  2763.             Parameter pIdFrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  2764.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_SCOPE, pId, pIdSoggetto, pIdAsps, pIdFrizione);

  2765.             int idLista = Liste.PORTE_DELEGATE_SCOPE;
  2766.             int limit = ricerca.getPageSize(idLista);
  2767.             int offset = ricerca.getIndexIniziale(idLista);
  2768.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  2769.             this.pd.setIndex(offset);
  2770.             this.pd.setPageSize(limit);
  2771.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  2772.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  2773.             String idporta = myPD.getNome();

  2774.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  2775.            
  2776.             String labelPerPorta = null;
  2777.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  2778.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  2779.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI,
  2780.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  2781.                         myPD);
  2782.             }
  2783.             else {
  2784.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI+idporta;
  2785.             }
  2786.            
  2787.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  2788.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + myPD.getId()),
  2789.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome()),
  2790.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, myPD.getIdSoggetto() + ""),
  2791.                     pIdAsps, new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione+ "")));
  2792.            
  2793.             String labelPagLista = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SCOPE_CONFIG;

  2794.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);

  2795.             this.pd.setSearchLabel(CostantiControlStation.LABEL_PARAMETRO_SCOPE);
  2796.             if(search.equals("")){
  2797.                 this.pd.setSearchDescription("");
  2798.                 lstParam.add(new Parameter(labelPagLista,null));
  2799.             }
  2800.             else{
  2801.                 lstParam.add(new Parameter(labelPagLista,
  2802.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_SCOPE_LIST, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione    ));
  2803.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));

  2804.             }

  2805.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  2806.            
  2807.             // imposto menu' contestuale
  2808.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  2809.             // controllo eventuali risultati ricerca
  2810.             if (!search.equals("")) {
  2811.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SCOPE, search);
  2812.             }

  2813.             // setto le label delle colonne
  2814.             String[] labels = {CostantiControlStation.LABEL_PARAMETRO_SCOPE };
  2815.             this.pd.setLabels(labels);

  2816.             // preparo i dati
  2817.             List<List<DataElement>> dati = new ArrayList<>();

  2818.             if (lista != null) {
  2819.                 Iterator<String> it = lista.iterator();
  2820.                 while (it.hasNext()) {
  2821.                     String scope = it.next();
  2822.        
  2823.                     List<DataElement> e = new ArrayList<>();
  2824.        
  2825.                     DataElement de = new DataElement();
  2826.                     de.setValue(scope);
  2827.                     de.setIdToRemove(scope);
  2828.                    
  2829.                     if(!this.isModalitaCompleta()) {
  2830.                         Scope scopeObj = this.scopeCore.getScope(scope);
  2831.                         Parameter pIdScope = new Parameter(ScopeCostanti.PARAMETRO_SCOPE_ID, scopeObj.getId()+"");
  2832.                        
  2833.                         String url = new Parameter("", ScopeCostanti.SERVLET_NAME_SCOPE_CHANGE , pIdScope).getValue();
  2834.                         String tooltip = scope;
  2835.                        
  2836.                         this.newDataElementVisualizzaInNuovoTab(de, url, tooltip);
  2837.                     }
  2838.                    
  2839.                     e.add(de);
  2840.        
  2841.                     dati.add(e);
  2842.                 }
  2843.             }

  2844.             this.pd.setDati(dati);
  2845.             this.pd.setAddButton(true);

  2846.         } catch (Exception e) {
  2847.             this.logError(e.getMessage(), e);
  2848.             throw new ControlStationCoreException(e.getMessage(),e);
  2849.         }
  2850.     }


  2851.     // Prepara la lista di Message-Security response-flow delle porte delegate
  2852.     public void preparePorteDelegateMessageSecurityResponseList(String nomePorta, ISearch ricerca, List<MessageSecurityFlowParameter> lista)
  2853.             throws Exception {
  2854.         try {
  2855.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  2856.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  2857.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  2858.             if(idAsps == null)
  2859.                 idAsps = "";
  2860.            
  2861.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  2862.             if(idFruizione == null)
  2863.                 idFruizione = "";
  2864.            
  2865.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  2866.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  2867.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  2868.             Parameter pIdFrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  2869.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  2870.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  2871.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;

  2872.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_MESSAGE_SECURITY_RESPONSE, pId, pIdSoggetto, pIdAsps, pIdFrizione);

  2873.             int idLista = Liste.PORTE_DELEGATE_MESSAGE_SECURITY_RESPONSE;
  2874.             int limit = ricerca.getPageSize(idLista);
  2875.             int offset = ricerca.getIndexIniziale(idLista);
  2876.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  2877.             this.pd.setIndex(offset);
  2878.             this.pd.setPageSize(limit);
  2879.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  2880.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  2881.             String idporta = myPD.getNome();

  2882.             // setto la barra del titolo
  2883.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  2884.            
  2885.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);
  2886.            
  2887.             String labelPerPorta = null;
  2888.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  2889.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  2890.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY_CONFIG_DI,
  2891.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY,
  2892.                         myPD);
  2893.             }
  2894.             else {
  2895.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY_CONFIG_DI+idporta;
  2896.             }
  2897.             lstParam.add(new Parameter(labelPerPorta,
  2898.                     PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY, pId, pIdSoggetto, pIdAsps, pIdFrizione  ));

  2899.             this.pd.setSearchLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  2900.             if(search.equals("")){
  2901.                 this.pd.setSearchDescription("");
  2902.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY_RESPONSE_FLOW_DI, // + idporta,
  2903.                         null));
  2904.             }
  2905.             else{
  2906.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY_RESPONSE_FLOW_DI, // + idporta,
  2907.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY_RESPONSE_LIST, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione    ));
  2908.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));

  2909.             }

  2910.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  2911.            
  2912.             // imposto menu' contestuale
  2913.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  2914.             // controllo eventuali risultati ricerca
  2915.             if (!search.equals("")) {
  2916.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY_RESPONSE_FLOW_DI, search);
  2917.             }

  2918.             // setto le label delle colonne
  2919.             String[] labels = {
  2920.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME,
  2921.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE
  2922.             };
  2923.             this.pd.setLabels(labels);

  2924.             // preparo i dati
  2925.             List<List<DataElement>> dati = new ArrayList<>();

  2926.             if (lista != null) {
  2927.                 Iterator<MessageSecurityFlowParameter> it = lista.iterator();
  2928.                 while (it.hasNext()) {
  2929.                     MessageSecurityFlowParameter wsrfp = it.next();

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

  2931.                     DataElement de = new DataElement();
  2932.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY_RESPONSE_CHANGE,
  2933.                             pId, pIdSoggetto, pIdAsps, pIdFrizione,
  2934.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, wsrfp.getNome())
  2935.                             );
  2936.                     de.setValue(wsrfp.getNome());
  2937.                     de.setIdToRemove(wsrfp.getNome());
  2938.                     e.add(de);

  2939.                     de = new DataElement();
  2940.                     if(wsrfp.getValore()!=null && StringUtils.isNotEmpty(wsrfp.getValore()) &&
  2941.                             BYOKManager.isEnabledBYOK() &&
  2942.                             this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(wsrfp.getValore())) {
  2943.                         de.setValue(CostantiControlStation.VALORE_CIFRATO);
  2944.                     }
  2945.                     else {
  2946.                         de.setValue(wsrfp.getValore());
  2947.                     }
  2948.                     e.add(de);

  2949.                     dati.add(e);
  2950.                 }
  2951.             }

  2952.             this.pd.setDati(dati);
  2953.             this.pd.setAddButton(true);

  2954.         } catch (Exception e) {
  2955.             this.logError(e.getMessage(), e);
  2956.             throw new ControlStationCoreException(e.getMessage(),e);
  2957.         }
  2958.     }


  2959.     // Prepara la lista di correlazioni applicative delle porte delegate
  2960.     public void preparePorteDelegateCorrAppList(String nomePorta, ISearch ricerca, List<CorrelazioneApplicativaElemento> lista)
  2961.             throws Exception {
  2962.         try {
  2963.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  2964.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  2965.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  2966.             if(idAsps == null)
  2967.                 idAsps = "";
  2968.            
  2969.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  2970.             if(idFruizione == null)
  2971.                 idFruizione = "";

  2972.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  2973.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  2974.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;

  2975.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  2976.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  2977.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  2978.             Parameter pIdFrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);
  2979.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_REQUEST, pId, pIdSoggetto, pIdAsps, pIdFrizione);

  2980.             int idLista = Liste.PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA;
  2981.             int limit = ricerca.getPageSize(idLista);
  2982.             int offset = ricerca.getIndexIniziale(idLista);
  2983.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  2984.             this.pd.setIndex(offset);
  2985.             this.pd.setPageSize(limit);
  2986.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  2987.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  2988.             String idporta = myPD.getNome();

  2989.             // setto la barra del titolo
  2990.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  2991.            
  2992.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);
  2993.             String labelPerPorta = null;
  2994.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  2995.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  2996.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONI_APPLICATIVE_CONFIG_DI,
  2997.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRACCIAMENTO,
  2998.                         myPD);
  2999.             }
  3000.             else {
  3001.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONI_APPLICATIVE_CONFIG_DI+idporta;
  3002.             }
  3003.             lstParam.add(new Parameter(labelPerPorta,
  3004.                     PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA, pIdSoggetto, pId, pNomePorta, pIdAsps, pIdFrizione));

  3005.             this.pd.setSearchLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML);
  3006.             if(search.equals("")){
  3007.                 this.pd.setSearchDescription("");
  3008.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONI_APPLICATIVE_RICHIESTA_DI, // + idporta,
  3009.                         null));
  3010.             }
  3011.             else{
  3012.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONI_APPLICATIVE_RICHIESTA_DI, // + idporta,
  3013.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_REQUEST_LIST, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione ));
  3014.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));
  3015.             }

  3016.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  3017.            
  3018.             // imposto menu' contestuale
  3019.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  3020.             // controllo eventuali risultati ricerca
  3021.             if (!search.equals("")) {
  3022.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONI_APPLICATIVE_RICHIESTA_DI, search);
  3023.             }

  3024.             // setto le label delle colonne
  3025.             String[] labels = {
  3026.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML,
  3027.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODALITA_IDENTIFICAZIONE};
  3028.             this.pd.setLabels(labels);

  3029.             // preparo i dati
  3030.             List<List<DataElement>> dati = new ArrayList<>();

  3031.             if (lista != null) {
  3032.                 Iterator<CorrelazioneApplicativaElemento> it = lista.iterator();
  3033.                 while (it.hasNext()) {
  3034.                     CorrelazioneApplicativaElemento cae = it.next();

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

  3036.                     DataElement de = new DataElement();
  3037.                     de.setType(DataElementType.HIDDEN);
  3038.                     de.setValue("" + cae.getId());
  3039.                     e.add(de);

  3040.                     de = new DataElement();
  3041.                     de.setUrl(
  3042.                             PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_REQUEST_CHANGE,
  3043.                             pId,
  3044.                             pIdSoggetto,    
  3045.                             pIdAsps,
  3046.                             pIdFrizione,
  3047.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_CORRELAZIONE, ""+ cae.getId())
  3048.                             );
  3049.                     //String nomeElemento = "(*)";
  3050.                     String nomeElemento = CostantiControlStation.LABEL_PORTE_CORRELAZIONE_APPLICATIVA_QUALSIASI;
  3051.                     if (cae.getNome() != null && !"".equals(cae.getNome()))
  3052.                         nomeElemento = cae.getNome();
  3053.                     de.setValue(nomeElemento);
  3054.                     de.setIdToRemove("" + cae.getId());
  3055.                     e.add(de);

  3056.                     de = new DataElement();
  3057.                     if(cae.getIdentificazione()!=null) {
  3058.                         //de.setValue(cae.getIdentificazione().toString());
  3059.                         switch (cae.getIdentificazione()) {
  3060.                         case DISABILITATO:
  3061.                             de.setValue(CostantiControlStation.LABEL_PARAMETRO_MODE_CORRELAZIONE_DISABILITATO);
  3062.                             break;
  3063.                         case HEADER_BASED:
  3064.                             de.setValue(ModalitaIdentificazione.HEADER_BASED.getLabel());
  3065.                             break;
  3066.                         case URL_BASED:
  3067.                             de.setValue(ModalitaIdentificazione.URL_BASED.getLabel());
  3068.                             break;
  3069.                         case CONTENT_BASED:
  3070.                             de.setValue(ModalitaIdentificazione.CONTENT_BASED.getLabel());
  3071.                             break;
  3072.                         case INPUT_BASED:
  3073.                             de.setValue(ModalitaIdentificazione.INPUT_BASED.getLabel());
  3074.                             break;
  3075.                         case TEMPLATE:
  3076.                             de.setValue(ModalitaIdentificazione.GOVWAY_TEMPLATE.getLabel());
  3077.                             break;
  3078.                         case FREEMARKER_TEMPLATE:
  3079.                             de.setValue(ModalitaIdentificazione.FREEMARKER_TEMPLATE.getLabel());
  3080.                             break;
  3081.                         case VELOCITY_TEMPLATE:
  3082.                             de.setValue(ModalitaIdentificazione.VELOCITY_TEMPLATE.getLabel());
  3083.                             break;
  3084.                         }
  3085.                     }
  3086.                     e.add(de);

  3087.                     dati.add(e);
  3088.                 }
  3089.             }

  3090.             this.pd.setDati(dati);
  3091.             this.pd.setAddButton(true);
  3092.         } catch (Exception e) {
  3093.             this.logError(e.getMessage(), e);
  3094.             throw new ControlStationCoreException(e.getMessage(),e);
  3095.         }
  3096.     }

  3097.     // Controlla i dati del message-security request-flow della porta delegata
  3098.     public boolean porteDelegateMessageSecurityRequestCheckData(TipoOperazione tipoOp) throws ControlStationCoreException {
  3099.         try {
  3100.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  3101.             int idInt = Integer.parseInt(id);
  3102.             String nome = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME);
  3103.             String valore = this.getLockedParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_VALORE, false);

  3104.             // Campi obbligatori
  3105.             if (nome.equals("") || valore.equals("")) {
  3106.                 String tmpElenco = "";
  3107.                 if (nome.equals("")) {
  3108.                     tmpElenco = "Nome";
  3109.                 }
  3110.                 if (valore.equals("")) {
  3111.                     if (tmpElenco.equals("")) {
  3112.                         tmpElenco = "Valore";
  3113.                     } else {
  3114.                         tmpElenco = tmpElenco + ", Valore";
  3115.                     }
  3116.                 }
  3117.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare: " + tmpElenco);
  3118.                 return false;
  3119.             }

  3120.             // Controllo che non ci siano spazi nei campi di testo
  3121.             if ((nome.indexOf(" ") != -1) ) {
  3122.                 this.pd.setMessage("Non inserire spazi nei nomi");
  3123.                 return false;
  3124.             }
  3125.             if(
  3126.                 (!this.core.getDriverBYOKUtilities().isEnabledBYOK() || !this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(valore))
  3127.                 &&
  3128.                 (valore.startsWith(" ") || valore.endsWith(" "))
  3129.             ){
  3130.                 this.pd.setMessage("Non inserire spazi all'inizio o alla fine dei valori");
  3131.                 return false;
  3132.             }
  3133.             if(!this.checkLength255(nome, PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME)) {
  3134.                 return false;
  3135.             }

  3136.             // Se tipoOp = add, controllo che il message-security non sia gia' stato
  3137.             // registrato per la porta delegata
  3138.             if (tipoOp.equals(TipoOperazione.ADD)) {
  3139.                 boolean giaRegistrato = false;
  3140.                 PortaDelegata pde = this.porteDelegateCore.getPortaDelegata(idInt);
  3141.                 String nomeporta = pde.getNome();
  3142.                 MessageSecurity messageSecurity = pde.getMessageSecurity();

  3143.                 if(messageSecurity!=null &&
  3144.                     messageSecurity.getRequestFlow()!=null){
  3145.                     for (int i = 0; i < messageSecurity.getRequestFlow().sizeParameterList(); i++) {
  3146.                         MessageSecurityFlowParameter tmpMessageSecurity =messageSecurity.getRequestFlow().getParameter(i);
  3147.                         if (nome.equals(tmpMessageSecurity.getNome())) {
  3148.                             giaRegistrato = true;
  3149.                             break;
  3150.                         }
  3151.                     }
  3152.                 }

  3153.                 if (giaRegistrato) {
  3154.                     this.pd.setMessage("La proprieta' di message-security " + nome + " &egrave; gi&agrave; stato associata alla porta delegata " + nomeporta);
  3155.                     return false;
  3156.                 }
  3157.             }

  3158.             return true;

  3159.         } catch (Exception e) {
  3160.             this.logError(e.getMessage(), e);
  3161.             throw new ControlStationCoreException(e.getMessage(),e);
  3162.         }
  3163.     }

  3164.     // Prepara la lista di Message-Security request-flow delle porte delegate
  3165.     public void preparePorteDelegateMessageSecurityRequestList(String nomePorta, ISearch ricerca, List<MessageSecurityFlowParameter> lista)
  3166.             throws Exception {
  3167.         try {

  3168.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  3169.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  3170.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;

  3171.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  3172.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  3173.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  3174.             if(idAsps == null)
  3175.                 idAsps = "";
  3176.            
  3177.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  3178.             if(idFruizione == null)
  3179.                 idFruizione = "";
  3180.            
  3181.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  3182.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  3183.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  3184.             Parameter pIdFrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  3185.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_MESSAGE_SECURITY_REQUEST, pId, pIdSoggetto, pIdAsps, pIdFrizione);

  3186.             int idLista = Liste.PORTE_DELEGATE_MESSAGE_SECURITY_REQUEST;
  3187.             int limit = ricerca.getPageSize(idLista);
  3188.             int offset = ricerca.getIndexIniziale(idLista);
  3189.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  3190.             this.pd.setIndex(offset);
  3191.             this.pd.setPageSize(limit);
  3192.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  3193.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  3194.             String idporta = myPD.getNome();

  3195.             // setto la barra del titolo
  3196.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  3197.            
  3198.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);

  3199.             String labelPerPorta = null;
  3200.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  3201.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  3202.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY_CONFIG_DI,
  3203.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY,
  3204.                         myPD);
  3205.             }
  3206.             else {
  3207.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY_CONFIG_DI+idporta;
  3208.             }
  3209.             lstParam.add(new Parameter(labelPerPorta,
  3210.                     PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione  ));

  3211.             this.pd.setSearchLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  3212.             if(search.equals("")){
  3213.                 this.pd.setSearchDescription("");
  3214.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY_REQUEST_FLOW_DI, // + idporta,
  3215.                         null));
  3216.             }
  3217.             else{
  3218.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY_REQUEST_FLOW_DI, // + idporta,
  3219.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY_REQUEST_LIST, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione ));
  3220.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));
  3221.             }


  3222.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  3223.            
  3224.             // imposto menu' contestuale
  3225.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  3226.             // controllo eventuali risultati ricerca
  3227.             if (!search.equals("")) {
  3228.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY_REQUEST_FLOW_DI, search);
  3229.             }

  3230.             // setto le label delle colonne
  3231.             String[] labels = {
  3232.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME,
  3233.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE    
  3234.             };
  3235.             this.pd.setLabels(labels);

  3236.             // preparo i dati
  3237.             List<List<DataElement>> dati = new ArrayList<>();

  3238.             if (lista != null) {
  3239.                 Iterator<MessageSecurityFlowParameter> it = lista.iterator();
  3240.                 while (it.hasNext()) {
  3241.                     MessageSecurityFlowParameter wsrfp = it.next();

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

  3243.                     DataElement de = new DataElement();
  3244.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY_REQUEST_CHANGE ,pId, pIdSoggetto, pIdAsps, pIdFrizione,
  3245.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, wsrfp.getNome())
  3246.                             );
  3247.                     de.setValue(wsrfp.getNome());
  3248.                     de.setIdToRemove(wsrfp.getNome());
  3249.                     e.add(de);

  3250.                     de = new DataElement();
  3251.                     if(wsrfp.getValore()!=null && StringUtils.isNotEmpty(wsrfp.getValore()) &&
  3252.                             BYOKManager.isEnabledBYOK() &&
  3253.                             this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(wsrfp.getValore())) {
  3254.                         de.setValue(CostantiControlStation.VALORE_CIFRATO);
  3255.                     }
  3256.                     else {
  3257.                         de.setValue(wsrfp.getValore());
  3258.                     }
  3259.                     e.add(de);

  3260.                     dati.add(e);
  3261.                 }
  3262.             }

  3263.             this.pd.setDati(dati);
  3264.             this.pd.setAddButton(true);

  3265.         } catch (Exception e) {
  3266.             this.logError(e.getMessage(), e);
  3267.             throw new ControlStationCoreException(e.getMessage(),e);
  3268.         }
  3269.     }

  3270.     public void preparePorteDelegateCorrAppRispostaList(String nomePorta, ISearch ricerca, List<CorrelazioneApplicativaRispostaElemento> lista)
  3271.             throws Exception {
  3272.         try {

  3273.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  3274.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  3275.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  3276.            
  3277.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  3278.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  3279.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  3280.             if(idAsps == null)
  3281.                 idAsps = "";
  3282.            
  3283.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  3284.             if(idFruizione == null)
  3285.                 idFruizione = "";
  3286.            
  3287.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  3288.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  3289.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  3290.             Parameter pIdFrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  3291.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_RESPONSE, pId, pIdSoggetto, pIdAsps, pIdFrizione);

  3292.             int idLista = Liste.PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_RISPOSTA;
  3293.             int limit = ricerca.getPageSize(idLista);
  3294.             int offset = ricerca.getIndexIniziale(idLista);
  3295.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  3296.             this.pd.setIndex(offset);
  3297.             this.pd.setPageSize(limit);
  3298.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  3299.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  3300.             String idporta = myPD.getNome();

  3301.             // setto la barra del titolo
  3302.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  3303.            
  3304.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);
  3305.             String labelPerPorta = null;
  3306.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  3307.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  3308.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONI_APPLICATIVE_CONFIG_DI,
  3309.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRACCIAMENTO,
  3310.                         myPD);
  3311.             }
  3312.             else {
  3313.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONI_APPLICATIVE_CONFIG_DI+idporta;
  3314.             }
  3315.             lstParam.add(new Parameter(labelPerPorta,
  3316.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione, pIdFrizione ));

  3317.             this.pd.setSearchLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML);
  3318.             if(search.equals("")){
  3319.                 this.pd.setSearchDescription("");
  3320.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONI_APPLICATIVE_RISPOSTA_DI, // + idporta,
  3321.                         null));
  3322.             }
  3323.             else{
  3324.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONI_APPLICATIVE_RISPOSTA_DI, // + idporta,
  3325.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_RESPONSE_LIST, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione    ));
  3326.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));
  3327.             }

  3328.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  3329.            
  3330.             // imposto menu' contestuale
  3331.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  3332.             // controllo eventuali risultati ricerca
  3333.             if (!search.equals("")) {
  3334.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONI_APPLICATIVE_RISPOSTA_DI, search);
  3335.             }

  3336.             // setto le label delle colonne
  3337.             String[] labels = {
  3338.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELEMENTO_XML,
  3339.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODALITA_IDENTIFICAZIONE
  3340.             };
  3341.             this.pd.setLabels(labels);

  3342.             // preparo i dati
  3343.             List<List<DataElement>> dati = new ArrayList<>();

  3344.             if (lista != null) {
  3345.                 Iterator<CorrelazioneApplicativaRispostaElemento> it = lista.iterator();
  3346.                 while (it.hasNext()) {
  3347.                     CorrelazioneApplicativaRispostaElemento cae = it.next();

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

  3349.                     DataElement de = new DataElement();
  3350.                     de.setType(DataElementType.HIDDEN);
  3351.                     de.setValue("" + cae.getId());
  3352.                     e.add(de);

  3353.                     de = new DataElement();
  3354.                     de.setUrl(
  3355.                             PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_RESPONSE_CHANGE, pId, pIdSoggetto, pIdAsps, pIdFrizione,
  3356.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_CORRELAZIONE, cae.getId() + "")
  3357.                             );
  3358.                     //String nomeElemento = "(*)";
  3359.                     String nomeElemento = CostantiControlStation.LABEL_PORTE_CORRELAZIONE_APPLICATIVA_QUALSIASI;
  3360.                     if (cae.getNome() != null && !"".equals(cae.getNome()))
  3361.                         nomeElemento = cae.getNome();
  3362.                     de.setValue(nomeElemento);
  3363.                     de.setIdToRemove("" + cae.getId());
  3364.                     e.add(de);

  3365.                     de = new DataElement();
  3366.                     if(cae.getIdentificazione()!=null) {
  3367.                         //de.setValue(cae.getIdentificazione().toString());
  3368.                         switch (cae.getIdentificazione()) {
  3369.                         case DISABILITATO:
  3370.                             de.setValue(CostantiControlStation.LABEL_PARAMETRO_MODE_CORRELAZIONE_DISABILITATO);
  3371.                             break;
  3372.                         case HEADER_BASED:
  3373.                             de.setValue(ModalitaIdentificazione.HEADER_BASED.getLabel());
  3374.                             break;
  3375.                         case CONTENT_BASED:
  3376.                             de.setValue(ModalitaIdentificazione.CONTENT_BASED.getLabel());
  3377.                             break;
  3378.                         case INPUT_BASED:
  3379.                             de.setValue(ModalitaIdentificazione.INPUT_BASED.getLabel());
  3380.                             break;
  3381.                         case TEMPLATE:
  3382.                             de.setValue(ModalitaIdentificazione.GOVWAY_TEMPLATE.getLabel());
  3383.                             break;
  3384.                         case FREEMARKER_TEMPLATE:
  3385.                             de.setValue(ModalitaIdentificazione.FREEMARKER_TEMPLATE.getLabel());
  3386.                             break;
  3387.                         case VELOCITY_TEMPLATE:
  3388.                             de.setValue(ModalitaIdentificazione.VELOCITY_TEMPLATE.getLabel());
  3389.                             break;
  3390.                         }
  3391.                     }
  3392.                     e.add(de);

  3393.                     dati.add(e);
  3394.                 }
  3395.             }

  3396.             this.pd.setDati(dati);
  3397.             this.pd.setAddButton(true);
  3398.         } catch (Exception e) {
  3399.             this.logError(e.getMessage(), e);
  3400.             throw new ControlStationCoreException(e.getMessage(),e);
  3401.         }
  3402.     }

  3403.     // Prepara la lista di MTOM request-flow delle porte delegate
  3404.     public void preparePorteDelegateMTOMRequestList(String nomePorta, ISearch ricerca, List<MtomProcessorFlowParameter> lista)  throws Exception {
  3405.         try {

  3406.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  3407.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  3408.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  3409.            
  3410.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  3411.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  3412.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  3413.             if(idAsps == null)
  3414.                 idAsps = "";
  3415.            
  3416.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  3417.             if(idFruizione == null)
  3418.                 idFruizione = "";
  3419.            
  3420.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  3421.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  3422.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  3423.             Parameter pIdFrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  3424.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_MTOM_REQUEST, pId, pIdSoggetto, pIdAsps, pIdFrizione);

  3425.             int idLista = Liste.PORTE_DELEGATE_MTOM_REQUEST;
  3426.             int limit = ricerca.getPageSize(idLista);
  3427.             int offset = ricerca.getIndexIniziale(idLista);
  3428.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  3429.             this.pd.setIndex(offset);
  3430.             this.pd.setPageSize(limit);
  3431.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  3432.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  3433.             String idporta = myPD.getNome();

  3434.             // setto la barra del titolo
  3435.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  3436.            
  3437.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);

  3438.             String labelPerPorta = null;
  3439.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  3440.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  3441.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_CONFIG_DI,
  3442.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_CONFIG,
  3443.                         myPD);
  3444.             }
  3445.             else {
  3446.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_CONFIG_DI+idporta;
  3447.             }
  3448.             lstParam.add(new Parameter(labelPerPorta,
  3449.                     PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM,pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione));
  3450.            
  3451.             this.pd.setSearchLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  3452.             if(search.equals("")){
  3453.                 this.pd.setSearchDescription("");
  3454.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_REQUEST_FLOW_DI, // + idporta,
  3455.                         null));
  3456.             }
  3457.             else{
  3458.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_REQUEST_FLOW_DI, // + idporta,
  3459.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM_REQUEST_LIST,pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione));
  3460.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));
  3461.             }


  3462.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  3463.            
  3464.             // imposto menu' contestuale
  3465.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  3466.             // controllo eventuali risultati ricerca
  3467.             if (!search.equals("")) {
  3468.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_REQUEST_FLOW_DI, search);
  3469.             }

  3470.             // setto le label delle colonne
  3471.             String[] labels = {
  3472.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME,
  3473.             };
  3474.             this.pd.setLabels(labels);

  3475.             // preparo i dati
  3476.             List<List<DataElement>> dati = new ArrayList<>();

  3477.             if (lista != null) {
  3478.                 Iterator<MtomProcessorFlowParameter> it = lista.iterator();
  3479.                 while (it.hasNext()) {
  3480.                     MtomProcessorFlowParameter parametro = it.next();

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

  3482.                     DataElement de = new DataElement();
  3483.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM_REQUEST_CHANGE ,pId, pIdSoggetto, pIdAsps, pIdFrizione,
  3484.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, parametro.getNome())
  3485.                             );
  3486.                     de.setValue(parametro.getNome());
  3487.                     de.setIdToRemove(parametro.getNome());
  3488.                     e.add(de);
  3489.                     dati.add(e);
  3490.                 }
  3491.             }

  3492.             this.pd.setDati(dati);
  3493.             this.pd.setAddButton(true);

  3494.         } catch (Exception e) {
  3495.             this.logError(e.getMessage(), e);
  3496.             throw new ControlStationCoreException(e.getMessage(),e);
  3497.         }
  3498.     }


  3499.     // Prepara la lista di MTOM response-flow delle porte delegate
  3500.     public void preparePorteDelegateMTOMResponseList(String nomePorta, ISearch ricerca,
  3501.             List<MtomProcessorFlowParameter> lista)
  3502.                     throws Exception {
  3503.         try {
  3504.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  3505.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  3506.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  3507.             if(idAsps == null)
  3508.                 idAsps = "";
  3509.            
  3510.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  3511.             if(idFruizione == null)
  3512.                 idFruizione = "";
  3513.            
  3514.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  3515.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  3516.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  3517.             Parameter pIdFrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  3518.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  3519.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  3520.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  3521.            
  3522.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_MTOM_RESPONSE, pId, pIdSoggetto, pIdAsps, pIdFrizione);

  3523.             int idLista = Liste.PORTE_DELEGATE_MTOM_RESPONSE;
  3524.             int limit = ricerca.getPageSize(idLista);
  3525.             int offset = ricerca.getIndexIniziale(idLista);
  3526.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  3527.             this.pd.setIndex(offset);
  3528.             this.pd.setPageSize(limit);
  3529.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  3530.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  3531.             String idporta = myPD.getNome();

  3532.             // setto la barra del titolo
  3533.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  3534.            
  3535.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);
  3536.            
  3537.             String labelPerPorta = null;
  3538.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  3539.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  3540.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_CONFIG_DI,
  3541.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_CONFIG,
  3542.                         myPD);
  3543.             }
  3544.             else {
  3545.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_CONFIG_DI+idporta;
  3546.             }
  3547.             lstParam.add(new Parameter(labelPerPorta,
  3548.                     PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM,pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione));

  3549.             this.pd.setSearchLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  3550.             if(search.equals("")){
  3551.                 this.pd.setSearchDescription("");
  3552.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_RESPONSE_FLOW_DI, // + idporta,
  3553.                         null));
  3554.             }
  3555.             else{
  3556.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_RESPONSE_FLOW_DI, // + idporta,
  3557.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM_RESPONSE_LIST,pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFrizione));
  3558.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));
  3559.             }

  3560.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  3561.            
  3562.             // imposto menu' contestuale
  3563.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  3564.             // controllo eventuali risultati ricerca
  3565.             if (!search.equals("")) {
  3566.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_RESPONSE_FLOW_DI, search);
  3567.             }

  3568.             // setto le label delle colonne
  3569.             String[] labels = {
  3570.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME,
  3571.             };
  3572.             this.pd.setLabels(labels);

  3573.             // preparo i dati
  3574.             List<List<DataElement>> dati = new ArrayList<>();

  3575.             if (lista != null) {
  3576.                 Iterator<MtomProcessorFlowParameter> it = lista.iterator();
  3577.                 while (it.hasNext()) {
  3578.                     MtomProcessorFlowParameter wsrfp = it.next();

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

  3580.                     DataElement de = new DataElement();
  3581.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM_RESPONSE_CHANGE,pId, pIdSoggetto, pIdAsps, pIdFrizione,
  3582.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, wsrfp.getNome())
  3583.                             );
  3584.                     de.setValue(wsrfp.getNome());
  3585.                     de.setIdToRemove(wsrfp.getNome());
  3586.                     e.add(de);

  3587.                     dati.add(e);
  3588.                 }
  3589.             }

  3590.             this.pd.setDati(dati);
  3591.             this.pd.setAddButton(true);

  3592.         } catch (Exception e) {
  3593.             this.logError(e.getMessage(), e);
  3594.             throw new ControlStationCoreException(e.getMessage(),e);
  3595.         }
  3596.     }
  3597.    
  3598.     public List<Parameter> getTitoloPD(Integer parentPD, String idSoggettoFruitore, String idAsps, String idFruizione)  throws Exception, DriverRegistroServiziNotFound, DriverRegistroServiziException {
  3599.        
  3600.         if(parentPD==null) {
  3601.             throw new Exception("Parameter parentPD is null");
  3602.         }
  3603.         if(idSoggettoFruitore==null) {
  3604.             throw new Exception("Parameter idSoggettoFruitore is null");
  3605.         }
  3606.        
  3607.         List<Parameter> lstParam = new ArrayList<>();
  3608.        
  3609.         String tipoSoggettoFruitore = null;
  3610.         String nomeSoggettoFruitore = null;
  3611.         if(this.core.isRegistroServiziLocale()){
  3612.             org.openspcoop2.core.registry.Soggetto soggettoFruitore = this.soggettiCore.getSoggettoRegistro(Integer.parseInt(idSoggettoFruitore));
  3613.             tipoSoggettoFruitore = soggettoFruitore.getTipo();
  3614.             nomeSoggettoFruitore = soggettoFruitore.getNome();
  3615.         }else{
  3616.             org.openspcoop2.core.config.Soggetto soggettoFruitore = this.soggettiCore.getSoggetto(Integer.parseInt(idSoggettoFruitore));
  3617.             tipoSoggettoFruitore = soggettoFruitore.getTipo();
  3618.             nomeSoggettoFruitore = soggettoFruitore.getNome();
  3619.         }
  3620.        
  3621.         String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(tipoSoggettoFruitore);
  3622.        
  3623.         switch (parentPD) {
  3624.         case PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE:
  3625.             // Prendo il nome e il tipo del servizio
  3626.             AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(idAsps));
  3627.             String servizioTmpTile = this.getLabelServizioFruizione(protocollo, new IDSoggetto(tipoSoggettoFruitore, nomeSoggettoFruitore), asps);
  3628.            
  3629.             String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  3630.             boolean gestioneFruitori = false;
  3631.             if(tipologia!=null) {
  3632.                 if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  3633.                     gestioneFruitori = true;
  3634.                 }
  3635.             }
  3636.            
  3637.             Parameter pIdServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId()+ "");
  3638.             Parameter pIdFruizione = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, idFruizione+ "");
  3639.             Parameter pIdSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO, idSoggettoFruitore);
  3640.             Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  3641.             Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  3642.             Parameter pTipoSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE, tipoSoggettoFruitore);
  3643.             Parameter pNomeSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE, nomeSoggettoFruitore);
  3644.            
  3645.             if(gestioneFruitori) {
  3646.                 Boolean vistaErogazioni = ServletUtils.getBooleanAttributeFromSession(ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI, this.session, this.request).getValue();
  3647.                 if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  3648.                     lstParam.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_FRUIZIONI, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST));
  3649.                     lstParam.add(new Parameter(servizioTmpTile, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_CHANGE,
  3650.                             pIdServizio,pNomeServizio, pTipoServizio, pTipoSoggettoFruitore, pNomeSoggettoFruitore));
  3651.                     boolean gestioneGruppi = true;
  3652.                     String paramGestioneGruppi = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_GRUPPI);
  3653.                     if(paramGestioneGruppi!=null && !"".equals(paramGestioneGruppi)) {
  3654.                         gestioneGruppi = Boolean.valueOf(paramGestioneGruppi);
  3655.                     }
  3656.                    
  3657.                     boolean gestioneConfigurazioni = true;
  3658.                     String paramGestioneConfigurazioni = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_CONFIGURAZIONI);
  3659.                     if(paramGestioneConfigurazioni!=null && !"".equals(paramGestioneConfigurazioni)) {
  3660.                         gestioneConfigurazioni = Boolean.valueOf(paramGestioneConfigurazioni);
  3661.                     }
  3662.                    
  3663.                     AccordoServizioParteComuneSintetico as = this.apcCore.getAccordoServizioSintetico(asps.getIdAccordo());
  3664.                     ServiceBinding serviceBinding = this.apcCore.toMessageServiceBinding(as.getServiceBinding());
  3665.                     String labelConfigurazione = gestioneConfigurazioni ? ErogazioniCostanti.LABEL_ASPS_GESTIONE_CONFIGURAZIONI :
  3666.                         (gestioneGruppi ? MessageFormat.format(ErogazioniCostanti.LABEL_ASPS_GESTIONE_GRUPPI_CON_PARAMETRO, this.getLabelAzioni(serviceBinding)) : AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_DELEGATE);
  3667.                    
  3668.                     lstParam.add(new Parameter(labelConfigurazione, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_PORTE_DELEGATE_LIST ,
  3669.                             pIdFruizione,pIdServizio,pIdSoggettoFruitore, pTipoSoggettoFruitore, pNomeSoggettoFruitore));
  3670.                    
  3671.                 }else {
  3672.                     lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  3673.                     //  lstParam.add(new Parameter(servizioTmpTile, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE, pIdServizio,pNomeServizio, pTipoServizio));
  3674.                     lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_CONFIGURAZIONI_DI + servizioTmpTile,
  3675.                             AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_PORTE_DELEGATE_LIST ,
  3676.                             pIdFruizione,pIdServizio,pIdSoggettoFruitore, pTipoSoggettoFruitore, pNomeSoggettoFruitore));
  3677.                 }
  3678.             }
  3679.             else {
  3680.            
  3681.                 Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, asps.getIdSoggetto()+"");
  3682.                 //Parameter pIdProviderSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE, idSoggettoFruitore);
  3683.                
  3684.                 String fruizioneTmpTile = this.getLabelNomeSoggetto(protocollo, tipoSoggettoFruitore,nomeSoggettoFruitore);
  3685.                
  3686.                 lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  3687.                 lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FUITORI_DI  + servizioTmpTile, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_LIST , pIdServizio,pIdSoggettoErogatore));
  3688.                 //lstParam.add(new Parameter(fruizioneTmpTile, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE, pIdServizio,pIdFruizione,pIdProviderSoggettoFruitore));
  3689.                 lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_CONFIGURAZIONI_DI + fruizioneTmpTile,
  3690.                         AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_PORTE_DELEGATE_LIST ,pIdFruizione,pIdServizio,pIdSoggettoFruitore));
  3691.                
  3692.             }
  3693.                
  3694.             break;
  3695.         case PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_SOGGETTO:
  3696.             String soggettoTitle =  this.getLabelNomeSoggetto(protocollo, tipoSoggettoFruitore,nomeSoggettoFruitore);
  3697.             lstParam.add(new Parameter(SoggettiCostanti.LABEL_SOGGETTI, SoggettiCostanti.SERVLET_NAME_SOGGETTI_LIST));
  3698.             lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PORTE_DELEGATE_DI + soggettoTitle, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_LIST ,
  3699.                     new Parameter( PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idSoggettoFruitore)));
  3700.             break;
  3701.         case PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE:
  3702.         default:
  3703.             lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PORTE_DELEGATE, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_LIST));
  3704.             break;
  3705.         }
  3706.         return lstParam;
  3707.     }
  3708.    
  3709.     public void impostaComandiMenuContestualePD(String idSoggFruitoreDelServizio, String idAsps, String idFruizione)    throws Exception, DriverRegistroServiziNotFound, DriverRegistroServiziException {
  3710.         if(idSoggFruitoreDelServizio==null) {
  3711.             throw new Exception("Parameter idSoggettoFruitore is null");
  3712.         }
  3713.        
  3714.         IDSoggetto idSoggettoFruitore = new IDSoggetto();
  3715.         String tipoSoggettoFruitore = null;
  3716.         String nomeSoggettoFruitore = null;
  3717.         if(this.core.isRegistroServiziLocale()){
  3718.             org.openspcoop2.core.registry.Soggetto soggettoFruitore = this.soggettiCore.getSoggettoRegistro(Integer.parseInt(idSoggFruitoreDelServizio));
  3719.             tipoSoggettoFruitore = soggettoFruitore.getTipo();
  3720.             nomeSoggettoFruitore = soggettoFruitore.getNome();
  3721.         }else{
  3722.             org.openspcoop2.core.config.Soggetto soggettoFruitore = this.soggettiCore.getSoggetto(Integer.parseInt(idSoggFruitoreDelServizio));
  3723.             tipoSoggettoFruitore = soggettoFruitore.getTipo();
  3724.             nomeSoggettoFruitore = soggettoFruitore.getNome();
  3725.         }
  3726.         idSoggettoFruitore.setTipo(tipoSoggettoFruitore);
  3727.         idSoggettoFruitore.setNome(nomeSoggettoFruitore);
  3728.        
  3729.         String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(tipoSoggettoFruitore);
  3730.        
  3731.         // Prendo il nome e il tipo del servizio
  3732.         AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(idAsps));
  3733.        
  3734.         Fruitore fru = null;
  3735.         for (Fruitore fruCheck : asps.getFruitoreList()) {
  3736.             if(fruCheck.getTipo().equals(idSoggettoFruitore.getTipo()) &&
  3737.                     fruCheck.getNome().equals(idSoggettoFruitore.getNome())) {
  3738.                 fru = fruCheck;
  3739.                 break;
  3740.             }
  3741.         }
  3742.        
  3743.         Parameter pIdFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, idFruizione+ "");
  3744.         Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  3745.         Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  3746.         Parameter pTipoSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE, tipoSoggettoFruitore);
  3747.         Parameter pNomeSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE, nomeSoggettoFruitore);
  3748.         Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, asps.getIdSoggetto()+"");
  3749.        
  3750.         this.impostaComandiMenuContestualePD(idSoggFruitoreDelServizio, pTipoSoggettoFruitore,
  3751.                 pNomeSoggettoFruitore, asps, protocollo, pIdSoggettoErogatore, fru,
  3752.                 pIdFruitore, pNomeServizio, pTipoServizio);
  3753.     }
  3754.    
  3755.     public String getPortaDelegataAzioneIdentificazioneLabel(String pdAiString) {
  3756.         if(pdAiString == null)
  3757.             return "";
  3758.        
  3759.         return getPortaDelegataAzioneIdentificazioneLabel(PortaDelegataAzioneIdentificazione.toEnumConstant(pdAiString));
  3760.     }
  3761.    

  3762.     public String getPortaDelegataAzioneIdentificazioneLabel(PortaDelegataAzioneIdentificazione pdAi) {
  3763.         if(pdAi == null)
  3764.             return "";
  3765.         switch (pdAi) {
  3766.         case CONTENT_BASED:
  3767.             return PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODE_CONTENT_BASED;
  3768.         case HEADER_BASED:
  3769.             return PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODE_HEADER_BASED;
  3770.         case INPUT_BASED:
  3771.             return PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODE_INPUT_BASED;
  3772.         case INTERFACE_BASED:
  3773.             return PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODE_WSDL_BASED;
  3774.         case SOAP_ACTION_BASED:
  3775.             return PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODE_SOAP_ACTION_BASED;
  3776.         case STATIC:
  3777.             return PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODE_REGISTER_INPUT;
  3778.         case URL_BASED:
  3779.             return PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODE_URL_BASED;
  3780.         case DELEGATED_BY:
  3781.         default:
  3782.             break;
  3783.         }
  3784.        
  3785.         return "";
  3786.     }

  3787.     public void preparePorteDelPropList(String nomePorta, ConsoleSearch ricerca, List<Proprieta> lista) throws Exception {
  3788.         try {
  3789.             if(nomePorta!=null) {
  3790.                 // nop
  3791.             }
  3792.            
  3793.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  3794.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  3795.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  3796.            
  3797.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  3798.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  3799.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  3800.             if(idAsps == null)
  3801.                 idAsps = "";
  3802.            
  3803.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  3804.             if(idFruizione == null)
  3805.                 idFruizione = "";
  3806.            
  3807.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  3808.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  3809.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  3810.             Parameter pIdFruizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  3811.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_PROPRIETA_PROTOCOLLO, pId, pIdSoggetto, pIdAsps, pIdFruizione);

  3812.             int idLista = Liste.PORTE_DELEGATE_PROP;
  3813.             int limit = ricerca.getPageSize(idLista);
  3814.             int offset = ricerca.getIndexIniziale(idLista);
  3815.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  3816.             this.pd.setIndex(offset);
  3817.             this.pd.setPageSize(limit);
  3818.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  3819.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  3820.             String idporta = myPD.getNome();

  3821.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  3822.            
  3823.             String labelPerPorta = null;
  3824.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  3825.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  3826.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PROTOCOL_PROPERTIES_CONFIG_DI,
  3827.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PROTOCOL_PROPERTIES,
  3828.                         myPD);
  3829.             }
  3830.             else {
  3831.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PROTOCOL_PROPERTIES_CONFIG_DI+idporta;
  3832.             }
  3833.            
  3834.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);

  3835.             this.pd.setSearchLabel(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME);
  3836.             if(search.equals("")){
  3837.                 this.pd.setSearchDescription("");
  3838.                 lstParam.add(new Parameter(labelPerPorta,null));
  3839.             }
  3840.             else{
  3841.                 lstParam.add(new Parameter(labelPerPorta,
  3842.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_PROPRIETA_PROTOCOLLO_LIST, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFruizione    ));
  3843.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));

  3844.             }

  3845.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  3846.            
  3847.             // imposto menu' contestuale
  3848.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  3849.             // controllo eventuali risultati ricerca
  3850.             if (!search.equals("")) {
  3851.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PROTOCOL_PROPERTIES, search);
  3852.             }
  3853.            
  3854.             // setto le label delle colonne
  3855.             String valueLabel = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  3856.             String[] labels = { PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME, valueLabel };
  3857.             this.pd.setLabels(labels);
  3858.            
  3859.             // preparo i dati
  3860.             List<List<DataElement>> dati = new ArrayList<>();

  3861.             if (lista != null) {
  3862.                 Iterator<Proprieta> it = lista.iterator();
  3863.                 while (it.hasNext()) {
  3864.                     Proprieta ssp = it.next();

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

  3866.                     DataElement de = new DataElement();
  3867.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_PROPRIETA_PROTOCOLLO_CHANGE, pId,pIdSoggetto, pIdAsps, pIdFruizione, new Parameter( PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, ssp.getNome()));
  3868.                     de.setValue(ssp.getNome());
  3869.                     de.setIdToRemove(ssp.getNome());
  3870.                     de.setSize(CostantiControlStation.NOME_PROPRIETA_VISUALIZZATA);
  3871.                     e.add(de);

  3872.                     de = new DataElement();
  3873.                     if(ssp.getValore()!=null) {
  3874.                         if(StringUtils.isNotEmpty(ssp.getValore()) &&
  3875.                                 BYOKManager.isEnabledBYOK() &&
  3876.                                 this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(ssp.getValore())) {
  3877.                             de.setValue(CostantiControlStation.VALORE_CIFRATO);
  3878.                         }
  3879.                         else {
  3880.                             de.setValue(ssp.getValore());
  3881.                         }
  3882.                     }
  3883.                     e.add(de);

  3884.                     dati.add(e);
  3885.                 }
  3886.             }

  3887.             this.pd.setDati(dati);
  3888.             this.pd.setAddButton(true);

  3889.         } catch (Exception e) {
  3890.             this.logError(e.getMessage(), e);
  3891.             throw new ControlStationCoreException(e.getMessage(),e);
  3892.         }
  3893.     }

  3894.     public List<DataElement> addProprietaProtocolloToDati(TipoOperazione tipoOp, int size, String nome, String valore,
  3895.             List<DataElement> dati) {
  3896.         DataElement de = new DataElement();
  3897.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PROTOCOL_PROPERTIES);
  3898.         de.setType(DataElementType.TITLE);
  3899.         dati.add(de);
  3900.        
  3901.         de = new DataElement();
  3902.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  3903.         de.setValue(nome);
  3904.         if(TipoOperazione.ADD.equals(tipoOp)){
  3905.             de.setType(DataElementType.TEXT_EDIT);
  3906.             de.setRequired(true);
  3907.         }
  3908.         else{
  3909.             de.setType(DataElementType.TEXT);
  3910.         }
  3911.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME);
  3912.         de.setSize(size);
  3913.         dati.add(de);

  3914.         de = new DataElement();
  3915.         de.setLabel(CostantiControlStation.LABEL_PARAMETRO_VALORE);
  3916.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_VALORE);
  3917.         this.core.getLockUtilities().lockProperty(de, valore);
  3918.         de.setRequired(true);
  3919.         de.setSize(size);
  3920.         dati.add(de);

  3921.         return dati;
  3922.        
  3923.     }

  3924.     public boolean porteAppPropCheckData(TipoOperazione tipoOp) throws ControlStationCoreException {
  3925.         try {
  3926.             String idPorta = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  3927.             int idInt = Integer.parseInt(idPorta);
  3928.             String nome = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME);
  3929.             String valore = this.getLockedParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_VALORE, false);

  3930.             // Campi obbligatori
  3931.             if (nome.equals("") || valore.equals("")) {
  3932.                 String tmpElenco = "";
  3933.                 if (nome.equals("")) {
  3934.                     tmpElenco = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME;
  3935.                 }
  3936.                 if (valore.equals("")) {
  3937.                     if (tmpElenco.equals("")) {
  3938.                         tmpElenco = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  3939.                     } else {
  3940.                         tmpElenco = tmpElenco + ", " + PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  3941.                     }
  3942.                 }
  3943.                 this.pd.setMessage(MessageFormat.format(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, tmpElenco));
  3944.                 return false;
  3945.             }

  3946.             if (nome.indexOf(" ") != -1) {
  3947.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_CAMPI_DI_TESTO);
  3948.                 return false;
  3949.             }
  3950.             if(!this.checkLength255(nome, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME)) {
  3951.                 return false;
  3952.             }
  3953.            
  3954.             if( !this.core.getDriverBYOKUtilities().isEnabledBYOK() || !this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(valore) ){
  3955.                 if (valore.indexOf(" ") != -1) {
  3956.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_CAMPI_DI_TESTO);
  3957.                     return false;
  3958.                 }
  3959.                 if(!this.checkLength255(valore, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE)) {
  3960.                     return false;
  3961.                 }
  3962.             }

  3963.             // Se tipoOp = add, controllo che la property non sia gia'
  3964.             // stata
  3965.             // registrata per la porta applicativa
  3966.             if (tipoOp.equals(TipoOperazione.ADD)) {
  3967.                 boolean giaRegistrato = false;
  3968.                 PortaDelegata portaDelegata = this.porteDelegateCore.getPortaDelegata(idInt);
  3969.                 String nomeporta = portaDelegata.getNome();

  3970.                 for (int i = 0; i < portaDelegata.sizeProprietaList(); i++) {
  3971.                     Proprieta tmpProp = portaDelegata.getProprieta(i);
  3972.                     if (nome.equals(tmpProp.getNome())) {
  3973.                         giaRegistrato = true;
  3974.                         break;
  3975.                     }
  3976.                 }

  3977.                 if (giaRegistrato) {
  3978.                     this.pd.setMessage(MessageFormat.format(
  3979.                             PorteDelegateCostanti.MESSAGGIO_ERRORE_LA_PROPERTY_XX_E_GIA_STATA_ASSOCIATA_ALLA_PORTA_DELEGATA_YY, nome,
  3980.                             nomeporta));
  3981.                     return false;
  3982.                 }
  3983.             }

  3984.             return true;
  3985.         } catch (Exception e) {
  3986.             this.logError(e.getMessage(), e);
  3987.             throw new ControlStationCoreException(e.getMessage(),e);
  3988.         }
  3989.     }
  3990.    
  3991.     public String getMessaggioConfermaModificaRegolaMappingFruizionePortaDelegata(boolean fromAPI,PortaDelegata pd, ServiceBinding serviceBinding, boolean abilitazione, boolean multiline,boolean listElement) throws DriverConfigurazioneException {
  3992.         MappingFruizionePortaDelegata mapping = this.porteDelegateCore.getMappingFruizionePortaDelegata(pd);
  3993.         List<String> listaAzioni = pd.getAzione()!= null ?  pd.getAzione().getAzioneDelegataList() : new ArrayList<>();
  3994.         return this.getMessaggioConfermaModificaRegolaMapping(fromAPI, mapping.isDefault(), listaAzioni, serviceBinding, mapping.getDescrizione(), abilitazione, multiline, listElement);
  3995.     }
  3996.    
  3997.    
  3998.    
  3999.     public void prepareResponseCachingConfigurazioneRegolaList(String nomePorta, ISearch ricerca, List<ResponseCachingConfigurazioneRegola> lista, Integer defaultCacheSeconds) throws Exception {
  4000.         try {
  4001.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  4002.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  4003.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  4004.            
  4005.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  4006.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  4007.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  4008.             if(idAsps == null)
  4009.                 idAsps = "";
  4010.            
  4011.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  4012.             if(idFruizione == null)
  4013.                 idFruizione = "";
  4014.            
  4015.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  4016.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  4017.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  4018.             Parameter pIdFrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  4019.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA, pId, pIdSoggetto, pIdAsps, pIdFrizione);

  4020.             int idLista = Liste.PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA;
  4021.             int limit = ricerca.getPageSize(idLista);
  4022.             int offset = ricerca.getIndexIniziale(idLista);
  4023.            
  4024.             this.pd.setIndex(offset);
  4025.             this.pd.setPageSize(limit);
  4026.             this.pd.setSearch("");
  4027.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  4028.             this.pd.setSearchDescription("");
  4029.            
  4030.             ServletUtils.disabledPageDataSearch(this.pd);

  4031.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  4032.             String idporta = myPD.getNome();

  4033.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  4034.            
  4035.             String labelPerPorta = null;
  4036.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  4037.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  4038.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_CONFIG_DI,
  4039.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE,
  4040.                         myPD);
  4041.             }
  4042.             else {
  4043.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_CONFIG_DI+idporta;
  4044.             }
  4045.            
  4046.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_RESPONSE_CACHING,
  4047.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + myPD.getId()),
  4048.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome()),
  4049.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, myPD.getIdSoggetto() + ""),
  4050.                     pIdAsps, new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione+ "")));
  4051.            
  4052.             String labelPagLista = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLE;
  4053.            
  4054.             lstParam.add(new Parameter(labelPagLista,null));
  4055.            
  4056.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  4057.            
  4058.             // imposto menu' contestuale
  4059.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  4060.             // setto le label delle colonne
  4061.             String[] labels = {
  4062.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE,
  4063.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_FAULT,
  4064.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_CACHE_TIMEOUT_SECONDS
  4065.             };
  4066.             this.pd.setLabels(labels);

  4067.             // preparo i dati
  4068.             List<List<DataElement>> dati = new ArrayList<>();

  4069.             if (lista != null) {
  4070.                 Iterator<ResponseCachingConfigurazioneRegola> it = lista.iterator();
  4071.                 while (it.hasNext()) {
  4072.                     ResponseCachingConfigurazioneRegola regola = it.next();

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

  4074.                     DataElement de = new DataElement();
  4075.                     de.setIdToRemove(regola.getId() + "");
  4076.                    
  4077.                     Integer statusMin = regola.getReturnCodeMin();
  4078.                     Integer statusMax = regola.getReturnCodeMax();
  4079.                    
  4080.                     // se e' stato salvato il valore 0 lo tratto come null
  4081.                     if(statusMin != null && statusMin.intValue() <= 0) {
  4082.                         statusMin = null;
  4083.                     }
  4084.                    
  4085.                     if(statusMax != null && statusMax.intValue() <= 0) {
  4086.                         statusMax = null;
  4087.                     }
  4088.                    
  4089.                     String statusValue = null;
  4090.                     // Intervallo
  4091.                     if(statusMin != null && statusMax != null) {
  4092.                         if(statusMax.longValue() == statusMin.longValue()) // esatto
  4093.                             statusValue = statusMin + "";
  4094.                         else
  4095.                             statusValue = "[" + statusMin + " - " + statusMax + "]";
  4096.                     } else if(statusMin != null && statusMax == null) { // definito solo l'estremo inferiore
  4097.                         statusValue = "&gt;" + statusMin;
  4098.                     } else if(statusMin == null && statusMax != null) { // definito solo l'estremo superiore
  4099.                         statusValue = "&lt;" + statusMax;
  4100.                     } else { //entrambi null
  4101.                         statusValue = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_QUALSIASI;
  4102.                     }
  4103.                    
  4104.                     de.setValue(statusValue);
  4105.                     e.add(de);
  4106.                    
  4107.                     de = new DataElement();
  4108.                     de.setValue(regola.getFault() ? CostantiControlStation.LABEL_SI : CostantiControlStation.LABEL_NO);
  4109.                     e.add(de);
  4110.                    
  4111.                     de = new DataElement();
  4112.                     de.setValue(regola.getCacheTimeoutSeconds() != null ? regola.getCacheTimeoutSeconds() + "" : "default ("+defaultCacheSeconds+")");
  4113.                     e.add(de);

  4114.                     dati.add(e);
  4115.                 }
  4116.             }

  4117.             this.pd.setDati(dati);
  4118.             this.pd.setAddButton(true);

  4119.         } catch (Exception e) {
  4120.             this.logError(e.getMessage(), e);
  4121.             throw new ControlStationCoreException(e.getMessage(),e);
  4122.         }
  4123.     }
  4124.    
  4125.     // Controlla i dati del registro
  4126.     public boolean responseCachingConfigurazioneRegolaCheckData(TipoOperazione tipoOp, long idPorta) throws Exception {

  4127.         try{
  4128.            
  4129.             if(this.checkRegolaResponseCaching() == false) {
  4130.                 return false;
  4131.             }
  4132.            
  4133.             String returnCode = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE);
  4134.             String statusMinS = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MIN);
  4135.             String statusMaxS = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_RETURN_CODE_MAX);
  4136.             String faultS = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_FAULT);
  4137.            
  4138.             Integer statusMin = null;
  4139.             Integer statusMax = null;
  4140.             boolean fault = ServletUtils.isCheckBoxEnabled(faultS);
  4141.            
  4142.             if(!returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_QUALSIASI)) {
  4143.                
  4144.                 if(StringUtils.isNotEmpty(statusMinS)) {
  4145.                     statusMin = Integer.parseInt(statusMinS);
  4146.                 }
  4147.                
  4148.                 if(returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_INTERVALLO)) {
  4149.                     if(StringUtils.isNotEmpty(statusMaxS)) {
  4150.                         statusMax = Integer.parseInt(statusMaxS);
  4151.                     }
  4152.                 }

  4153.                 // return code esatto, ho salvato lo stesso valore nel campo return code;
  4154.                 if(returnCode.equals(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_ESATTO))
  4155.                     statusMax = statusMin;
  4156.             }
  4157.            
  4158.             // Se tipoOp = add, controllo che il registro non sia gia' stato
  4159.             // registrata
  4160.             if (tipoOp.equals(TipoOperazione.ADD)) {
  4161.                 boolean giaRegistrato = this.porteDelegateCore.existsResponseCachingConfigurazioneRegola(idPorta,statusMin, statusMax, fault);

  4162.                 if (giaRegistrato) {
  4163.                     this.pd.setMessage("&Egrave; gi&agrave; presente una Regola di Response Caching con in parametri indicati.");
  4164.                     return false;
  4165.                 }
  4166.             }

  4167.             return true;

  4168.         } catch (Exception e) {
  4169.             this.logError(e.getMessage(), e);
  4170.             throw new ControlStationCoreException(e.getMessage(),e);
  4171.         }
  4172.     }
  4173.        
  4174.     public void preparePorteDelegateTrasformazioniRegolaList(String nomePorta, ISearch ricerca, List<TrasformazioneRegola> lista) throws Exception {
  4175.         try {
  4176.            
  4177.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  4178.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  4179.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  4180.            
  4181.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  4182.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  4183.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  4184.             if(idAsps == null)
  4185.                 idAsps = "";
  4186.            
  4187.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  4188.             if(idFruizione == null)
  4189.                 idFruizione = "";
  4190.            
  4191.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  4192.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  4193.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  4194.             Parameter pIdFruizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);
  4195.             Parameter pFromList = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_APPLICABILITA_LIST, "true");

  4196.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_TRASFORMAZIONI,
  4197.                     pId, pIdSoggetto, pIdAsps, pIdFruizione);

  4198.             int idLista = Liste.PORTE_DELEGATE_TRASFORMAZIONI;
  4199.             int limit = ricerca.getPageSize(idLista);
  4200.             int offset = ricerca.getIndexIniziale(idLista);

  4201.             this.pd.setIndex(offset);
  4202.             this.pd.setPageSize(limit);
  4203.             this.pd.setSearch("");
  4204.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  4205.             this.pd.setSearchDescription("");
  4206.            
  4207.             ServletUtils.disabledPageDataSearch(this.pd);

  4208.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  4209.             String idporta = myPD.getNome();
  4210.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome());
  4211.            
  4212.             // Prendo il nome e il tipo del servizio
  4213.             AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(idAsps));
  4214.             AccordoServizioParteComuneSintetico apc = this.apcCore.getAccordoServizioSintetico(asps.getIdAccordo());
  4215.             Map<String,String> azioni = this.porteApplicativeCore.getAzioniConLabel(asps, apc, false, true, new ArrayList<>());

  4216.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  4217.             boolean autenticazione = !TipoAutenticazione.DISABILITATO.equals(myPD.getAutenticazione());
  4218.            
  4219.             boolean autenticazioneToken = myPD.getGestioneToken()!=null && myPD.getGestioneToken().getPolicy()!=null;
  4220.            
  4221.             // setto la barra del titolo
  4222.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  4223.            
  4224.             // imposto menu' contestuale
  4225.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);
  4226.            
  4227.             String labelPerPorta = null;
  4228.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  4229.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  4230.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI,
  4231.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI,
  4232.                         myPD);
  4233.             }
  4234.             else {
  4235.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI+idporta;
  4236.             }
  4237.            
  4238.             lstParam.add(new Parameter(labelPerPorta,null));

  4239.             // setto la barra del titolo
  4240.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));

  4241.             // setto le label delle colonne
  4242.             String nomeColonnaAzione = null;
  4243.             if(org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(apc.getServiceBinding())) {
  4244.                 nomeColonnaAzione = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_RISORSE;
  4245.             }
  4246.             else {
  4247.                 nomeColonnaAzione = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_APPLICABILITA_AZIONI;
  4248.             }
  4249.            
  4250.            
  4251.             List<String> lstLabels = new ArrayList<>();
  4252.             if(lista != null && lista.size() > 1)
  4253.                 lstLabels.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_POSIZIONE);
  4254.             lstLabels.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_STATO);
  4255.             lstLabels.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_NOME);
  4256.             lstLabels.add(nomeColonnaAzione);
  4257.             lstLabels.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_APPLICABILITA_CT);
  4258.             lstLabels.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_APPLICABILITA_PATTERN);
  4259.             if(autenticazione || autenticazioneToken) {
  4260.                 lstLabels.add( PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVI);
  4261.             }
  4262.            
  4263.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  4264.             // preparo i dati
  4265.             List<List<DataElement>> dati = new ArrayList<>();

  4266.             if (lista != null) {
  4267.                 Iterator<TrasformazioneRegola> it = lista.iterator();
  4268.                 int numeroElementi = lista.size();
  4269.                 int i = 0;
  4270.                 while (it.hasNext()) {
  4271.                     TrasformazioneRegola regola = it.next();
  4272.                     Parameter pIdTrasformazione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE, regola.getId() + "");
  4273.                     List<DataElement> e = new ArrayList<>();
  4274.                    
  4275.                     // Posizione
  4276.                     if(lista.size() > 1) {
  4277.                         DataElement de = new DataElement();
  4278.                         de.setWidthPx(48);
  4279.                         de.setType(DataElementType.IMAGE);
  4280.                         DataElementImage imageUp = new DataElementImage();
  4281.                         Parameter pDirezioneSu = new Parameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_POSIZIONE,
  4282.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SU);
  4283.                         Parameter pDirezioneGiu = new Parameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_POSIZIONE,
  4284.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_GIU);
  4285.                                
  4286.                         if(i > 0) {
  4287.                             imageUp.setImage(CostantiControlStation.ICONA_FRECCIA_SU);
  4288.                             imageUp.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_SU);
  4289.                             imageUp.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_LIST,pId, pIdSoggetto, pIdAsps, pIdFruizione, pNomePorta,pIdTrasformazione, pDirezioneSu);
  4290.                         }
  4291.                         else {
  4292.                             imageUp.setImage(CostantiControlStation.ICONA_PLACEHOLDER);
  4293.                         }
  4294.                         de.addImage(imageUp);
  4295.                        
  4296.                         if(i < numeroElementi -1) {
  4297.                             DataElementImage imageDown = new DataElementImage();
  4298.                             imageDown.setImage(CostantiControlStation.ICONA_FRECCIA_GIU);
  4299.                             imageDown.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_GIU);
  4300.                             imageDown.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_LIST, pId, pIdSoggetto, pIdAsps, pIdFruizione, pNomePorta,pIdTrasformazione, pDirezioneGiu);
  4301.                             de.addImage(imageDown);
  4302.                         }
  4303.                         de.setValue(regola.getPosizione()+"");
  4304.                         e.add(de);
  4305.                     }
  4306.                    
  4307.                    
  4308.                     // Stato
  4309.                     DataElement de = new DataElement();
  4310.                     de.setWidthPx(10);
  4311.                     de.setType(DataElementType.CHECKBOX);
  4312.                     if(regola.getStato()==null // backward compatibility
  4313.                             ||
  4314.                             StatoFunzionalita.ABILITATO.equals(regola.getStato())){
  4315.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  4316.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_ABILITATO);
  4317.                         de.setSelected(CheckboxStatusType.CONFIG_ENABLE);
  4318.                     }
  4319.                     else{
  4320.                         de.setToolTip(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  4321.                         de.setValue(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_STATO_DISABILITATO);
  4322.                         de.setSelected(CheckboxStatusType.CONFIG_DISABLE);
  4323.                     }
  4324.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_CHANGE,
  4325.                             pId, pIdSoggetto, pIdAsps, pIdFruizione, pNomePorta, pIdTrasformazione
  4326.                             );
  4327.                     e.add(de);
  4328.                    
  4329.                     // Nome
  4330.                     de = new DataElement();
  4331.                     de.setIdToRemove(regola.getId() + "");
  4332.                     de.setValue(regola.getNome());
  4333.                     de.setToolTip(regola.getNome());
  4334.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_CHANGE,
  4335.                             pId, pIdSoggetto, pIdAsps, pIdFruizione, pNomePorta, pIdTrasformazione
  4336.                             );
  4337.                     e.add(de);
  4338.                    
  4339.                    
  4340.                     // Azioni
  4341.                     de = new DataElement();
  4342.                    
  4343.                     TrasformazioneRegolaApplicabilitaRichiesta applicabilita = regola.getApplicabilita();
  4344.                    
  4345.                     List<String> listaAzioni = applicabilita != null ? applicabilita.getAzioneList() : null;
  4346.                     String nomiAzioni = "";
  4347.                     if((listaAzioni != null && listaAzioni.size() > 0) && azioni.size()>0) {
  4348.                        
  4349.                         StringBuilder sb = new StringBuilder();
  4350.                         Iterator<String> itAz = azioni.keySet().iterator();
  4351.                         while (itAz.hasNext()) {
  4352.                             String idAzione = (String) itAz.next();
  4353.                             if(listaAzioni.contains(idAzione)) {
  4354.                                 if(sb.length() >0)
  4355.                                     sb.append(", ");
  4356.                                
  4357.                                 sb.append(azioni.get(idAzione));
  4358.                             }
  4359.                         }
  4360.                         nomiAzioni = sb.toString();
  4361.                     }
  4362.                    
  4363.                     if(StringUtils.isEmpty(nomiAzioni))
  4364.                         nomiAzioni = CostantiControlStation.LABEL_QUALSIASI;
  4365.                    
  4366.                     de.setValue(nomiAzioni);
  4367.                     de.setToolTip(nomiAzioni);
  4368.                     if(nomiAzioni!=null && nomiAzioni.length()>197) {
  4369.                         de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_CHANGE,
  4370.                                 pId, pIdSoggetto, pIdAsps, pIdFruizione, pNomePorta, pIdTrasformazione
  4371.                                 );
  4372.                     }
  4373.                     de.setSize(200);
  4374.                    
  4375.                     e.add(de);
  4376.                    

  4377.                                    
  4378.                     // Content-type
  4379.                    
  4380.                     String ct = "";
  4381.                     List<String> contentTypeList = applicabilita != null ? applicabilita.getContentTypeList() : null;
  4382.                     if(contentTypeList != null && contentTypeList.size() > 0) {
  4383.                         StringBuilder sb = new StringBuilder();
  4384.                         for (String string : contentTypeList) {
  4385.                             if(sb.length() >0)
  4386.                                 sb.append(", ");
  4387.                            
  4388.                             sb.append(string);
  4389.                         }
  4390.                         ct =sb.toString();
  4391.                     }
  4392.                    
  4393.                     if(StringUtils.isEmpty(ct))
  4394.                         ct = "&nbsp;";
  4395.                    
  4396.                    
  4397.                     de = new DataElement();
  4398.                     de.setValue(ct);
  4399.                     e.add(de);

  4400.                    
  4401.                     // Pattern
  4402.                     de = new DataElement();
  4403.                     String p = (applicabilita != null && applicabilita.getPattern() != null) ? applicabilita.getPattern() + "" : "&nbsp;";
  4404.                     de.setValue(p.length()>CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PATTERN_LIST_MAX_VALUE ?
  4405.                                 p.substring(0, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PATTERN_LIST_MAX_VALUE)+"..." :
  4406.                                 p);
  4407.                     e.add(de);
  4408.                    
  4409.                    
  4410.                     if(autenticazione || autenticazioneToken) {
  4411.                        
  4412.                         String servletTrasformazioniAutorizzazioneAutenticati =  PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_SERVIZIO_APPLICATIVO_LIST;
  4413.                         List<Parameter> parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati = new ArrayList<>();
  4414.                         parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati.add(pId);
  4415.                         parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati.add(pIdSoggetto);
  4416.                         parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati.add(pIdAsps);
  4417.                         parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati.add(pIdFruizione);
  4418.                         parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati.add(pIdTrasformazione);
  4419.                         parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati.add(pFromList);
  4420.                         int numAutenticati = applicabilita != null ? applicabilita.sizeServizioApplicativoList() : 0;
  4421.                        
  4422.                         de = new DataElement();
  4423.                         de.setUrl(servletTrasformazioniAutorizzazioneAutenticati, parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati.toArray(new Parameter[parametriInvocazioneServletTrasformazioniAutorizzazioneAutenticati.size()]));
  4424.                         String labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZI_APPLICATIVI;
  4425.                         if(!this.isModalitaCompleta()) {
  4426.                             labelApplicativi = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVI;
  4427.                         }
  4428.                         if (contaListe) {
  4429.                             ServletUtils.setDataElementCustomLabel(de,labelApplicativi,Long.valueOf(numAutenticati));
  4430.                         } else {
  4431.                             ServletUtils.setDataElementCustomLabel(de,labelApplicativi);
  4432.                         }
  4433.                         e.add(de);
  4434.                     }
  4435.                    
  4436.                    
  4437.                     dati.add(e);
  4438.                     i++;
  4439.                 }
  4440.             }

  4441.             this.pd.setDati(dati);
  4442.             this.pd.setAddButton(true);

  4443.         } catch (Exception e) {
  4444.             this.logError(e.getMessage(), e);
  4445.             throw new ControlStationCoreException(e.getMessage(),e);
  4446.         }
  4447.     }
  4448.    
  4449.     public void preparePorteDelegateTrasformazioniRispostaList(String nomePorta,  long idTrasformazione, ISearch ricerca, List<TrasformazioneRegolaRisposta> lista) throws Exception {
  4450.         try {
  4451.            
  4452.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  4453.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  4454.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  4455.            
  4456.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  4457.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  4458.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  4459.             if(idAsps == null)
  4460.                 idAsps = "";
  4461.            
  4462.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  4463.             if(idFruizione == null)
  4464.                 idFruizione = "";
  4465.            
  4466.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  4467.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  4468.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  4469.             Parameter pIdFruizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);
  4470.             Parameter pIdTrasformazione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE, idTrasformazione+"");
  4471.            
  4472.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA,
  4473.                     pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione);
  4474.            

  4475.             int idLista = Liste.PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTE;
  4476.             int limit = ricerca.getPageSize(idLista);
  4477.             int offset = ricerca.getIndexIniziale(idLista);

  4478.             this.pd.setIndex(offset);
  4479.             this.pd.setPageSize(limit);
  4480.             this.pd.setSearch("");
  4481.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  4482.             this.pd.setSearchDescription("");
  4483.            
  4484.             ServletUtils.disabledPageDataSearch(this.pd);

  4485.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  4486.             String idporta = myPD.getNome();
  4487. //          @SuppressWarnings("unused")
  4488. //          Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome());
  4489.            
  4490.             Trasformazioni trasformazioni = myPD.getTrasformazioni();
  4491.             TrasformazioneRegola oldRegola = null;
  4492.             for (TrasformazioneRegola reg : trasformazioni.getRegolaList()) {
  4493.                 if(reg.getId().longValue() == idTrasformazione) {
  4494.                     oldRegola = reg;
  4495.                     break;
  4496.                 }
  4497.             }
  4498.             if(oldRegola==null) {
  4499.                 throw new Exception("TrasformazioneRegola con id '"+idTrasformazione+"' non trovata");
  4500.             }
  4501.            
  4502.             String nomeTrasformazione = oldRegola.getNome();
  4503.            
  4504.             // setto la barra del titolo
  4505.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  4506.            
  4507.             String labelPerPorta = null;
  4508.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  4509.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  4510.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI,
  4511.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI,
  4512.                         myPD);
  4513.             }
  4514.             else {
  4515.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI+idporta;
  4516.             }
  4517.            
  4518.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_LIST,
  4519.                     pId, pIdSoggetto, pIdAsps, pIdFruizione));
  4520.            
  4521.            
  4522.             lstParam.add(new Parameter(nomeTrasformazione, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_CHANGE,
  4523.                     pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione));
  4524.            
  4525.             String labelPag = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTE;
  4526.            
  4527.             lstParam.add(new Parameter(labelPag,null));

  4528.             // setto la barra del titolo
  4529.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  4530.            
  4531.             // imposto menu' contestuale
  4532.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  4533.             // setto le label delle colonne
  4534.             List<String> lstLabels = new ArrayList<>();
  4535.             if(lista != null && lista.size() > 1)
  4536.                 lstLabels.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_POSIZIONE);
  4537.             lstLabels.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_NOME);
  4538.             lstLabels.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_STATUS);
  4539.             lstLabels.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_CT);
  4540.             lstLabels.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_APPLICABILITA_PATTERN);
  4541.            
  4542.             this.pd.setLabels(lstLabels.toArray(new String [lstLabels.size()]));

  4543.             // preparo i dati
  4544.             List<List<DataElement>> dati = new ArrayList<>();

  4545.             if (lista != null) {
  4546.                 Iterator<TrasformazioneRegolaRisposta> it = lista.iterator();
  4547.                 int numeroElementi = lista.size();
  4548.                 int i = 0;
  4549.                 while (it.hasNext()) {
  4550.                     TrasformazioneRegolaRisposta risposta = it.next();
  4551.                     Parameter pIdTrasformazioneRisposta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE_RISPOSTA, risposta.getId() + "");

  4552.                     List<DataElement> e = new ArrayList<>();
  4553.                    
  4554.                     // Posizione
  4555.                     if(lista.size() > 1) {
  4556.                         DataElement de = new DataElement();
  4557.                         de.setWidthPx(48);
  4558.                         de.setType(DataElementType.IMAGE);
  4559.                         DataElementImage imageUp = new DataElementImage();
  4560.                         Parameter pDirezioneSu = new Parameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_POSIZIONE,
  4561.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SU);
  4562.                         Parameter pDirezioneGiu = new Parameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_POSIZIONE,
  4563.                                 CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_POSIZIONE_GIU);
  4564.                                
  4565.                         if(i > 0) {
  4566.                             imageUp.setImage(CostantiControlStation.ICONA_FRECCIA_SU);
  4567.                             imageUp.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_SU);
  4568.                             imageUp.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_LIST, pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione, pIdTrasformazioneRisposta, pDirezioneSu);
  4569.                         }
  4570.                         else {
  4571.                             imageUp.setImage(CostantiControlStation.ICONA_PLACEHOLDER);
  4572.                         }
  4573.                         de.addImage(imageUp);
  4574.                        
  4575.                         if(i < numeroElementi -1) {
  4576.                             DataElementImage imageDown = new DataElementImage();
  4577.                             imageDown.setImage(CostantiControlStation.ICONA_FRECCIA_GIU);
  4578.                             imageDown.setToolTip(CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_POSIZIONE_SPOSTA_GIU);
  4579.                             imageDown.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_LIST, pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione, pIdTrasformazioneRisposta, pDirezioneGiu);
  4580.                             de.addImage(imageDown);
  4581.                         }
  4582.                         de.setValue(risposta.getPosizione()+"");
  4583.                         e.add(de);
  4584.                     }
  4585.                     // Nome
  4586.                     DataElement de = new DataElement();
  4587.                     de.setIdToRemove(risposta.getId() + "");
  4588.                     de.setValue(risposta.getNome());
  4589.                     de.setToolTip(risposta.getNome());
  4590.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_CHANGE,
  4591.                             pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione,
  4592.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE_RISPOSTA, risposta.getId() + "")
  4593.                             );
  4594.                     e.add(de);
  4595.                    
  4596.                    
  4597.                     // Status Code
  4598.                     de = new DataElement();
  4599.                    
  4600.                     TrasformazioneRegolaApplicabilitaRisposta applicabilita = risposta.getApplicabilita();
  4601.                    
  4602.                     Integer statusMin = applicabilita != null ? applicabilita.getReturnCodeMin() : null;
  4603.                     Integer statusMax = applicabilita != null ? applicabilita.getReturnCodeMax() : null;
  4604.                    
  4605.                     // se e' stato salvato il valore 0 lo tratto come null
  4606.                     if(statusMin != null && statusMin.intValue() <= 0) {
  4607.                         statusMin = null;
  4608.                     }
  4609.                    
  4610.                     if(statusMax != null && statusMax.intValue() <= 0) {
  4611.                         statusMax = null;
  4612.                     }
  4613.                    
  4614.                     String statusValue = null;
  4615.                     // Intervallo
  4616.                     if(statusMin != null && statusMax != null) {
  4617.                         if(statusMax.longValue() == statusMin.longValue()) // esatto
  4618.                             statusValue = statusMin + "";
  4619.                         else
  4620.                             statusValue = "[" + statusMin + " - " + statusMax + "]";
  4621.                     } else if(statusMin != null && statusMax == null) { // definito solo l'estremo inferiore
  4622.                         statusValue = "&gt;" + statusMin;
  4623.                     } else if(statusMin == null && statusMax != null) { // definito solo l'estremo superiore
  4624.                         statusValue = "&lt;" + statusMax;
  4625.                     } else { //entrambi null
  4626.                         statusValue = CostantiControlStation.LABEL_PARAMETRO_CONFIGURAZIONE_RETURN_CODE_QUALSIASI;
  4627.                     }
  4628.                    
  4629.                     de.setValue(statusValue);
  4630.                     e.add(de);
  4631.                    
  4632.                    
  4633.                     // Content-type
  4634.                     String ct = "";
  4635.                     List<String> contentTypeList = applicabilita != null ? applicabilita.getContentTypeList() : null;
  4636.                     if(contentTypeList != null && contentTypeList.size() > 0) {
  4637.                         StringBuilder sb = new StringBuilder();
  4638.                         for (String string : contentTypeList) {
  4639.                             if(sb.length() >0)
  4640.                                 sb.append(", ");
  4641.                            
  4642.                             sb.append(string);
  4643.                         }
  4644.                         ct =sb.toString();
  4645.                     }
  4646.                    
  4647.                     if(StringUtils.isEmpty(ct))
  4648.                         ct = "&nbsp;";
  4649.                                    
  4650.                     de = new DataElement();
  4651.                     de.setValue(ct);
  4652.                     e.add(de);

  4653.                    
  4654.                     // Pattern
  4655.                     de = new DataElement();
  4656.                     String p = (applicabilita != null && applicabilita.getPattern() != null) ? applicabilita.getPattern() + "" : "&nbsp;";
  4657.                     de.setValue(p.length()>CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PATTERN_LIST_MAX_VALUE ?
  4658.                                 p.substring(0, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_PATTERN_LIST_MAX_VALUE)+"..." :
  4659.                                 p);
  4660.                     e.add(de);
  4661.                    
  4662.                    
  4663.                     dati.add(e);
  4664.                     i++;
  4665.                 }
  4666.             }

  4667.             this.pd.setDati(dati);
  4668.             this.pd.setAddButton(true);

  4669.         } catch (Exception e) {
  4670.             this.logError(e.getMessage(), e);
  4671.             throw new ControlStationCoreException(e.getMessage(),e);
  4672.         }
  4673.     }
  4674.    
  4675.     public void preparePorteDelegateTrasformazioniRispostaHeaderList(String nomePorta,  long idTrasformazione, long idTrasformazioneRisposta,  ISearch ricerca, List<TrasformazioneRegolaParametro> lista) throws Exception {
  4676.         try {
  4677.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  4678.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  4679.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  4680.            
  4681.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  4682.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  4683.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  4684.             if(idAsps == null)
  4685.                 idAsps = "";
  4686.            
  4687.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  4688.             if(idFruizione == null)
  4689.                 idFruizione = "";
  4690.            
  4691.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  4692.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  4693.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  4694.             Parameter pIdFruizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);
  4695.             Parameter pIdTrasformazione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE, idTrasformazione+"");
  4696.             Parameter pIdTrasformazioneRisposta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE_RISPOSTA, idTrasformazioneRisposta + "");
  4697.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_HEADER,
  4698.                     pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione,pIdTrasformazioneRisposta);

  4699.             int idLista = Liste.PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTE_HEADER;
  4700.             int limit = ricerca.getPageSize(idLista);
  4701.             int offset = ricerca.getIndexIniziale(idLista);

  4702.             this.pd.setIndex(offset);
  4703.             this.pd.setPageSize(limit);
  4704.             this.pd.setSearch("");
  4705.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  4706.             this.pd.setSearchDescription("");
  4707.            
  4708.             ServletUtils.disabledPageDataSearch(this.pd);

  4709.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  4710.             String idporta = myPD.getNome();
  4711. //          @SuppressWarnings("unused")
  4712. //          Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome());
  4713.            
  4714.             Trasformazioni trasformazioni = myPD.getTrasformazioni();
  4715.             TrasformazioneRegola oldRegola = null;
  4716.             TrasformazioneRegolaRisposta oldRisposta = null;
  4717.             for (TrasformazioneRegola reg : trasformazioni.getRegolaList()) {
  4718.                 if(reg.getId().longValue() == idTrasformazione) {
  4719.                     oldRegola = reg;
  4720.                     break;
  4721.                 }
  4722.             }
  4723.             if(oldRegola==null) {
  4724.                 throw new Exception("TrasformazioneRegola con id '"+idTrasformazione+"' non trovata");
  4725.             }
  4726.            
  4727.             for (int j = 0; j < oldRegola.sizeRispostaList(); j++) {
  4728.                 TrasformazioneRegolaRisposta risposta = oldRegola.getRisposta(j);
  4729.                 if (risposta.getId().longValue() == idTrasformazioneRisposta) {
  4730.                     oldRisposta = risposta;
  4731.                     break;
  4732.                 }
  4733.             }
  4734.             if(oldRisposta==null) {
  4735.                 throw new Exception("TrasformazioneRegolaRisposta con id '"+idTrasformazioneRisposta+"' non trovata");
  4736.             }
  4737.            
  4738.             String nomeRisposta = oldRisposta.getNome();
  4739.             String nomeTrasformazione = oldRegola.getNome();
  4740.            
  4741.             // setto la barra del titolo
  4742.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  4743.            
  4744.             String labelPerPorta = null;
  4745.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  4746.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  4747.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI,
  4748.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI,
  4749.                         myPD);
  4750.             }
  4751.             else {
  4752.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI+idporta;
  4753.             }
  4754.            
  4755.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_LIST,
  4756.                     pId, pIdSoggetto, pIdAsps, pIdFruizione));
  4757.            
  4758.            
  4759.             lstParam.add(new Parameter(nomeTrasformazione, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_CHANGE,
  4760.                     pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione));
  4761.            
  4762.             List<Parameter> parametriInvocazioneServletTrasformazioniRisposta = new ArrayList<>();
  4763.             parametriInvocazioneServletTrasformazioniRisposta.add(pId);
  4764.             parametriInvocazioneServletTrasformazioniRisposta.add(pIdSoggetto);
  4765.             parametriInvocazioneServletTrasformazioniRisposta.add(pIdAsps);
  4766.             parametriInvocazioneServletTrasformazioniRisposta.add(pIdFruizione);
  4767.             parametriInvocazioneServletTrasformazioniRisposta.add(pIdTrasformazione);
  4768.            
  4769.             lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTE,PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_LIST,parametriInvocazioneServletTrasformazioniRisposta));
  4770.            
  4771.             lstParam.add(new Parameter(nomeRisposta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_CHANGE,
  4772.                     pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione,pIdTrasformazioneRisposta));
  4773.            
  4774.             String labelPag = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_HEADERS;
  4775.            
  4776.             lstParam.add(new Parameter(labelPag,null));

  4777.             // setto la barra del titolo
  4778.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  4779.            
  4780.             // imposto menu' contestuale
  4781.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  4782.             // setto le label delle colonne
  4783.             String[] labels = { PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_HEADER_NOME,
  4784.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_HEADER_TIPO,
  4785.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_HEADER_VALORE};
  4786.             this.pd.setLabels(labels);

  4787.             // preparo i dati
  4788.             List<List<DataElement>> dati = new ArrayList<>();

  4789.             if (lista != null) {
  4790.                 Iterator<TrasformazioneRegolaParametro> it = lista.iterator();
  4791.                 while (it.hasNext()) {
  4792.                     TrasformazioneRegolaParametro parametro = it.next();

  4793.                     List<DataElement> e = new ArrayList<>();
  4794.                    
  4795.                     // Nome
  4796.                     DataElement de = new DataElement();
  4797.                     de.setIdToRemove(parametro.getId() + "");
  4798.                     de.setValue(parametro.getNome());
  4799.                    
  4800.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RISPOSTA_HEADER_CHANGE,
  4801.                             pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione,
  4802.                             pIdTrasformazioneRisposta,
  4803.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE_RISPOSTA_HEADER, parametro.getId() + "")
  4804.                             );
  4805.                     e.add(de);
  4806.                    
  4807.                     // Tipo
  4808.                     de = new DataElement();
  4809.                     de.setValue(parametro.getConversioneTipo().getValue());
  4810.                     e.add(de);
  4811.                    
  4812.                     // Valore
  4813.                     de = new DataElement();
  4814.                     de.setValue(StringUtils.isNotEmpty(parametro.getValore()) ? this.formatInfoForView(parametro.getValore()) :  "&nbsp;" );
  4815.                     if(StringUtils.isNotEmpty(parametro.getValore())) {
  4816.                         de.setToolTip(parametro.getValore());
  4817.                     }
  4818.                     e.add(de);

  4819.                     dati.add(e);
  4820.                 }
  4821.             }

  4822.             this.pd.setDati(dati);
  4823.             this.pd.setAddButton(true);

  4824.         } catch (Exception e) {
  4825.             this.logError(e.getMessage(), e);
  4826.             throw new ControlStationCoreException(e.getMessage(),e);
  4827.         }
  4828.     }
  4829.    
  4830.     public void preparePorteDelegateTrasformazioniRichiestaHeaderList(String nomePorta,  long idTrasformazione, ISearch ricerca, List<TrasformazioneRegolaParametro> lista) throws Exception {
  4831.         try {
  4832.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  4833.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  4834.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  4835.            
  4836.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  4837.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  4838.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  4839.             if(idAsps == null)
  4840.                 idAsps = "";
  4841.            
  4842.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  4843.             if(idFruizione == null)
  4844.                 idFruizione = "";
  4845.            
  4846.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  4847.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  4848.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  4849.             Parameter pIdFruizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);
  4850.             Parameter pIdTrasformazione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE, idTrasformazione+"");
  4851.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_HEADER,
  4852.                     pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione);

  4853.             int idLista = Liste.PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_HEADER;
  4854.             int limit = ricerca.getPageSize(idLista);
  4855.             int offset = ricerca.getIndexIniziale(idLista);

  4856.             this.pd.setIndex(offset);
  4857.             this.pd.setPageSize(limit);
  4858.             this.pd.setSearch("");
  4859.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  4860.             this.pd.setSearchDescription("");
  4861.            
  4862.             ServletUtils.disabledPageDataSearch(this.pd);

  4863.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  4864.             String idporta = myPD.getNome();
  4865. //          @SuppressWarnings("unused")
  4866. //          Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome());
  4867.            
  4868.             Trasformazioni trasformazioni = myPD.getTrasformazioni();
  4869.             TrasformazioneRegola oldRegola = null;
  4870.             for (TrasformazioneRegola reg : trasformazioni.getRegolaList()) {
  4871.                 if(reg.getId().longValue() == idTrasformazione) {
  4872.                     oldRegola = reg;
  4873.                     break;
  4874.                 }
  4875.             }
  4876.             if(oldRegola==null) {
  4877.                 throw new Exception("TrasformazioneRegola con id '"+idTrasformazione+"' non trovata");
  4878.             }
  4879.            
  4880.             String nomeTrasformazione = oldRegola.getNome();
  4881.            
  4882.             // setto la barra del titolo
  4883.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  4884.            
  4885.             String labelPerPorta = null;
  4886.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  4887.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  4888.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI,
  4889.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI,
  4890.                         myPD);
  4891.             }
  4892.             else {
  4893.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI+idporta;
  4894.             }
  4895.            
  4896.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_LIST,
  4897.                     pId, pIdSoggetto, pIdAsps, pIdFruizione));
  4898.            
  4899.            
  4900.             lstParam.add(new Parameter(nomeTrasformazione, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_CHANGE,
  4901.                     pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione));
  4902.            
  4903.             List<Parameter> parametriInvocazioneServletTrasformazioniRichiesta = new ArrayList<>();
  4904.             parametriInvocazioneServletTrasformazioniRichiesta.add(pId);
  4905.             parametriInvocazioneServletTrasformazioniRichiesta.add(pIdSoggetto);
  4906.             parametriInvocazioneServletTrasformazioniRichiesta.add(pIdAsps);
  4907.             parametriInvocazioneServletTrasformazioniRichiesta.add(pIdFruizione);
  4908.             parametriInvocazioneServletTrasformazioniRichiesta.add(pIdTrasformazione);
  4909.            
  4910.             lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA,
  4911.                     PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA,parametriInvocazioneServletTrasformazioniRichiesta));
  4912.            
  4913.             String labelPag = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_HEADERS;
  4914.            
  4915.             lstParam.add(new Parameter(labelPag,null));

  4916.             // setto la barra del titolo
  4917.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  4918.            
  4919.             // imposto menu' contestuale
  4920.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  4921.             // setto le label delle colonne
  4922.             String[] labels = { PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_HEADER_NOME,
  4923.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_HEADER_TIPO,
  4924.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_HEADER_VALORE};
  4925.             this.pd.setLabels(labels);

  4926.             // preparo i dati
  4927.             List<List<DataElement>> dati = new ArrayList<>();

  4928.             if (lista != null) {
  4929.                 Iterator<TrasformazioneRegolaParametro> it = lista.iterator();
  4930.                 while (it.hasNext()) {
  4931.                     TrasformazioneRegolaParametro parametro = it.next();

  4932.                     List<DataElement> e = new ArrayList<>();
  4933.                    
  4934.                     // Nome
  4935.                     DataElement de = new DataElement();
  4936.                     de.setIdToRemove(parametro.getId() + "");
  4937.                     de.setValue(parametro.getNome());
  4938.                    
  4939.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_HEADER_CHANGE,
  4940.                             pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione,
  4941.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE_RICHIESTA_HEADER, parametro.getId() + "")
  4942.                             );
  4943.                     e.add(de);
  4944.                    
  4945.                     // Tipo
  4946.                     de = new DataElement();
  4947.                     de.setValue(parametro.getConversioneTipo().getValue());
  4948.                     e.add(de);
  4949.                    
  4950.                     // Valore
  4951.                     de = new DataElement();
  4952.                     de.setValue(StringUtils.isNotEmpty(parametro.getValore()) ? this.formatInfoForView(parametro.getValore()) :  "&nbsp;" );
  4953.                     if(StringUtils.isNotEmpty(parametro.getValore())) {
  4954.                         de.setToolTip(parametro.getValore());
  4955.                     }
  4956.                     e.add(de);

  4957.                     dati.add(e);
  4958.                 }
  4959.             }

  4960.             this.pd.setDati(dati);
  4961.             this.pd.setAddButton(true);

  4962.         } catch (Exception e) {
  4963.             this.logError(e.getMessage(), e);
  4964.             throw new ControlStationCoreException(e.getMessage(),e);
  4965.         }
  4966.     }
  4967.    
  4968.     public void preparePorteDelegateTrasformazioniRichiestaUrlParameterList(String nomePorta,  long idTrasformazione, ISearch ricerca, List<TrasformazioneRegolaParametro> lista) throws Exception {
  4969.         try {
  4970.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  4971.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  4972.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  4973.            
  4974.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  4975.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  4976.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  4977.             if(idAsps == null)
  4978.                 idAsps = "";
  4979.            
  4980.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  4981.             if(idFruizione == null)
  4982.                 idFruizione = "";
  4983.            
  4984.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  4985.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  4986.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  4987.             Parameter pIdFruizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);
  4988.             Parameter pIdTrasformazione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE, idTrasformazione+"");
  4989.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_PARAMETRO,
  4990.                     pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione);

  4991.             int idLista = Liste.PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_PARAMETRI;
  4992.             int limit = ricerca.getPageSize(idLista);
  4993.             int offset = ricerca.getIndexIniziale(idLista);

  4994.             this.pd.setIndex(offset);
  4995.             this.pd.setPageSize(limit);
  4996.             this.pd.setSearch("");
  4997.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  4998.             this.pd.setSearchDescription("");
  4999.            
  5000.             ServletUtils.disabledPageDataSearch(this.pd);

  5001.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  5002.             String idporta = myPD.getNome();
  5003. //          @SuppressWarnings("unused")
  5004. //          Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome());
  5005.            
  5006.             Trasformazioni trasformazioni = myPD.getTrasformazioni();
  5007.             TrasformazioneRegola oldRegola = null;
  5008.             for (TrasformazioneRegola reg : trasformazioni.getRegolaList()) {
  5009.                 if(reg.getId().longValue() == idTrasformazione) {
  5010.                     oldRegola = reg;
  5011.                     break;
  5012.                 }
  5013.             }
  5014.             if(oldRegola==null) {
  5015.                 throw new Exception("TrasformazioneRegola con id '"+idTrasformazione+"' non trovata");
  5016.             }
  5017.            
  5018.             String nomeTrasformazione = oldRegola.getNome();
  5019.            
  5020.             // setto la barra del titolo
  5021.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  5022.            
  5023.             String labelPerPorta = null;
  5024.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  5025.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  5026.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI,
  5027.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI,
  5028.                         myPD);
  5029.             }
  5030.             else {
  5031.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI+idporta;
  5032.             }
  5033.            
  5034.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_LIST,
  5035.                     pId, pIdSoggetto, pIdAsps, pIdFruizione));
  5036.            
  5037.            
  5038.             lstParam.add(new Parameter(nomeTrasformazione, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_CHANGE,
  5039.                     pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione));
  5040.            
  5041.             List<Parameter> parametriInvocazioneServletTrasformazioniRichiesta = new ArrayList<>();
  5042.             parametriInvocazioneServletTrasformazioniRichiesta.add(pId);
  5043.             parametriInvocazioneServletTrasformazioniRichiesta.add(pIdSoggetto);
  5044.             parametriInvocazioneServletTrasformazioniRichiesta.add(pIdAsps);
  5045.             parametriInvocazioneServletTrasformazioniRichiesta.add(pIdFruizione);
  5046.             parametriInvocazioneServletTrasformazioniRichiesta.add(pIdTrasformazione);
  5047.            
  5048.             lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA,
  5049.                     PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA,parametriInvocazioneServletTrasformazioniRichiesta));
  5050.            
  5051.             String labelPag = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_PARAMETRI;
  5052.            
  5053.             lstParam.add(new Parameter(labelPag,null));

  5054.             // setto la barra del titolo
  5055.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  5056.            
  5057.             // imposto menu' contestuale
  5058.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  5059.             // setto le label delle colonne
  5060.             String[] labels = { PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_NOME,
  5061.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_TIPO,
  5062.                     PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_VALORE};
  5063.             this.pd.setLabels(labels);

  5064.             // preparo i dati
  5065.             List<List<DataElement>> dati = new ArrayList<>();

  5066.             if (lista != null) {
  5067.                 Iterator<TrasformazioneRegolaParametro> it = lista.iterator();
  5068.                 while (it.hasNext()) {
  5069.                     TrasformazioneRegolaParametro parametro = it.next();

  5070.                     List<DataElement> e = new ArrayList<>();
  5071.                    
  5072.                     // Nome
  5073.                     DataElement de = new DataElement();
  5074.                     de.setIdToRemove(parametro.getId() + "");
  5075.                     de.setValue(parametro.getNome());
  5076.                    
  5077.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_CHANGE,
  5078.                             pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione,
  5079.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE_RICHIESTA_PARAMETRO, parametro.getId() + "")
  5080.                             );
  5081.                     e.add(de);
  5082.                    
  5083.                     // Tipo
  5084.                     de = new DataElement();
  5085.                     de.setValue(parametro.getConversioneTipo().getValue());
  5086.                     e.add(de);
  5087.                    
  5088.                     // Valore
  5089.                     de = new DataElement();
  5090.                     de.setValue(StringUtils.isNotEmpty(parametro.getValore()) ? this.formatInfoForView(parametro.getValore()) :  "&nbsp;" );
  5091.                     if(StringUtils.isNotEmpty(parametro.getValore())) {
  5092.                         de.setToolTip(parametro.getValore());
  5093.                     }
  5094.                     e.add(de);

  5095.                     dati.add(e);
  5096.                 }
  5097.             }

  5098.             this.pd.setDati(dati);
  5099.             this.pd.setAddButton(true);

  5100.         } catch (Exception e) {
  5101.             this.logError(e.getMessage(), e);
  5102.             throw new ControlStationCoreException(e.getMessage(),e);
  5103.         }
  5104.     }
  5105.    
  5106.    
  5107.     // Prepara la lista di sil delle porte delegate
  5108.     public void preparePorteDelegateTrasformazioniServizioApplicativoList(String nomePorta, long idTrasformazione, ISearch ricerca, List<TrasformazioneRegolaApplicabilitaServizioApplicativo> lista)
  5109.             throws Exception {
  5110.         try {
  5111.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  5112.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  5113.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  5114.            
  5115.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  5116.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  5117.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  5118.             if(idAsps == null)
  5119.                 idAsps = "";
  5120.            
  5121.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  5122.             if(idFruizione == null)
  5123.                 idFruizione = "";
  5124.            
  5125.             String listaTmp = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_APPLICABILITA_LIST);
  5126.             boolean fromList = false;
  5127.             if(listaTmp != null && !"".equals(listaTmp))
  5128.                 fromList = true;
  5129.            
  5130.            
  5131.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  5132.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  5133.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  5134.             Parameter pIdFruizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);
  5135.             Parameter pIdTrasformazione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE, idTrasformazione+"");
  5136.            
  5137.             List<Parameter> parameters = new ArrayList<>();
  5138.             parameters.add(pId);
  5139.             parameters.add(pIdSoggetto);
  5140.             parameters.add(pIdAsps);
  5141.             parameters.add(pIdFruizione);
  5142.             parameters.add(pIdTrasformazione);
  5143.             if(fromList) {
  5144.                 parameters.add(new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_APPLICABILITA_LIST, listaTmp));
  5145.             }
  5146.            
  5147.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_TRASFORMAZIONI_SERVIZIO_APPLICATIVO,
  5148.                     parameters);

  5149.             int idLista = Liste.PORTE_DELEGATE_TRASFORMAZIONI_SERVIZIO_APPLICATIVO;
  5150.             int limit = ricerca.getPageSize(idLista);
  5151.             int offset = ricerca.getIndexIniziale(idLista);
  5152.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  5153.             this.pd.setIndex(offset);
  5154.             this.pd.setPageSize(limit);
  5155.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  5156.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  5157.             String idporta = myPD.getNome();
  5158.            
  5159.             Trasformazioni trasformazioni = myPD.getTrasformazioni();
  5160.             TrasformazioneRegola oldRegola = null;
  5161.             for (TrasformazioneRegola reg : trasformazioni.getRegolaList()) {
  5162.                 if(reg.getId().longValue() == idTrasformazione) {
  5163.                     oldRegola = reg;
  5164.                     break;
  5165.                 }
  5166.             }
  5167.             if(oldRegola==null) {
  5168.                 throw new Exception("TrasformazioneRegola con id '"+idTrasformazione+"' non trovata");
  5169.             }
  5170.            
  5171.             String nomeTrasformazione = oldRegola.getNome();
  5172.            
  5173.             // setto la barra del titolo
  5174.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  5175.            
  5176.             String labelPerPorta = null;
  5177.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  5178.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  5179.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI,
  5180.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI,
  5181.                         myPD);
  5182.             }
  5183.             else {
  5184.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI_DI+idporta;
  5185.             }
  5186.            
  5187.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_LIST,
  5188.                     pId, pIdSoggetto, pIdAsps, pIdFruizione));
  5189.            
  5190.             if(!fromList) {
  5191.                 lstParam.add(new Parameter(nomeTrasformazione, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_CHANGE,
  5192.                         pId, pIdSoggetto, pIdAsps, pIdFruizione, pIdTrasformazione));
  5193.             }
  5194.            
  5195.             String labelPagLista = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZIO_APPLICATIVO_CONFIG;
  5196.             if(!this.isModalitaCompleta()) {
  5197.                 labelPagLista = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVO_CONFIG;
  5198.             }
  5199.            
  5200.             this.pd.setSearchLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  5201.             if(search.equals("")){
  5202.                 this.pd.setSearchDescription("");
  5203.                 lstParam.add(new Parameter(labelPagLista,null));
  5204.             }
  5205.             else{
  5206.                 lstParam.add(new Parameter(labelPagLista,
  5207.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_SERVIZIO_APPLICATIVO_LIST, pId, pIdSoggetto, pIdAsps, pIdFruizione    ));
  5208.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));
  5209.             }

  5210.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  5211.            
  5212.             // imposto menu' contestuale
  5213.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  5214.             // controllo eventuali risultati ricerca
  5215.             if (!search.equals("")) {
  5216.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZI_APPLICATIVI, search);
  5217.             }

  5218.             // setto le label delle colonne
  5219.             String[] labels = new String[1];
  5220.             if(this.isModalitaCompleta()) {
  5221.                 labels[0] = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZIO_APPLICATIVO;
  5222.             }
  5223.             else {
  5224.                 labels[0] = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_APPLICATIVO;
  5225.             }
  5226.             this.pd.setLabels(labels);

  5227.             // preparo i dati
  5228.             List<List<DataElement>> dati = new ArrayList<>();

  5229.             if (lista != null) {
  5230.                 Iterator<TrasformazioneRegolaApplicabilitaServizioApplicativo> it = lista.iterator();
  5231.                 while (it.hasNext()) {
  5232.                     TrasformazioneRegolaApplicabilitaServizioApplicativo sa = it.next();

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

  5234.                     DataElement de = new DataElement();
  5235.                     if(this.isModalitaCompleta()) {
  5236.                         de.setUrl(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_CHANGE,
  5237.                                 new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID, sa.getId() + ""),
  5238.                                 new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_PROVIDER, idsogg));
  5239.                     }
  5240.                     de.setValue(sa.getNome());
  5241.                     de.setIdToRemove(sa.getNome());
  5242.                     e.add(de);

  5243.                     dati.add(e);
  5244.                 }
  5245.             }

  5246.             this.pd.setDati(dati);
  5247.             this.pd.setAddButton(true);

  5248.         } catch (Exception e) {
  5249.             this.logError(e.getMessage(), e);
  5250.             throw new ControlStationCoreException(e.getMessage(),e);
  5251.         }
  5252.     }
  5253.    
  5254.     // Controlla i dati del servizioApplicativo della porta delegata
  5255.     public boolean porteDelegateTrasformazioniServizioApplicativoCheckData(TipoOperazione tipoOp)
  5256.             throws Exception {
  5257.         try {
  5258.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  5259.             int idInt = Integer.parseInt(id);
  5260.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  5261.             int soggInt = Integer.parseInt(idsogg);
  5262.             String servizioApplicativo = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_SERVIZIO_APPLICATIVO);
  5263.             String idTrasformazioneS = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_TRASFORMAZIONE);
  5264.             long idTrasformazione = Long.parseLong(idTrasformazioneS);
  5265.            
  5266.             // Campi obbligatori
  5267.             if (servizioApplicativo.equals("")) {
  5268.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare un Servizio Applicativo");
  5269.                 return false;
  5270.             }

  5271.             // Controllo che il servizioApplicativo appartenga alla lista di
  5272.             // servizioApplicativo disponibili per il soggetto
  5273.             boolean trovatoServizioApplicativo = false;

  5274.             // Prendo il nome e il tipo del soggetto
  5275.             String nomeprov = null;
  5276.             String tipoprov = null;
  5277.             if(this.core.isRegistroServiziLocale()){
  5278.                 Soggetto mySogg = this.soggettiCore.getSoggettoRegistro(soggInt);
  5279.                 nomeprov = mySogg.getNome();
  5280.                 tipoprov = mySogg.getTipo();
  5281.             }else{
  5282.                 org.openspcoop2.core.config.Soggetto mySogg = this.soggettiCore.getSoggetto(soggInt);
  5283.                 nomeprov = mySogg.getNome();
  5284.                 tipoprov = mySogg.getTipo();
  5285.             }

  5286.             IDSoggetto ids = new IDSoggetto(tipoprov, nomeprov);
  5287.             IDServizioApplicativo idSA = new IDServizioApplicativo();
  5288.             idSA.setIdSoggettoProprietario(ids);
  5289.             idSA.setNome(servizioApplicativo);
  5290.             trovatoServizioApplicativo = this.saCore.existsServizioApplicativo(idSA);
  5291.             if (!trovatoServizioApplicativo) {
  5292.                 this.pd.setMessage("Il Servizio Applicativo dev'essere scelto tra quelli definiti nel pannello Servizi Applicativi ed associati al soggetto " + tipoprov + "/" + nomeprov);
  5293.                 return false;
  5294.             }

  5295.             // Se tipoOp = add, controllo che il servizioApplicativo non sia
  5296.             // gia'
  5297.             // stato
  5298.             // registrato per la porta delegata
  5299.             if (tipoOp.equals(TipoOperazione.ADD)) {
  5300.                 boolean giaRegistrato = false;

  5301.                 // Prendo il nome della porta delegata
  5302.                 PortaDelegata pde = this.porteDelegateCore.getPortaDelegata(idInt);
  5303.                
  5304.                
  5305.                 Trasformazioni trasformazioni = pde.getTrasformazioni();
  5306.                 TrasformazioneRegola regola = null;
  5307.                 for (int j = 0; j < trasformazioni.sizeRegolaList(); j++) {
  5308.                     TrasformazioneRegola regolaTmp = trasformazioni.getRegola(j);
  5309.                     if (regolaTmp.getId().longValue() == idTrasformazione) {
  5310.                         regola = regolaTmp;
  5311.                         break;
  5312.                     }
  5313.                 }
  5314.                 if(regola==null) {
  5315.                     throw new Exception("TrasformazioneRegola con id '"+idTrasformazione+"' non trovata");
  5316.                 }

  5317.                 String nometrasformazione = regola.getNome();
  5318.                
  5319.                 if(regola.getApplicabilita() != null) {
  5320.                     for (int i = 0; i < regola.getApplicabilita().sizeServizioApplicativoList(); i++) {
  5321.                         TrasformazioneRegolaApplicabilitaServizioApplicativo tmpSA = regola.getApplicabilita().getServizioApplicativo(i);
  5322.                         if (servizioApplicativo.equals(tmpSA.getNome())) {
  5323.                             giaRegistrato = true;
  5324.                             break;
  5325.                         }
  5326.                     }
  5327.                 }

  5328.                 if (giaRegistrato) {
  5329.                     this.pd.setMessage("Il Servizio Applicativo " + servizioApplicativo + " &egrave; gi&agrave; stato associato alla trasformazione " + nometrasformazione);
  5330.                     return false;
  5331.                 }
  5332.             }

  5333.             return true;
  5334.         } catch (Exception e) {
  5335.             this.logError(e.getMessage(), e);
  5336.             throw new ControlStationCoreException(e.getMessage(),e);
  5337.         }
  5338.     }
  5339.    
  5340.     public void preparePorteDelegateAutorizzazioneCustomPropList(String nomePorta, ConsoleSearch ricerca, List<Proprieta> lista) throws Exception {
  5341.         try {
  5342.             if(nomePorta!=null) {
  5343.                 // nop
  5344.             }
  5345.            
  5346.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  5347.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  5348.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  5349.            
  5350.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  5351.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  5352.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  5353.             if(idAsps == null)
  5354.                 idAsps = "";
  5355.            
  5356.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  5357.             if(idFruizione == null)
  5358.                 idFruizione = "";
  5359.            
  5360.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  5361.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  5362.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  5363.             Parameter pIdFruizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  5364.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_AUTORIZZAZIONE_CUSTOM_PROPERTIES, pId, pIdSoggetto, pIdAsps, pIdFruizione);

  5365.             int idLista = Liste.PORTE_DELEGATE_PROPRIETA_AUTORIZZAZIONE;
  5366.             int limit = ricerca.getPageSize(idLista);
  5367.             int offset = ricerca.getIndexIniziale(idLista);
  5368.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  5369.             this.pd.setIndex(offset);
  5370.             this.pd.setPageSize(limit);
  5371.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  5372.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  5373.             String idporta = myPD.getNome();

  5374.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  5375.            
  5376.             String labelPerPorta = null;
  5377.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  5378.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  5379.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI,
  5380.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  5381.                         myPD);
  5382.             }
  5383.             else {
  5384.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI+idporta;
  5385.             }
  5386.            
  5387.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  5388.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + myPD.getId()),
  5389.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome()),
  5390.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, myPD.getIdSoggetto() + ""),
  5391.                     pIdAsps, new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione+ "")));
  5392.            
  5393.             String labelPagLista = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_AUTORIZZAZIONE_PROPRIETA;

  5394.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);

  5395.             this.pd.setSearchLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  5396.             if(search.equals("")){
  5397.                 this.pd.setSearchDescription("");
  5398.                 lstParam.add(new Parameter(labelPagLista,null));
  5399.             }
  5400.             else{
  5401.                 lstParam.add(new Parameter(labelPagLista,
  5402.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_AUTORIZZAZIONE_CUSTOM_PROPERTIES_LIST, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFruizione    ));
  5403.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));

  5404.             }

  5405.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  5406.            
  5407.             // imposto menu' contestuale
  5408.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  5409.             // controllo eventuali risultati ricerca
  5410.             if (!search.equals("")) {
  5411.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_AUTORIZZAZIONE_PROPRIETA, search);
  5412.             }
  5413.            
  5414.             // setto le label delle colonne
  5415.             String valueLabel = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  5416.             String[] labels = { PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME, valueLabel };
  5417.             this.pd.setLabels(labels);
  5418.            
  5419.             // preparo i dati
  5420.             List<List<DataElement>> dati = new ArrayList<>();

  5421.             if (lista != null) {
  5422.                 Iterator<Proprieta> it = lista.iterator();
  5423.                 while (it.hasNext()) {
  5424.                     Proprieta ssp = it.next();

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

  5426.                     DataElement de = new DataElement();
  5427.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_AUTORIZZAZIONE_CUSTOM_PROPERTIES_CHANGE, pId,pIdSoggetto, pIdAsps, pIdFruizione, new Parameter( PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, ssp.getNome()));
  5428.                     de.setValue(ssp.getNome());
  5429.                     de.setIdToRemove(ssp.getId()+"");
  5430.                     de.setSize(CostantiControlStation.NOME_PROPRIETA_VISUALIZZATA);
  5431.                     e.add(de);

  5432.                     de = new DataElement();
  5433.                     if(StringUtils.isNotEmpty(ssp.getValore()) &&
  5434.                             BYOKManager.isEnabledBYOK() &&
  5435.                             this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(ssp.getValore())) {
  5436.                         de.setValue(CostantiControlStation.VALORE_CIFRATO);
  5437.                     }
  5438.                     else {
  5439.                         de.setValue(ssp.getValore());
  5440.                     }
  5441.                     e.add(de);

  5442.                     dati.add(e);
  5443.                 }
  5444.             }

  5445.             this.pd.setDati(dati);
  5446.             this.pd.setAddButton(true);

  5447.         } catch (Exception e) {
  5448.             this.logError(e.getMessage(), e);
  5449.             throw new ControlStationCoreException(e.getMessage(),e);
  5450.         }
  5451.     }

  5452.     public boolean proprietaAutorizzazioneCheckData(TipoOperazione tipoOp, String idPorta, String nome, String valore ) throws ControlStationCoreException {
  5453.         try {
  5454.             int idInt = Integer.parseInt(idPorta);

  5455.             // Campi obbligatori
  5456.             if (nome.equals("") || valore.equals("")) {
  5457.                 String tmpElenco = "";
  5458.                 if (nome.equals("")) {
  5459.                     tmpElenco = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME;
  5460.                 }
  5461.                 if (valore.equals("")) {
  5462.                     if (tmpElenco.equals("")) {
  5463.                         tmpElenco = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  5464.                     } else {
  5465.                         tmpElenco = tmpElenco + ", " + PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  5466.                     }
  5467.                 }
  5468.                 this.pd.setMessage(MessageFormat.format(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, tmpElenco));
  5469.                 return false;
  5470.             }

  5471.             if (nome.indexOf(" ") != -1) {
  5472.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_CAMPI_DI_TESTO);
  5473.                 return false;
  5474.             }
  5475.             if(!this.checkLength255(nome, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME)) {
  5476.                 return false;
  5477.             }
  5478.            
  5479.             if( !this.core.getDriverBYOKUtilities().isEnabledBYOK() || !this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(valore) ){
  5480.                 if (valore.indexOf(" ") != -1) {
  5481.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_CAMPI_DI_TESTO);
  5482.                     return false;
  5483.                 }
  5484.                 if(!this.checkLength255(valore, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE)) {
  5485.                     return false;
  5486.                 }
  5487.             }

  5488.             // Se tipoOp = add, controllo che la property non sia gia'
  5489.             // stata
  5490.             // registrata per la porta applicativa
  5491.             if (tipoOp.equals(TipoOperazione.ADD)) {
  5492.                 boolean giaRegistrato = false;
  5493.                 PortaDelegata portaDelegata = this.porteDelegateCore.getPortaDelegata(idInt);
  5494.                 String nomeporta = portaDelegata.getNome();

  5495.                 for (int i = 0; i < portaDelegata.sizeProprietaAutorizzazioneList(); i++) {
  5496.                     Proprieta tmpProp = portaDelegata.getProprietaAutorizzazione(i);
  5497.                     if (nome.equals(tmpProp.getNome())) {
  5498.                         giaRegistrato = true;
  5499.                         break;
  5500.                     }
  5501.                 }

  5502.                 if (giaRegistrato) {
  5503.                     Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  5504.                     if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  5505.                     if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  5506.                         nomeporta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(null , null, portaDelegata);
  5507.                         this.pd.setMessage(MessageFormat.format(
  5508.                                 PorteDelegateCostanti.MESSAGGIO_ERRORE_LA_PROPERTY_XX_E_GIA_STATA_ASSOCIATA_ALLA_CONFIGURAZIONE_YY, nome,
  5509.                                 nomeporta));
  5510.                     }
  5511.                     else {
  5512.                         this.pd.setMessage(MessageFormat.format(
  5513.                                 PorteDelegateCostanti.MESSAGGIO_ERRORE_LA_PROPERTY_XX_E_GIA_STATA_ASSOCIATA_ALLA_PORTA_DELEGATA_YY, nome,
  5514.                                 nomeporta));
  5515.                     }
  5516.                    
  5517.                    
  5518.                     return false;
  5519.                 }
  5520.             }

  5521.             return true;
  5522.         } catch (Exception e) {
  5523.             this.logError(e.getMessage(), e);
  5524.             throw new ControlStationCoreException(e.getMessage(),e);
  5525.         }
  5526.     }
  5527.    
  5528.     public void preparePorteDelegateAutorizzazioneContenutoCustomPropList(String nomePorta, ConsoleSearch ricerca, List<Proprieta> lista) throws Exception {
  5529.         try {
  5530.             if(nomePorta!=null) {
  5531.                 // nop
  5532.             }
  5533.            
  5534.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  5535.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  5536.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  5537.            
  5538.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  5539.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  5540.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  5541.             if(idAsps == null)
  5542.                 idAsps = "";
  5543.            
  5544.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  5545.             if(idFruizione == null)
  5546.                 idFruizione = "";
  5547.            
  5548.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  5549.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  5550.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  5551.             Parameter pIdFruizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  5552.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_AUTORIZZAZIONE_CONTENUTI_CUSTOM_PROPERTIES, pId, pIdSoggetto, pIdAsps, pIdFruizione);

  5553.             int idLista = Liste.PORTE_DELEGATE_PROPRIETA_AUTORIZZAZIONE_CONTENUTO;
  5554.             int limit = ricerca.getPageSize(idLista);
  5555.             int offset = ricerca.getIndexIniziale(idLista);
  5556.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  5557.             this.pd.setIndex(offset);
  5558.             this.pd.setPageSize(limit);
  5559.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  5560.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  5561.             String idporta = myPD.getNome();

  5562.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  5563.            
  5564.             String labelPerPorta = null;
  5565.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  5566.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  5567.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI,
  5568.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  5569.                         myPD);
  5570.             }
  5571.             else {
  5572.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI+idporta;
  5573.             }
  5574.            
  5575.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  5576.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + myPD.getId()),
  5577.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome()),
  5578.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, myPD.getIdSoggetto() + ""),
  5579.                     pIdAsps, new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione+ "")));
  5580.            
  5581.             String labelPagLista = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_AUTORIZZAZIONE_CONTENUTO_PROPRIETA;

  5582.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);

  5583.             this.pd.setSearchLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  5584.             if(search.equals("")){
  5585.                 this.pd.setSearchDescription("");
  5586.                 lstParam.add(new Parameter(labelPagLista,null));
  5587.             }
  5588.             else{
  5589.                 lstParam.add(new Parameter(labelPagLista,
  5590.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_AUTORIZZAZIONE_CONTENUTI_CUSTOM_PROPERTIES_LIST, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFruizione  ));
  5591.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));

  5592.             }

  5593.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  5594.            
  5595.             // imposto menu' contestuale
  5596.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);

  5597.             // controllo eventuali risultati ricerca
  5598.             if (!search.equals("")) {
  5599.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_AUTORIZZAZIONE_CONTENUTO_PROPRIETA, search);
  5600.             }
  5601.            
  5602.             // setto le label delle colonne
  5603.             String valueLabel = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  5604.             String[] labels = { PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME, valueLabel };
  5605.             this.pd.setLabels(labels);
  5606.            
  5607.             // preparo i dati
  5608.             List<List<DataElement>> dati = new ArrayList<>();

  5609.             if (lista != null) {
  5610.                 Iterator<Proprieta> it = lista.iterator();
  5611.                 while (it.hasNext()) {
  5612.                     Proprieta ssp = it.next();

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

  5614.                     DataElement de = new DataElement();
  5615.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_AUTORIZZAZIONE_CONTENUTI_CUSTOM_PROPERTIES_CHANGE, pId,pIdSoggetto, pIdAsps, pIdFruizione, new Parameter( PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, ssp.getNome()));
  5616.                     de.setValue(ssp.getNome());
  5617.                     de.setIdToRemove(ssp.getId()+"");
  5618.                     de.setSize(CostantiControlStation.NOME_PROPRIETA_VISUALIZZATA);
  5619.                     e.add(de);

  5620.                     de = new DataElement();
  5621.                     if(StringUtils.isNotEmpty(ssp.getValore()) &&
  5622.                             BYOKManager.isEnabledBYOK() &&
  5623.                             this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(ssp.getValore())) {
  5624.                         de.setValue(CostantiControlStation.VALORE_CIFRATO);
  5625.                     }
  5626.                     else {
  5627.                         de.setValue(ssp.getValore());
  5628.                     }
  5629.                     e.add(de);

  5630.                     dati.add(e);
  5631.                 }
  5632.             }

  5633.             this.pd.setDati(dati);
  5634.             this.pd.setAddButton(true);

  5635.         } catch (Exception e) {
  5636.             this.logError(e.getMessage(), e);
  5637.             throw new ControlStationCoreException(e.getMessage(),e);
  5638.         }
  5639.     }

  5640.     public boolean proprietaAutorizzazioneContenutoCheckData(TipoOperazione tipoOp, String idPorta, String nome, String valore ) throws ControlStationCoreException {
  5641.         try {
  5642.             int idInt = Integer.parseInt(idPorta);

  5643.             // Campi obbligatori
  5644.             if (nome.equals("") || valore.equals("")) {
  5645.                 String tmpElenco = "";
  5646.                 if (nome.equals("")) {
  5647.                     tmpElenco = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME;
  5648.                 }
  5649.                 if (valore.equals("")) {
  5650.                     if (tmpElenco.equals("")) {
  5651.                         tmpElenco = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  5652.                     } else {
  5653.                         tmpElenco = tmpElenco + ", " + PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  5654.                     }
  5655.                 }
  5656.                 this.pd.setMessage(MessageFormat.format(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, tmpElenco));
  5657.                 return false;
  5658.             }

  5659.             if (nome.indexOf(" ") != -1) {
  5660.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_CAMPI_DI_TESTO);
  5661.                 return false;
  5662.             }
  5663.             if(!this.checkLength255(nome, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME)) {
  5664.                 return false;
  5665.             }
  5666.            
  5667.             if( !this.core.getDriverBYOKUtilities().isEnabledBYOK() || !this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(valore) ){
  5668.                 if (valore.indexOf(" ") != -1) {
  5669.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_CAMPI_DI_TESTO);
  5670.                     return false;
  5671.                 }
  5672.                 if(!this.checkLength255(valore, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE)) {
  5673.                     return false;
  5674.                 }
  5675.             }
  5676.                
  5677.             // Se tipoOp = add, controllo che la property non sia gia'
  5678.             // stata
  5679.             // registrata per la porta applicativa
  5680.             if (tipoOp.equals(TipoOperazione.ADD)) {
  5681.                 boolean giaRegistrato = false;
  5682.                 PortaDelegata portaDelegata = this.porteDelegateCore.getPortaDelegata(idInt);
  5683.                 String nomeporta = portaDelegata.getNome();

  5684.                 for (int i = 0; i < portaDelegata.sizeProprietaAutorizzazioneContenutoList(); i++) {
  5685.                     Proprieta tmpProp = portaDelegata.getProprietaAutorizzazioneContenuto(i);
  5686.                     if (nome.equals(tmpProp.getNome())) {
  5687.                         giaRegistrato = true;
  5688.                         break;
  5689.                     }
  5690.                 }

  5691.                 if (giaRegistrato) {
  5692.                     Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  5693.                     if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  5694.                     if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  5695.                         nomeporta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(null , null, portaDelegata);
  5696.                         this.pd.setMessage(MessageFormat.format(
  5697.                                 PorteDelegateCostanti.MESSAGGIO_ERRORE_LA_PROPERTY_XX_E_GIA_STATA_ASSOCIATA_ALLA_CONFIGURAZIONE_YY, nome,
  5698.                                 nomeporta));
  5699.                     }
  5700.                     else {
  5701.                         this.pd.setMessage(MessageFormat.format(
  5702.                                 PorteDelegateCostanti.MESSAGGIO_ERRORE_LA_PROPERTY_XX_E_GIA_STATA_ASSOCIATA_ALLA_PORTA_DELEGATA_YY, nome,
  5703.                                 nomeporta));
  5704.                     }
  5705.                    
  5706.                    
  5707.                     return false;
  5708.                 }
  5709.             }

  5710.             return true;
  5711.         } catch (Exception e) {
  5712.             this.logError(e.getMessage(), e);
  5713.             throw new ControlStationCoreException(e.getMessage(),e);
  5714.         }
  5715.     }
  5716.    
  5717.     public void preparePorteDelegateAutenticazioneCustomPropList(String nomePorta, ConsoleSearch ricerca, List<Proprieta> lista) throws Exception {
  5718.         try {
  5719.             if(nomePorta!=null) {
  5720.                 // nop
  5721.             }
  5722.            
  5723.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  5724.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  5725.             if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  5726.            
  5727.             String id = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  5728.             String idsogg = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  5729.             String idAsps = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  5730.             if(idAsps == null)
  5731.                 idAsps = "";
  5732.            
  5733.             String idFruizione = this.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  5734.             if(idFruizione == null)
  5735.                 idFruizione = "";
  5736.            
  5737.             Parameter pId = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  5738.             Parameter pIdSoggetto = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  5739.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idAsps);
  5740.             Parameter pIdFruizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione);

  5741.             ServletUtils.addListElementIntoSession(this.request, this.session, PorteDelegateCostanti.OBJECT_NAME_PORTE_DELEGATE_AUTENTICAZIONE_CUSTOM_PROPERTIES, pId, pIdSoggetto, pIdAsps, pIdFruizione);

  5742.             int idLista = Liste.PORTE_DELEGATE_PROPRIETA_AUTENTICAZIONE;
  5743.             int limit = ricerca.getPageSize(idLista);
  5744.             int offset = ricerca.getIndexIniziale(idLista);
  5745.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  5746.             this.pd.setIndex(offset);
  5747.             this.pd.setPageSize(limit);
  5748.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  5749.             PortaDelegata myPD = this.porteDelegateCore.getPortaDelegata(Integer.parseInt(id));
  5750.             String idporta = myPD.getNome();

  5751.             List<Parameter> lstParam = this.getTitoloPD(parentPD, idsogg, idAsps, idFruizione);
  5752.            
  5753.             String labelPerPorta = null;
  5754.             if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  5755.                 labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  5756.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI,
  5757.                         PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  5758.                         myPD);
  5759.             }
  5760.             else {
  5761.                 labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI_CONFIG_DI+idporta;
  5762.             }
  5763.            
  5764.             lstParam.add(new Parameter(labelPerPorta, PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONTROLLO_ACCESSI,
  5765.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + myPD.getId()),
  5766.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, myPD.getNome()),
  5767.                     new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, myPD.getIdSoggetto() + ""),
  5768.                     pIdAsps, new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE, idFruizione+ "")));
  5769.            
  5770.             String labelPagLista = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_AUTENTICAZIONE_PROPRIETA;

  5771.             Parameter pNomePorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, idporta);

  5772.             this.pd.setSearchLabel(CostantiControlStation.LABEL_PARAMETRO_NOME);
  5773.             if(search.equals("")){
  5774.                 this.pd.setSearchDescription("");
  5775.                 lstParam.add(new Parameter(labelPagLista,null));
  5776.             }
  5777.             else{
  5778.                 lstParam.add(new Parameter(labelPagLista,
  5779.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_AUTENTICAZIONE_CUSTOM_PROPERTIES_LIST, pId, pIdSoggetto, pNomePorta, pIdAsps, pIdFruizione    ));
  5780.                 lstParam.add(new Parameter(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RISULTATI_RICERCA, null));

  5781.             }

  5782.             ServletUtils.setPageDataTitle(this.pd, lstParam.toArray(new Parameter[lstParam.size()]));
  5783.            
  5784.             // imposto menu' contestuale
  5785.             this.impostaComandiMenuContestualePD(idsogg, idAsps, idFruizione);
  5786.            
  5787.             // controllo eventuali risultati ricerca
  5788.             if (!search.equals("")) {
  5789.                 ServletUtils.enabledPageDataSearch(this.pd, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_AUTENTICAZIONE_PROPRIETA, search);
  5790.             }
  5791.            
  5792.             // setto le label delle colonne
  5793.             String valueLabel = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  5794.             String[] labels = { PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME, valueLabel };
  5795.             this.pd.setLabels(labels);
  5796.            
  5797.             // preparo i dati
  5798.             List<List<DataElement>> dati = new ArrayList<>();

  5799.             if (lista != null) {
  5800.                 Iterator<Proprieta> it = lista.iterator();
  5801.                 while (it.hasNext()) {
  5802.                     Proprieta ssp = it.next();

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

  5804.                     DataElement de = new DataElement();
  5805.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_AUTENTICAZIONE_CUSTOM_PROPERTIES_CHANGE, pId,pIdSoggetto, pIdAsps, pIdFruizione, new Parameter( PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME, ssp.getNome()));
  5806.                     de.setValue(ssp.getNome());
  5807.                     de.setIdToRemove(ssp.getId()+"");
  5808.                     de.setSize(CostantiControlStation.NOME_PROPRIETA_VISUALIZZATA);
  5809.                     e.add(de);

  5810.                     de = new DataElement();
  5811.                     if(StringUtils.isNotEmpty(ssp.getValore()) &&
  5812.                             BYOKManager.isEnabledBYOK() &&
  5813.                             this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(ssp.getValore())) {
  5814.                         de.setValue(CostantiControlStation.VALORE_CIFRATO);
  5815.                     }
  5816.                     else {
  5817.                         de.setValue(ssp.getValore());
  5818.                     }
  5819.                     e.add(de);

  5820.                     dati.add(e);
  5821.                 }
  5822.             }

  5823.             this.pd.setDati(dati);
  5824.             this.pd.setAddButton(true);

  5825.         } catch (Exception e) {
  5826.             this.logError(e.getMessage(), e);
  5827.             throw new ControlStationCoreException(e.getMessage(),e);
  5828.         }
  5829.     }

  5830.     public boolean proprietaAutenticazioneCheckData(TipoOperazione tipoOp, String idPorta, String nome, String valore ) throws ControlStationCoreException {
  5831.         try {
  5832.             int idInt = Integer.parseInt(idPorta);

  5833.             // Campi obbligatori
  5834.             if (nome.equals("") || valore.equals("")) {
  5835.                 String tmpElenco = "";
  5836.                 if (nome.equals("")) {
  5837.                     tmpElenco = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME;
  5838.                 }
  5839.                 if (valore.equals("")) {
  5840.                     if (tmpElenco.equals("")) {
  5841.                         tmpElenco = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  5842.                     } else {
  5843.                         tmpElenco = tmpElenco + ", " + PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE;
  5844.                     }
  5845.                 }
  5846.                 this.pd.setMessage(MessageFormat.format(PorteDelegateCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_XX, tmpElenco));
  5847.                 return false;
  5848.             }

  5849.             if (nome.indexOf(" ") != -1) {
  5850.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_CAMPI_DI_TESTO);
  5851.                 return false;
  5852.             }
  5853.             if(!this.checkLength255(nome, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME)) {
  5854.                 return false;
  5855.             }
  5856.             if( !this.core.getDriverBYOKUtilities().isEnabledBYOK() || !this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(valore) ){
  5857.                 if (valore.indexOf(" ") != -1) {
  5858.                     this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NON_INSERIRE_SPAZI_NEI_CAMPI_DI_TESTO);
  5859.                     return false;
  5860.                 }
  5861.                 if(!this.checkLength255(valore, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALORE)) {
  5862.                     return false;
  5863.                 }
  5864.             }

  5865.             // Se tipoOp = add, controllo che la property non sia gia'
  5866.             // stata
  5867.             // registrata per la porta applicativa
  5868.             if (tipoOp.equals(TipoOperazione.ADD)) {
  5869.                 boolean giaRegistrato = false;
  5870.                 PortaDelegata portaDelegata = this.porteDelegateCore.getPortaDelegata(idInt);
  5871.                 String nomeporta = portaDelegata.getNome();

  5872.                 for (int i = 0; i < portaDelegata.sizeProprietaAutenticazioneList(); i++) {
  5873.                     Proprieta tmpProp = portaDelegata.getProprietaAutenticazione(i);
  5874.                     if (nome.equals(tmpProp.getNome())) {
  5875.                         giaRegistrato = true;
  5876.                         break;
  5877.                     }
  5878.                 }

  5879.                 if (giaRegistrato) {
  5880.                     Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  5881.                     if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  5882.                     if(parentPD!=null && (parentPD.intValue() == PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE)) {
  5883.                         nomeporta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(null , null, portaDelegata);
  5884.                         this.pd.setMessage(MessageFormat.format(
  5885.                                 PorteDelegateCostanti.MESSAGGIO_ERRORE_LA_PROPERTY_XX_E_GIA_STATA_ASSOCIATA_ALLA_CONFIGURAZIONE_YY, nome,
  5886.                                 nomeporta));
  5887.                     }
  5888.                     else {
  5889.                         this.pd.setMessage(MessageFormat.format(
  5890.                                 PorteDelegateCostanti.MESSAGGIO_ERRORE_LA_PROPERTY_XX_E_GIA_STATA_ASSOCIATA_ALLA_PORTA_DELEGATA_YY, nome,
  5891.                                 nomeporta));
  5892.                     }
  5893.                    
  5894.                    
  5895.                     return false;
  5896.                 }
  5897.             }

  5898.             return true;
  5899.         } catch (Exception e) {
  5900.             this.logError(e.getMessage(), e);
  5901.             throw new ControlStationCoreException(e.getMessage(),e);
  5902.         }
  5903.     }
  5904. }