AccordiServizioParteSpecificaHelper.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.aps;

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

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

  30. import org.apache.commons.lang.StringEscapeUtils;
  31. import org.apache.commons.lang.StringUtils;
  32. import org.apache.struts.upload.FormFile;
  33. import org.openspcoop2.core.allarmi.constants.RuoloPorta;
  34. import org.openspcoop2.core.commons.Filtri;
  35. import org.openspcoop2.core.commons.ISearch;
  36. import org.openspcoop2.core.commons.Liste;
  37. import org.openspcoop2.core.commons.SearchUtils;
  38. import org.openspcoop2.core.config.CanaleConfigurazione;
  39. import org.openspcoop2.core.config.Configurazione;
  40. import org.openspcoop2.core.config.GenericProperties;
  41. import org.openspcoop2.core.config.PortaApplicativa;
  42. import org.openspcoop2.core.config.PortaApplicativaServizio;
  43. import org.openspcoop2.core.config.PortaApplicativaServizioApplicativo;
  44. import org.openspcoop2.core.config.PortaDelegata;
  45. import org.openspcoop2.core.config.PortaDelegataServizio;
  46. import org.openspcoop2.core.config.Property;
  47. import org.openspcoop2.core.config.ServizioApplicativo;
  48. import org.openspcoop2.core.config.TrasformazioneRegola;
  49. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  50. import org.openspcoop2.core.config.constants.MTOMProcessorType;
  51. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  52. import org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal;
  53. import org.openspcoop2.core.config.constants.TipoAutorizzazione;
  54. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  55. import org.openspcoop2.core.config.driver.DriverConfigurazioneNotFound;
  56. import org.openspcoop2.core.constants.TipiConnettore;
  57. import org.openspcoop2.core.controllo_traffico.AttivazionePolicy;
  58. import org.openspcoop2.core.controllo_traffico.constants.RuoloPolicy;
  59. import org.openspcoop2.core.id.IDAccordo;
  60. import org.openspcoop2.core.id.IDPortaApplicativa;
  61. import org.openspcoop2.core.id.IDPortaDelegata;
  62. import org.openspcoop2.core.id.IDServizio;
  63. import org.openspcoop2.core.id.IDServizioApplicativo;
  64. import org.openspcoop2.core.id.IDSoggetto;
  65. import org.openspcoop2.core.mapping.MappingErogazionePortaApplicativa;
  66. import org.openspcoop2.core.mapping.MappingFruizionePortaDelegata;
  67. import org.openspcoop2.core.mvc.properties.utils.ConfigManager;
  68. import org.openspcoop2.core.mvc.properties.utils.PropertiesSourceConfiguration;
  69. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  70. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  71. import org.openspcoop2.core.registry.ConfigurazioneServizioAzione;
  72. import org.openspcoop2.core.registry.Connettore;
  73. import org.openspcoop2.core.registry.Documento;
  74. import org.openspcoop2.core.registry.Fruitore;
  75. import org.openspcoop2.core.registry.ProprietaOggetto;
  76. import org.openspcoop2.core.registry.Soggetto;
  77. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  78. import org.openspcoop2.core.registry.beans.AzioneSintetica;
  79. import org.openspcoop2.core.registry.beans.OperationSintetica;
  80. import org.openspcoop2.core.registry.beans.PortTypeSintetico;
  81. import org.openspcoop2.core.registry.beans.ResourceSintetica;
  82. import org.openspcoop2.core.registry.constants.FormatoSpecifica;
  83. import org.openspcoop2.core.registry.constants.PddTipologia;
  84. import org.openspcoop2.core.registry.constants.ProprietariDocumento;
  85. import org.openspcoop2.core.registry.constants.RuoliDocumento;
  86. import org.openspcoop2.core.registry.constants.StatiAccordo;
  87. import org.openspcoop2.core.registry.constants.TipiDocumentoLivelloServizio;
  88. import org.openspcoop2.core.registry.constants.TipiDocumentoSemiformale;
  89. import org.openspcoop2.core.registry.constants.TipiDocumentoSicurezza;
  90. import org.openspcoop2.core.registry.constants.TipologiaServizio;
  91. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  92. import org.openspcoop2.core.registry.driver.DriverRegistroServiziNotFound;
  93. import org.openspcoop2.message.constants.ServiceBinding;
  94. import org.openspcoop2.monitor.engine.alarm.wrapper.ConfigurazioneAllarmeBean;
  95. import org.openspcoop2.protocol.basic.config.ImplementationConfiguration;
  96. import org.openspcoop2.protocol.basic.config.SubscriptionConfiguration;
  97. import org.openspcoop2.protocol.engine.ProtocolFactoryManager;
  98. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  99. import org.openspcoop2.protocol.sdk.constants.ArchiveType;
  100. import org.openspcoop2.protocol.sdk.validator.ValidazioneResult;
  101. import org.openspcoop2.utils.BooleanNullable;
  102. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  103. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  104. import org.openspcoop2.web.ctrlstat.core.ControlStationCoreException;
  105. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  106. import org.openspcoop2.web.ctrlstat.plugins.ExtendedConnettore;
  107. import org.openspcoop2.web.ctrlstat.plugins.IExtendedListServlet;
  108. import org.openspcoop2.web.ctrlstat.servlet.ConsoleHelper;
  109. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCostanti;
  110. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneUtilities;
  111. import org.openspcoop2.web.ctrlstat.servlet.aps.erogazioni.ErogazioniCostanti;
  112. import org.openspcoop2.web.ctrlstat.servlet.archivi.ArchiviCostanti;
  113. import org.openspcoop2.web.ctrlstat.servlet.archivi.ExporterUtils;
  114. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCostanti;
  115. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCostanti;
  116. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriHelper;
  117. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCostanti;
  118. import org.openspcoop2.web.ctrlstat.servlet.pd.PorteDelegateCostanti;
  119. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCostanti;
  120. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCostanti;
  121. import org.openspcoop2.web.ctrlstat.servlet.utils.ProprietaOggettoRegistro;
  122. import org.openspcoop2.web.lib.mvc.AreaBottoni;
  123. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  124. import org.openspcoop2.web.lib.mvc.CheckboxStatusType;
  125. import org.openspcoop2.web.lib.mvc.Costanti;
  126. import org.openspcoop2.web.lib.mvc.DataElement;
  127. import org.openspcoop2.web.lib.mvc.DataElementImage;
  128. import org.openspcoop2.web.lib.mvc.DataElementType;
  129. import org.openspcoop2.web.lib.mvc.PageData;
  130. import org.openspcoop2.web.lib.mvc.Parameter;
  131. import org.openspcoop2.web.lib.mvc.ServletUtils;
  132. import org.openspcoop2.web.lib.mvc.TipoOperazione;
  133. import org.openspcoop2.web.lib.users.dao.User;

  134. /**
  135.  * AccordiServizioParteSpecificaHelper
  136.  *
  137.  * @author Poli Andrea (apoli@link.it)
  138.  * @author $Author$
  139.  * @version $Rev$, $Date$
  140.  */
  141. public class AccordiServizioParteSpecificaHelper extends ConnettoriHelper {

  142.     public AccordiServizioParteSpecificaHelper(HttpServletRequest request, PageData pd,
  143.             HttpSession session) throws Exception {
  144.         super(request, pd,  session);
  145.     }
  146.     public AccordiServizioParteSpecificaHelper(ControlStationCore core, HttpServletRequest request, PageData pd,
  147.             HttpSession session) throws Exception {
  148.         super(core, request, pd,  session);
  149.     }


  150.     // Controlla i dati dei WSDL degli Accordi e dei Servizi
  151.     boolean accordiParteSpecificaWSDLCheckData(PageData pd,String tipo, String wsdl,
  152.             AccordoServizioParteSpecifica aps, AccordoServizioParteComune apc,boolean validazioneDocumenti) throws Exception {

  153.         if(validazioneDocumenti){
  154.            
  155.             FormatoSpecifica formato = null;
  156.             if(apc!=null) {
  157.                 formato = apc.getFormatoSpecifica();
  158.             }
  159.            
  160.             boolean  validazioneParteSpecifica = false;
  161.             if (tipo.equals(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE)) {
  162.                 byte [] tmp = this.apsCore.getInterfaceAsByteArray(formato, wsdl);
  163.                 aps.setByteWsdlImplementativoErogatore(tmp);
  164.                 validazioneParteSpecifica = true;
  165.             }
  166.             else if (tipo.equals(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE)) {
  167.                 byte [] tmp = this.apsCore.getInterfaceAsByteArray(formato, wsdl);
  168.                 aps.setByteWsdlImplementativoFruitore(tmp);
  169.                 validazioneParteSpecifica = true;
  170.             }

  171.             if(validazioneParteSpecifica){
  172.                 ValidazioneResult result = this.apsCore.validaInterfacciaWsdlParteSpecifica(aps, apc, this.soggettiCore);
  173.                 if(result.isEsito()==false){
  174.                     pd.setMessage(result.getMessaggioErrore());
  175.                 }
  176.                 return result.isEsito();
  177.             }
  178.         }

  179.         return true;
  180.     }
  181.    
  182.     // Controlla i dati dei WSDL degli Accordi e dei Servizi
  183.     boolean accordiParteSpecificaFruitoreWSDLCheckData(PageData pd,String tipo, String wsdl,
  184.             Fruitore fruitore,AccordoServizioParteSpecifica aps, AccordoServizioParteComune apc,boolean validazioneDocumenti) throws Exception {

  185.         if(validazioneDocumenti){

  186.             FormatoSpecifica formato = null;
  187.             if(apc!=null) {
  188.                 formato = apc.getFormatoSpecifica();
  189.             }
  190.            
  191.             boolean  validazioneParteSpecifica = false;
  192.             if (tipo.equals(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE)) {
  193.                 byte [] tmp = this.apsCore.getInterfaceAsByteArray(formato, wsdl);
  194.                 fruitore.setByteWsdlImplementativoErogatore(tmp);
  195.                 validazioneParteSpecifica = true;
  196.             }
  197.             else if (tipo.equals(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE)) {
  198.                 byte [] tmp = this.apsCore.getInterfaceAsByteArray(formato, wsdl);
  199.                 fruitore.setByteWsdlImplementativoFruitore(tmp);
  200.                 validazioneParteSpecifica = true;
  201.             }

  202.             if(validazioneParteSpecifica){
  203.                 ValidazioneResult result = this.apsCore.validaInterfacciaWsdlParteSpecifica(fruitore, (AccordoServizioParteSpecifica) aps.clone(), apc, this.soggettiCore);
  204.                 if(result.isEsito()==false){
  205.                     pd.setMessage(result.getMessaggioErrore());
  206.                 }
  207.                 return result.isEsito();
  208.             }
  209.         }

  210.         return true;
  211.     }

  212.     private boolean existsOperazione(AccordoServizioParteComuneSintetico aspc, ServiceBinding serviceBinding, String portType, String azione) {
  213.         if(ServiceBinding.REST.equals(serviceBinding)) {
  214.             if(aspc.getResource()!=null && !aspc.getResource().isEmpty()) {
  215.                 for (ResourceSintetica resource : aspc.getResource()) {
  216.                     if(resource.getNome().equals(azione)) {
  217.                         return true;
  218.                     }
  219.                 }
  220.             }
  221.         }
  222.         else {
  223.             if(portType!=null && !"".equals(portType)) {
  224.                 if(aspc.getPortType()!=null && !aspc.getPortType().isEmpty()) {
  225.                     for (PortTypeSintetico pt : aspc.getPortType()) {
  226.                         if(portType.equals(pt.getNome())) {
  227.                             if(pt.getAzione()!=null && !pt.getAzione().isEmpty()) {
  228.                                 for (OperationSintetica az : pt.getAzione()) {
  229.                                     if(az.getNome().equals(azione)) {
  230.                                         return true;
  231.                                     }
  232.                                 }
  233.                             }
  234.                             break;
  235.                         }
  236.                     }
  237.                 }
  238.             }
  239.             else {
  240.                 if(aspc.getAzione()!=null && !aspc.getAzione().isEmpty()) {
  241.                     for (AzioneSintetica az : aspc.getAzione()) {
  242.                         if(az.getNome().equals(azione)) {
  243.                             return true;
  244.                         }
  245.                     }
  246.                 }
  247.             }
  248.         }
  249.        
  250.         return false;
  251.     }
  252.     private boolean checkModificaVersioneApi(AccordoServizioParteSpecifica servizio,
  253.             long idAccordo, ServiceBinding serviceBinding, String portType,
  254.             boolean gestioneFruitori, boolean gestioneErogatori) throws Exception {
  255.         List<String> erogazione_listTrasformazioniPredefinito = null;
  256.         List<String> erogazione_listRateLimitingPredefinito = null;
  257.         List<String> erogazione_listAllarmePredefinito = null;
  258.         HashMap<String, List<String>> erogazione_mapGruppi = new HashMap<>();
  259.        
  260.         HashMap<String, List<String>> fruizione_listTrasformazioniPredefinito = null;
  261.         HashMap<String, List<String>> fruizione_listRateLimitingPredefinito = null;
  262.         HashMap<String, List<String>> fruizione_listAllarmePredefinito = null;
  263.         HashMap<String,HashMap<String, List<String>>> fruizione_mapGruppi = new HashMap<String,HashMap<String, List<String>>>();
  264.        
  265.        
  266.         IDServizio idService = this.idServizioFactory.getIDServizioFromAccordo(servizio);
  267.        
  268.         List<MappingErogazionePortaApplicativa> listaMappingErogazione = null;
  269.         try{
  270.             listaMappingErogazione = this.apsCore.mappingServiziPorteAppList(idService,servizio.getId(), null);
  271.         }catch(Exception e) {
  272.             // ignore
  273.         }
  274.         if(listaMappingErogazione!=null && !listaMappingErogazione.isEmpty()) {
  275.             for (MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa : listaMappingErogazione) {
  276.                 PortaApplicativa pa = null;
  277.                 try {
  278.                     pa = this.porteApplicativeCore.getPortaApplicativa(mappingErogazionePortaApplicativa.getIdPortaApplicativa());
  279.                 }catch(Exception e) {
  280.                     // ignore
  281.                 }
  282.                 if(pa!=null) {
  283.                     if(mappingErogazionePortaApplicativa.isDefault()) {
  284.                         if(pa.getTrasformazioni()!=null && pa.getTrasformazioni().sizeRegolaList()>0) {
  285.                             for (TrasformazioneRegola regola :  pa.getTrasformazioni().getRegolaList()) {
  286.                                 if(regola.getApplicabilita()!=null && regola.getApplicabilita().sizeAzioneList()>0) {
  287.                                     if(erogazione_listTrasformazioniPredefinito==null) {
  288.                                         erogazione_listTrasformazioniPredefinito = regola.getApplicabilita().getAzioneList();
  289.                                     }
  290.                                     else {
  291.                                         for (String az : regola.getApplicabilita().getAzioneList()) {
  292.                                             if(!erogazione_listTrasformazioniPredefinito.contains(az)) {
  293.                                                 erogazione_listTrasformazioniPredefinito.add(az);
  294.                                             }
  295.                                         }
  296.                                     }
  297.                                 }
  298.                             }
  299.                         }
  300.                         List<AttivazionePolicy> listaPolicies = null;
  301.                         try {
  302.                             ConsoleSearch ricercaPolicies = new ConsoleSearch(true);
  303.                             listaPolicies = this.confCore.attivazionePolicyList(ricercaPolicies, RuoloPolicy.APPLICATIVA, pa.getNome());
  304.                         }catch(Exception e) {
  305.                             // ignore
  306.                         }
  307.                         if(listaPolicies!=null && !listaPolicies.isEmpty()) {
  308.                             for (AttivazionePolicy ap : listaPolicies) {
  309.                                 if(ap.getFiltro()!=null && ap.getFiltro().getAzione()!=null) {
  310.                                     String [] tmp = ap.getFiltro().getAzione().split(",");
  311.                                     if(tmp!=null && tmp.length>0) {
  312.                                         if(erogazione_listRateLimitingPredefinito==null) {
  313.                                             erogazione_listRateLimitingPredefinito = new ArrayList<>();
  314.                                         }
  315.                                         for (String az : tmp) {
  316.                                             if(!erogazione_listRateLimitingPredefinito.contains(az)) {
  317.                                                 erogazione_listRateLimitingPredefinito.add(az);
  318.                                             }  
  319.                                         }
  320.                                     }
  321.                                 }
  322.                             }
  323.                         }
  324.                         if(this.confCore.isConfigurazioneAllarmiEnabled()) {
  325.                             List<ConfigurazioneAllarmeBean> listaAllarmi = null;
  326.                             try {
  327.                                 ConsoleSearch ricercaPolicies = new ConsoleSearch(true);
  328.                                 listaAllarmi = this.confCore.allarmiList(ricercaPolicies, RuoloPorta.APPLICATIVA, pa.getNome());
  329.                             }catch(Exception e) {
  330.                                 // ignore
  331.                             }
  332.                             if(listaAllarmi!=null && !listaAllarmi.isEmpty()) {
  333.                                 for (ConfigurazioneAllarmeBean allarme : listaAllarmi) {
  334.                                     if(allarme.getFiltro()!=null && allarme.getFiltro().getAzione()!=null) {
  335.                                         String [] tmp = allarme.getFiltro().getAzione().split(",");
  336.                                         if(tmp!=null && tmp.length>0) {
  337.                                             if(erogazione_listAllarmePredefinito==null) {
  338.                                                 erogazione_listAllarmePredefinito = new ArrayList<>();
  339.                                             }
  340.                                             for (String az : tmp) {
  341.                                                 if(!erogazione_listAllarmePredefinito.contains(az)) {
  342.                                                     erogazione_listAllarmePredefinito.add(az);
  343.                                                 }  
  344.                                             }
  345.                                         }
  346.                                     }
  347.                                 }
  348.                             }
  349.                         }
  350.                     }
  351.                     else {
  352.                         if(pa.getAzione()!=null && pa.getAzione().sizeAzioneDelegataList()>0) {
  353.                             List<String> l = new ArrayList<>();
  354.                             for (String az : pa.getAzione().getAzioneDelegataList()) {
  355.                                 l.add(az);
  356.                             }
  357.                             erogazione_mapGruppi.put(mappingErogazionePortaApplicativa.getDescrizione(), l);
  358.                         }
  359.                     }
  360.                 }
  361.             }
  362.         }
  363.        
  364.         if(servizio.sizeFruitoreList()>0) {
  365.             for (Fruitore fruitore : servizio.getFruitoreList()) {
  366.                 IDSoggetto idFruitore = new IDSoggetto(fruitore.getTipo(), fruitore.getNome());
  367.                 String labelFruitore = ConsoleHelper._getLabelNomeSoggetto(idFruitore);
  368.                
  369.                 List<MappingFruizionePortaDelegata> listaMappingFruizione = null;
  370.                 try{
  371.                     listaMappingFruizione = this.apsCore.serviziFruitoriMappingList(idFruitore, idService, null);
  372.                 }catch(Exception e) {
  373.                     // ignore
  374.                 }
  375.                 if(listaMappingFruizione!=null && !listaMappingFruizione.isEmpty()) {
  376.                     for (MappingFruizionePortaDelegata mappingFruizionePortaDelegata : listaMappingFruizione) {
  377.                         PortaDelegata pd = null;
  378.                         try {
  379.                             pd = this.porteDelegateCore.getPortaDelegata(mappingFruizionePortaDelegata.getIdPortaDelegata());
  380.                         }catch(Exception e) {
  381.                             // ignore
  382.                         }
  383.                         if(pd!=null) {
  384.                             if(mappingFruizionePortaDelegata.isDefault()) {
  385.                                 if(pd.getTrasformazioni()!=null && pd.getTrasformazioni().sizeRegolaList()>0) {
  386.                                     List<String> list = null;
  387.                                     for (TrasformazioneRegola regola :  pd.getTrasformazioni().getRegolaList()) {
  388.                                         if(regola.getApplicabilita()!=null && regola.getApplicabilita().sizeAzioneList()>0) {
  389.                                             if(list==null) {
  390.                                                 list = regola.getApplicabilita().getAzioneList();
  391.                                             }
  392.                                             else {
  393.                                                 for (String az : regola.getApplicabilita().getAzioneList()) {
  394.                                                     if(!list.contains(az)) {
  395.                                                         list.add(az);
  396.                                                     }
  397.                                                 }
  398.                                             }
  399.                                         }
  400.                                     }
  401.                                     if(list!=null) {
  402.                                         if(fruizione_listTrasformazioniPredefinito==null) {
  403.                                             fruizione_listTrasformazioniPredefinito = new HashMap<>();
  404.                                         }
  405.                                         fruizione_listTrasformazioniPredefinito.put(labelFruitore, list);
  406.                                     }
  407.                                 }
  408.                                 List<AttivazionePolicy> listaPolicies = null;
  409.                                 try {
  410.                                     ConsoleSearch ricercaPolicies = new ConsoleSearch(true);
  411.                                     listaPolicies = this.confCore.attivazionePolicyList(ricercaPolicies, RuoloPolicy.DELEGATA, pd.getNome());
  412.                                 }catch(Exception e) {
  413.                                     // ignore
  414.                                 }
  415.                                 if(listaPolicies!=null && !listaPolicies.isEmpty()) {
  416.                                     List<String> list = null;
  417.                                     for (AttivazionePolicy ap : listaPolicies) {
  418.                                         if(ap.getFiltro()!=null && ap.getFiltro().getAzione()!=null) {
  419.                                             String [] tmp = ap.getFiltro().getAzione().split(",");
  420.                                             if(tmp!=null && tmp.length>0) {
  421.                                                 if(list==null) {
  422.                                                     list = new ArrayList<>();
  423.                                                 }
  424.                                                 for (String az : tmp) {
  425.                                                     if(!list.contains(az)) {
  426.                                                         list.add(az);
  427.                                                     }  
  428.                                                 }
  429.                                             }
  430.                                         }
  431.                                     }
  432.                                     if(list!=null) {
  433.                                         if(fruizione_listRateLimitingPredefinito==null) {
  434.                                             fruizione_listRateLimitingPredefinito = new HashMap<>();
  435.                                         }
  436.                                         fruizione_listRateLimitingPredefinito.put(labelFruitore, list);
  437.                                     }
  438.                                 }
  439.                                 if(this.confCore.isConfigurazioneAllarmiEnabled()) {
  440.                                     List<ConfigurazioneAllarmeBean> listaAllarmi = null;
  441.                                     try {
  442.                                         ConsoleSearch ricercaPolicies = new ConsoleSearch(true);
  443.                                         listaAllarmi = this.confCore.allarmiList(ricercaPolicies, RuoloPorta.DELEGATA, pd.getNome());
  444.                                     }catch(Exception e) {
  445.                                         // ignore
  446.                                     }
  447.                                     if(listaAllarmi!=null && !listaAllarmi.isEmpty()) {
  448.                                         List<String> list = null;
  449.                                         for (ConfigurazioneAllarmeBean allarme : listaAllarmi) {
  450.                                             if(allarme.getFiltro()!=null && allarme.getFiltro().getAzione()!=null) {
  451.                                                 String [] tmp = allarme.getFiltro().getAzione().split(",");
  452.                                                 if(tmp!=null && tmp.length>0) {
  453.                                                     if(list==null) {
  454.                                                         list = new ArrayList<>();
  455.                                                     }
  456.                                                     for (String az : tmp) {
  457.                                                         if(!list.contains(az)) {
  458.                                                             list.add(az);
  459.                                                         }  
  460.                                                     }
  461.                                                 }
  462.                                             }
  463.                                         }
  464.                                         if(list!=null) {
  465.                                             if(fruizione_listAllarmePredefinito==null) {
  466.                                                 fruizione_listAllarmePredefinito = new HashMap<>();
  467.                                             }
  468.                                             fruizione_listAllarmePredefinito.put(labelFruitore, list);
  469.                                         }
  470.                                     }
  471.                                 }
  472.                             }
  473.                             else {
  474.                                 if(pd.getAzione()!=null && pd.getAzione().sizeAzioneDelegataList()>0) {
  475.                                     List<String> l = new ArrayList<>();
  476.                                     for (String az : pd.getAzione().getAzioneDelegataList()) {
  477.                                         l.add(az);
  478.                                     }
  479.                                     HashMap<String, List<String>> m = new HashMap<>();
  480.                                     m.put(mappingFruizionePortaDelegata.getDescrizione(), l);
  481.                                     fruizione_mapGruppi.put(labelFruitore, m);
  482.                                 }
  483.                             }
  484.                         }
  485.                     }
  486.                 }
  487.             }
  488.         }
  489.        
  490.         StringBuilder sbError = new StringBuilder();
  491.        
  492.         AccordoServizioParteComuneSintetico asSintetico = null;
  493.         boolean azioniInErogazione = !erogazione_mapGruppi.isEmpty() || erogazione_listRateLimitingPredefinito!=null || erogazione_listAllarmePredefinito!=null || erogazione_listTrasformazioniPredefinito!=null;
  494.         boolean azioniInFruizione = !fruizione_mapGruppi.isEmpty() || fruizione_listRateLimitingPredefinito!=null || fruizione_listAllarmePredefinito!=null || fruizione_listTrasformazioniPredefinito!=null;
  495.         if( azioniInErogazione
  496.                 ||
  497.                 azioniInFruizione )
  498.              {
  499.             asSintetico = this.apcCore.getAccordoServizioSintetico(idAccordo);
  500.            
  501.             if(!erogazione_mapGruppi.isEmpty() ) {
  502.                 for (String gruppo : erogazione_mapGruppi.keySet()) {
  503.                     List<String> azioni = erogazione_mapGruppi.get(gruppo);
  504.                     List<String> azioniNonTrovate = new ArrayList<>();
  505.                     if(azioni!=null && !azioni.isEmpty()) {
  506.                         for (String az : azioni) {
  507.                             if(!existsOperazione(asSintetico, serviceBinding, portType, az)) {
  508.                                 azioniNonTrovate.add(az);
  509.                             }
  510.                         }
  511.                     }
  512.                     if(!azioniNonTrovate.isEmpty()) {
  513.                         if(sbError.length()>0) {
  514.                             sbError.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  515.                         }
  516.                         sbError.append("Gruppo '"+gruppo+"' (Erogazione): "+azioniNonTrovate);
  517.                     }
  518.                 }
  519.             }
  520.            
  521.             if(erogazione_listTrasformazioniPredefinito!=null && !erogazione_listTrasformazioniPredefinito.isEmpty()) {
  522.                 List<String> azioniNonTrovate = new ArrayList<>();
  523.                 for (String az : erogazione_listTrasformazioniPredefinito) {
  524.                     if(!existsOperazione(asSintetico, serviceBinding, portType, az)) {
  525.                         azioniNonTrovate.add(az);
  526.                     }
  527.                 }
  528.                 if(!azioniNonTrovate.isEmpty()) {
  529.                     if(sbError.length()>0) {
  530.                         sbError.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  531.                     }
  532.                     sbError.append("Criteri di Applicabilità nelle Trasformazioni del gruppo '"+org.openspcoop2.core.constants.Costanti.MAPPING_DESCRIZIONE_DEFAULT+"' (Erogazione): "+azioniNonTrovate);
  533.                 }
  534.             }
  535.            
  536.             if(erogazione_listRateLimitingPredefinito!=null && !erogazione_listRateLimitingPredefinito.isEmpty()) {
  537.                 List<String> azioniNonTrovate = new ArrayList<>();
  538.                 for (String az : erogazione_listRateLimitingPredefinito) {
  539.                     if(!existsOperazione(asSintetico, serviceBinding, portType, az)) {
  540.                         azioniNonTrovate.add(az);
  541.                     }
  542.                 }
  543.                 if(!azioniNonTrovate.isEmpty()) {
  544.                     if(sbError.length()>0) {
  545.                         sbError.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  546.                     }
  547.                     sbError.append("Policy di RateLimiting del gruppo '"+org.openspcoop2.core.constants.Costanti.MAPPING_DESCRIZIONE_DEFAULT+"' (Erogazione): "+azioniNonTrovate);
  548.                 }
  549.             }
  550.            
  551.             if(erogazione_listAllarmePredefinito!=null && !erogazione_listAllarmePredefinito.isEmpty()) {
  552.                 List<String> azioniNonTrovate = new ArrayList<>();
  553.                 for (String az : erogazione_listAllarmePredefinito) {
  554.                     if(!existsOperazione(asSintetico, serviceBinding, portType, az)) {
  555.                         azioniNonTrovate.add(az);
  556.                     }
  557.                 }
  558.                 if(!azioniNonTrovate.isEmpty()) {
  559.                     if(sbError.length()>0) {
  560.                         sbError.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  561.                     }
  562.                     sbError.append("Allarme del gruppo '"+org.openspcoop2.core.constants.Costanti.MAPPING_DESCRIZIONE_DEFAULT+"' (Erogazione): "+azioniNonTrovate);
  563.                 }
  564.             }
  565.            
  566.             if(azioniInFruizione) {
  567.                 if(sbError.length()>0) {
  568.                     sbError.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  569.                 }
  570.             }
  571.            
  572.             if(!fruizione_mapGruppi.isEmpty() ) {
  573.                 for (String labelFruitore : fruizione_mapGruppi.keySet()) {
  574.                     HashMap<String, List<String>> m = fruizione_mapGruppi.get(labelFruitore);
  575.                     for (String gruppo : m.keySet()) {
  576.                         List<String> azioni = m.get(gruppo);
  577.                         List<String> azioniNonTrovate = new ArrayList<>();
  578.                         if(azioni!=null && !azioni.isEmpty()) {
  579.                             for (String az : azioni) {
  580.                                 if(!existsOperazione(asSintetico, serviceBinding, portType, az)) {
  581.                                     azioniNonTrovate.add(az);
  582.                                 }
  583.                             }
  584.                         }
  585.                         if(!azioniNonTrovate.isEmpty()) {
  586.                             if(sbError.length()>0) {
  587.                                 sbError.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  588.                             }
  589.                             sbError.append("Gruppo '"+gruppo+"' (Fruizione '"+labelFruitore+"'): "+azioniNonTrovate);
  590.                         }
  591.                     }
  592.                 }
  593.             }
  594.            
  595.             if(fruizione_listTrasformazioniPredefinito!=null && !fruizione_listTrasformazioniPredefinito.isEmpty()) {
  596.                 for (String labelFruitore : fruizione_listTrasformazioniPredefinito.keySet()) {
  597.                     List<String> l = fruizione_listTrasformazioniPredefinito.get(labelFruitore);
  598.                     List<String> azioniNonTrovate = new ArrayList<>();
  599.                     for (String az : l) {
  600.                         if(!existsOperazione(asSintetico, serviceBinding, portType, az)) {
  601.                             azioniNonTrovate.add(az);
  602.                         }
  603.                     }
  604.                     if(!azioniNonTrovate.isEmpty()) {
  605.                         if(sbError.length()>0) {
  606.                             sbError.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  607.                         }
  608.                         sbError.append("Criteri di Applicabilità nelle Trasformazioni del gruppo '"+org.openspcoop2.core.constants.Costanti.MAPPING_DESCRIZIONE_DEFAULT+"' (Fruizione '"+labelFruitore+"'): "+azioniNonTrovate);
  609.                     }
  610.                 }
  611.             }
  612.            
  613.             if(fruizione_listRateLimitingPredefinito!=null && !fruizione_listRateLimitingPredefinito.isEmpty()) {
  614.                 for (String labelFruitore : fruizione_listRateLimitingPredefinito.keySet()) {
  615.                     List<String> l = fruizione_listRateLimitingPredefinito.get(labelFruitore);
  616.                     List<String> azioniNonTrovate = new ArrayList<>();
  617.                     for (String az : l) {
  618.                         if(!existsOperazione(asSintetico, serviceBinding, portType, az)) {
  619.                             azioniNonTrovate.add(az);
  620.                         }
  621.                     }
  622.                     if(!azioniNonTrovate.isEmpty()) {
  623.                         if(sbError.length()>0) {
  624.                             sbError.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  625.                         }
  626.                         sbError.append("Policy di RateLimiting del gruppo '"+org.openspcoop2.core.constants.Costanti.MAPPING_DESCRIZIONE_DEFAULT+"' (Fruizione '"+labelFruitore+"'): "+azioniNonTrovate);
  627.                     }
  628.                 }
  629.             }
  630.            
  631.             if(fruizione_listAllarmePredefinito!=null && !fruizione_listAllarmePredefinito.isEmpty()) {
  632.                 for (String labelFruitore : fruizione_listAllarmePredefinito.keySet()) {
  633.                     List<String> l = fruizione_listAllarmePredefinito.get(labelFruitore);
  634.                     List<String> azioniNonTrovate = new ArrayList<>();
  635.                     for (String az : l) {
  636.                         if(!existsOperazione(asSintetico, serviceBinding, portType, az)) {
  637.                             azioniNonTrovate.add(az);
  638.                         }
  639.                     }
  640.                     if(!azioniNonTrovate.isEmpty()) {
  641.                         if(sbError.length()>0) {
  642.                             sbError.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  643.                         }
  644.                         sbError.append("Allarme del gruppo '"+org.openspcoop2.core.constants.Costanti.MAPPING_DESCRIZIONE_DEFAULT+"' (Fruizione '"+labelFruitore+"'): "+azioniNonTrovate);
  645.                     }
  646.                 }
  647.             }
  648.         }
  649.        
  650.         if(sbError.length()>0) {
  651.             String prefix = "";
  652.             if(
  653.                     (azioniInErogazione && azioniInFruizione)
  654.                     ||
  655.                     (gestioneFruitori && azioniInErogazione)
  656.                     ||
  657.                     (gestioneErogatori && azioniInFruizione)
  658.                 ) {
  659.                 prefix = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_CAMBIO_EROGATORE_MULTI_API_INFLUENZATE_MODIFICA_VERSIONE;
  660.             }
  661.             this.pd.setMessage(prefix+MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_CAMBIO_VERSIONE_ACCORDO,sbError.toString()));
  662.             return false;
  663.         }
  664.        
  665.         return true;
  666.     }

  667.     private boolean checkCambioErogatore(AccordoServizioParteSpecifica servizio, boolean gestioneFruitori, boolean gestioneErogatori,
  668.             String idSoggErogatore, String protocollo) throws Exception {
  669.        
  670.         // Verifico che non esistano erogazioni riguardanti la modifica (anche se la modifica parte da una fruizione) contenente applicativi server.
  671.         List<String> nomiApplicativiServer = new ArrayList<>();
  672.         IDServizio idService = this.idServizioFactory.getIDServizioFromAccordo(servizio);
  673.         List<MappingErogazionePortaApplicativa> listaMappingErogazione = null;
  674.         try{
  675.             listaMappingErogazione = this.apsCore.mappingServiziPorteAppList(idService,servizio.getId(), null);
  676.         }catch(Exception e) {
  677.             // ignore
  678.         }
  679.         if(listaMappingErogazione!=null && !listaMappingErogazione.isEmpty()) {
  680.             for (MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa : listaMappingErogazione) {
  681.                 PortaApplicativa pa = null;
  682.                 try {
  683.                     pa = this.porteApplicativeCore.getPortaApplicativa(mappingErogazionePortaApplicativa.getIdPortaApplicativa());
  684.                 }catch(Exception e) {
  685.                     // ignore
  686.                 }
  687.                 if(pa!=null && pa.sizeServizioApplicativoList()>0) {
  688.                     for (PortaApplicativaServizioApplicativo pasa: pa.getServizioApplicativoList()) {
  689.                         ServizioApplicativo sa = null;
  690.                         try {
  691.                             sa = this.saCore.getServizioApplicativo(pasa.getIdServizioApplicativo());
  692.                         }catch(Exception e) {
  693.                             // ignore
  694.                         }
  695.                         if(sa!=null && ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(sa.getTipo())) {
  696.                             if(!nomiApplicativiServer.contains(sa.getNome())) {
  697.                                 nomiApplicativiServer.add(sa.getNome());
  698.                             }
  699.                         }
  700.                     }
  701.                 }
  702.             }
  703.         }
  704.         if(!nomiApplicativiServer.isEmpty()) {
  705.             StringBuilder elenco = new StringBuilder();
  706.             for (String server : nomiApplicativiServer) {
  707.                 if(elenco.length()>0) {
  708.                     elenco.append(", ");
  709.                 }
  710.                 elenco.append(server);
  711.             }
  712.             if(gestioneFruitori) {
  713.                 this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_CAMBIO_EROGATORE_FRUIZIONE_CON_APPLICATIVO_SERVER,
  714.                         getLabelIdServizioSenzaErogatore(idService),
  715.                         elenco.toString()));
  716.             }
  717.             else {
  718.                 this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_CAMBIO_EROGATORE_CON_APPLICATIVO_SERVER,elenco.toString()));
  719.             }
  720.             return false;
  721.         }
  722.        
  723.        
  724.         // Verifico che il soggetto selezionato sia compatibile con una eventuale fruizione (se modifico da erogazione) o vicersa.
  725.         if(idSoggErogatore!=null && !"".equals(idSoggErogatore)) {
  726.             long idSoggettoErogatoreLong = Long.parseLong(idSoggErogatore);
  727.             Soggetto soggettoErogatoreSelezionato = this.soggettiCore.getSoggettoRegistro(idSoggettoErogatoreLong);
  728.            
  729.             // verifico che se esiste una erogazione, il soggetto selezionato nella fruizione sia compatibile
  730.             // se e' stato selezionato dall'erogazione lo sarà sicuramente
  731.             if(listaMappingErogazione!=null && !listaMappingErogazione.isEmpty()) {
  732.                 // esiste erogazione
  733.            
  734.                 ConsoleSearch searchSoggetti = new ConsoleSearch(true);
  735.                 searchSoggetti.addFilter(Liste.SOGGETTI, Filtri.FILTRO_PROTOCOLLO, protocollo);
  736.                 searchSoggetti.addFilter(Liste.SOGGETTI, Filtri.FILTRO_DOMINIO, SoggettiCostanti.SOGGETTO_DOMINIO_OPERATIVO_VALUE);
  737.                
  738.                 List<Soggetto> list = this.soggettiCore.soggettiRegistroList(null, searchSoggetti);
  739.                 boolean find = false;
  740.                 if(list!=null && !list.isEmpty()) {
  741.                     for (Soggetto soggetto : list) {
  742.                         if(soggettoErogatoreSelezionato.getTipo().equals(soggetto.getTipo()) &&
  743.                                 soggettoErogatoreSelezionato.getNome().equals(soggetto.getNome())) {
  744.                             find = true;
  745.                         }
  746.                     }
  747.                 }
  748.                 if(!find) {
  749.                     this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_CAMBIO_EROGATORE_NON_COMPATIBILE_CON_EROGAZIONE,
  750.                             getLabelIdServizioSenzaErogatore(idService)));
  751.                     return false;
  752.                 }
  753.             }
  754.            
  755.             // verifico che se esiste una fruizione, il soggetto selezionato nella erogazione sia compatibile
  756.             // se e' stato selezionato dalla fruizione lo sarà sicuramente
  757.             if(servizio.sizeFruitoreList()>0) {
  758.                 for (Fruitore fruitore : servizio.getFruitoreList()) {
  759.                     IDSoggetto idFruitore = new IDSoggetto(fruitore.getTipo(), fruitore.getNome());
  760.                     List<MappingFruizionePortaDelegata> listaMappingFruizione = null;
  761.                     try{
  762.                         listaMappingFruizione = this.apsCore.serviziFruitoriMappingList(idFruitore, idService, null);
  763.                     }catch(Exception e) {
  764.                         // ignore
  765.                     }
  766.                     if(listaMappingFruizione!=null && !listaMappingFruizione.isEmpty()) {
  767.                         // esiste fruizione
  768.                        
  769.                         ConsoleSearch searchSoggetti = new ConsoleSearch(true);
  770.                         searchSoggetti.addFilter(Liste.SOGGETTI, Filtri.FILTRO_PROTOCOLLO, protocollo);
  771.                         boolean gestioneFruitori_soggettiErogatori_escludiSoggettoFruitore = false;
  772.                         boolean filtraSoloEsterni = true;
  773.                         if(this.apsCore.isMultitenant() && this.apsCore.getMultitenantSoggettiFruizioni()!=null) {
  774.                             switch (this.apsCore.getMultitenantSoggettiFruizioni()) {
  775.                             case SOLO_SOGGETTI_ESTERNI:
  776.                                 filtraSoloEsterni = true;
  777.                                 break;
  778.                             case ESCLUDI_SOGGETTO_FRUITORE:
  779.                                 filtraSoloEsterni = false;
  780.                                 gestioneFruitori_soggettiErogatori_escludiSoggettoFruitore = true;
  781.                                 break;
  782.                             case TUTTI:
  783.                                 filtraSoloEsterni = false;
  784.                                 break;
  785.                             }
  786.                         }
  787.                         if(filtraSoloEsterni) {
  788.                             searchSoggetti.addFilter(Liste.SOGGETTI, Filtri.FILTRO_DOMINIO, SoggettiCostanti.SOGGETTO_DOMINIO_ESTERNO_VALUE);
  789.                         }
  790.                         List<Soggetto> list = this.soggettiCore.soggettiRegistroList(null, searchSoggetti);                                
  791.                         if(gestioneFruitori_soggettiErogatori_escludiSoggettoFruitore && list!=null && !list.isEmpty()) {
  792.                             for (int i = 0; i < list.size(); i++) {
  793.                                 Soggetto soggettoCheck = list.get(i);
  794.                                 if(soggettoCheck.getTipo().equals(fruitore.getTipo()) && soggettoCheck.getNome().equals(fruitore.getNome())) {
  795.                                     list.remove(i);
  796.                                     break;
  797.                                 }
  798.                             }
  799.                         }
  800.                         boolean find = false;
  801.                         if(list!=null && !list.isEmpty()) {
  802.                             for (Soggetto soggetto : list) {
  803.                                 if(soggettoErogatoreSelezionato.getTipo().equals(soggetto.getTipo()) &&
  804.                                         soggettoErogatoreSelezionato.getNome().equals(soggetto.getNome())) {
  805.                                     find = true;
  806.                                 }
  807.                             }
  808.                         }
  809.                         if(!find) {
  810.                             String labelFruizione = null;
  811.                             String labelFruitore = this.getLabelNomeSoggetto(protocollo, idFruitore);
  812.                             labelFruizione = labelFruitore + " -> " + getLabelIdServizioSenzaErogatore(idService);
  813.                             this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_CAMBIO_EROGATORE_NON_COMPATIBILE_CON_FRUIZIONE,
  814.                                     labelFruizione));
  815.                             return false;
  816.                         }
  817.                     }
  818.                 }
  819.             }
  820.         }
  821.         return true;
  822.     }
  823.    
  824.     private String getServiziCheckDataIdSoggettoErogatoreAsString(long idServizio){
  825.         try {
  826.             AccordoServizioParteSpecifica servizio = this.apsCore.getAccordoServizioParteSpecifica(idServizio);
  827.             return servizio.getIdSoggetto().toString();
  828.         } catch (DriverRegistroServiziNotFound | DriverRegistroServiziException e) {
  829.             // ignore
  830.         }
  831.         return null;
  832.     }
  833.    
  834.     // Controlla i dati dei Servizi
  835.     public boolean serviziCheckData(TipoOperazione tipoOp, String[] soggettiList,
  836.             String[] accordiList, String oldNomeservizio,
  837.             String oldTiposervizio, int oldVersioneServizio,
  838.             String nomeservizio,
  839.             String tiposervizio, String idSoggErogatore,
  840.             String nomeErogatore, String tipoErogatore, String idAccordo, ServiceBinding serviceBinding,
  841.             String servcorr, String endpointtype, String url, String nome,
  842.             String tipo, String user, String password, String initcont,
  843.             String urlpgk, String provurl, String connfact, String sendas,
  844.             BinaryParameter wsdlimpler, BinaryParameter wsdlimplfru, String id,
  845.             String profilo, String portType, String[] ptList,
  846.             boolean visibilitaAccordoServizio,boolean visibilitaServizio,
  847.             String httpsurl, String httpstipologia, boolean httpshostverify,
  848.             boolean httpsTrustVerifyCert, String httpspath, String httpstipo, String httpspwd,
  849.             String httpsalgoritmo, boolean httpsstato, String httpskeystore,
  850.             String httpspwdprivatekeytrust, String httpspathkey,
  851.             String httpstipokey, String httpspwdkey,
  852.             String httpspwdprivatekey, String httpsalgoritmokey,
  853.             String httpsKeyAlias, String httpsTrustStoreCRLs, String httpsTrustStoreOCSPPolicy, String httpsKeyStoreBYOKPolicy,
  854.             String tipoconn, String versione,
  855.             boolean validazioneDocumenti,  String backToStato,
  856.             String autenticazioneHttp,
  857.             String proxyEnabled, String proxyHost, String proxyPort, String proxyUsername, String proxyPassword,
  858.             String tempiRispostaEnabled, String tempiRispostaConnectionTimeout, String tempiRispostaReadTimeout, String tempiRispostaTempoMedioRisposta,
  859.             String opzioniAvanzate, String transferMode, String transferModeChunkSize, String redirectMode, String redirectMaxHop,
  860.             String requestOutputFileName, String requestOutputFileNamePermissions, String requestOutputFileNameHeaders, String requestOutputFileNameHeadersPermissions,
  861.             String requestOutputParentDirCreateIfNotExists,String requestOutputOverwriteIfExists,
  862.             String responseInputMode, String responseInputFileName, String responseInputFileNameHeaders, String responseInputDeleteAfterRead, String responseInputWaitTime,
  863.             String erogazioneSoggetto,String erogazioneRuolo,String erogazioneAutenticazione,String erogazioneAutenticazioneOpzionale, TipoAutenticazionePrincipal erogazioneAutenticazionePrincipal, List<String> erogazioneAutenticazioneParametroList, String erogazioneAutorizzazione,
  864.             String erogazioneAutorizzazioneAutenticati,String erogazioneAutorizzazioneRuoli, String erogazioneAutorizzazioneRuoliTipologia, String erogazioneAutorizzazioneRuoliMatch,boolean isSupportatoAutenticazione,
  865.             boolean generaPACheckSoggetto, List<ExtendedConnettore> listExtendedConnettore,
  866.             String fruizioneServizioApplicativo,String fruizioneRuolo,String fruizioneAutenticazione,String fruizioneAutenticazioneOpzionale, TipoAutenticazionePrincipal fruizioneAutenticazionePrincipal, List<String> fruizioneAutenticazioneParametroList, String fruizioneAutorizzazione,
  867.             String fruizioneAutorizzazioneAutenticati,String fruizioneAutorizzazioneRuoli, String fruizioneAutorizzazioneRuoliTipologia, String fruizioneAutorizzazioneRuoliMatch,
  868.             String protocollo,BinaryParameter allegatoXacmlPolicy,
  869.             String descrizione, String tipoFruitore, String nomeFruitore,
  870.             boolean autenticazioneToken, String tokenPolicy,
  871.             String autenticazioneApiKey, boolean useOAS3Names, boolean useAppId, String apiKeyHeader, String apiKeyValue, String appIdHeader, String appIdValue,
  872.             boolean erogazioneServizioApplicativoServerEnabled, String erogazioneServizioApplicativoServer, String canaleStato, String canale, boolean gestioneCanaliEnabled)   throws Exception {

  873.         boolean isModalitaAvanzata = this.isModalitaAvanzata();

  874.         try{
  875.             if(erogazioneSoggetto!=null || erogazioneRuolo!=null || fruizioneServizioApplicativo!=null || fruizioneRuolo!=null || descrizione!=null) {
  876.                 // nop
  877.             }

  878.             String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  879.             boolean gestioneFruitori = false;
  880.             boolean gestioneErogatori = false;
  881.             if(tipologia!=null) {
  882.                 if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  883.                     gestioneFruitori = true;
  884.                 }
  885.                 else if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE.equals(tipologia)) {
  886.                     gestioneErogatori = true;
  887.                 }
  888.             }
  889.            
  890.             // ripristina dello stato solo in modalita change
  891.             if(backToStato != null && tipoOp.equals(TipoOperazione.CHANGE)){
  892.                 return true;
  893.             }

  894.             int idInt = 0;
  895.             if (tipoOp.equals(TipoOperazione.CHANGE)) {
  896.                 idInt = Integer.parseInt(id);
  897.             }
  898.             if (idSoggErogatore == null) {
  899.                 idSoggErogatore = "";
  900.             }
  901.             if (idAccordo == null) {
  902.                 idAccordo = "";
  903.             }
  904.             if (url == null) {
  905.                 url = "";
  906.             }
  907.             if (nome == null) {
  908.                 nome = "";
  909.             }
  910.             if (tipo == null) {
  911.                 tipo = "";
  912.             }
  913.             if (user == null) {
  914.                 user = "";
  915.             }
  916.             if (password == null) {
  917.                 password = "";
  918.             }
  919.             if (initcont == null) {
  920.                 initcont = "";
  921.             }
  922.             if (urlpgk == null) {
  923.                 urlpgk = "";
  924.             }
  925.             if (provurl == null) {
  926.                 provurl = "";
  927.             }
  928.             if (connfact == null) {
  929.                 connfact = "";
  930.             }
  931.             if (sendas == null) {
  932.                 sendas = "";
  933.             }
  934.             if (versione == null) {
  935.                 versione = "";
  936.             }

  937.             // Visibilita rispetto all'accordo
  938.             boolean nonVisibile = true;
  939.             boolean visibile = false;
  940.             if( (visibilitaServizio==visibile)
  941.                     &&
  942.                 (visibilitaAccordoServizio==nonVisibile)
  943.                 ){
  944.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_USO_ACCORDO_SERVIZIO_CON_VISIBILITA_PRIVATA_IN_UN_SERVIZIO_CON_VISIBILITA_PUBBLICA);
  945.                 return false;
  946.             }

  947.             Integer versioneInt = 1;
  948.             if(versione!=null && !"".equals(versione)){
  949.                 versioneInt = Integer.parseInt(versione);
  950.             }
  951.             else {
  952.                 versione = "1";
  953.                 versioneInt = 1;
  954.             }
  955.            
  956.             String oldTipoSoggettoErogatore = null;
  957.             String oldNomeSoggettoErogatore = null;
  958.             boolean cambiaErogatore = false;
  959.             boolean modificaVersioneApi = false;
  960.            
  961.             if (tipoOp.equals(TipoOperazione.CHANGE)) {

  962.                 String tmpModificaVersioneApi = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_API);
  963.                 if(tmpModificaVersioneApi!=null) {
  964.                     modificaVersioneApi = "true".equals(tmpModificaVersioneApi);
  965.                 }
  966.                
  967.                 String tmpCambiaSoggettoErogatore = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_CAMBIA_SOGGETTO_EROGATORE);
  968.                 if(tmpCambiaSoggettoErogatore!=null) {
  969.                     cambiaErogatore = "true".equals(tmpCambiaSoggettoErogatore);
  970.                 }
  971.                
  972.                 if(modificaVersioneApi) {
  973.                    
  974.                     AccordoServizioParteSpecifica servizio = this.apsCore.getAccordoServizioParteSpecifica(idInt);
  975.                     long idAccordoLong = Long.parseLong(idAccordo);
  976.                     boolean isOk = checkModificaVersioneApi(servizio,
  977.                             idAccordoLong, serviceBinding, portType,
  978.                             gestioneFruitori, gestioneErogatori);
  979.                     if(!isOk) {
  980.                         return false; // messaggio scritto nel metodo
  981.                     }
  982.                     idSoggErogatore = servizio.getIdSoggetto().toString();
  983.                 }
  984.                 else if(cambiaErogatore) {
  985.                     AccordoServizioParteSpecifica servizio = this.apsCore.getAccordoServizioParteSpecifica(idInt);
  986.                     oldTipoSoggettoErogatore = servizio.getTipoSoggettoErogatore();
  987.                     oldNomeSoggettoErogatore = servizio.getNomeSoggettoErogatore();
  988.                    
  989.                     boolean isOk =  checkCambioErogatore(servizio, gestioneFruitori, gestioneErogatori,
  990.                             idSoggErogatore, protocollo);
  991.                     if(!isOk) {
  992.                         return false; // messaggio scritto nel metodo
  993.                     }
  994.                 }
  995.                 else {
  996.                     @SuppressWarnings("unused")
  997.                     IDServizio idService = this.idServizioFactory.getIDServizioFromValues(tiposervizio, nomeservizio,
  998.                             tipoErogatore, nomeErogatore, versioneInt);
  999.                    
  1000.                     idSoggErogatore = getServiziCheckDataIdSoggettoErogatoreAsString(idInt);
  1001.                 }
  1002.                
  1003.             }

  1004.             // Campi obbligatori
  1005.             if (idAccordo.equals("")) {
  1006.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_API_NON_INDICATA);
  1007.                 return false;
  1008.             }
  1009.            
  1010.             if (nomeservizio.equals("") || tiposervizio.equals("") || idSoggErogatore.equals("") || idAccordo.equals("") || versione.equals("")) {
  1011.                 String tmpElenco = "";
  1012.                 if (nomeservizio.equals("")) {
  1013.                     tmpElenco = AccordiServizioParteSpecificaCostanti.LABEL_APS_NOME_SERVIZIO;
  1014.                 }
  1015.                 if (tiposervizio.equals("")) {
  1016.                     if (tmpElenco.equals("")) {
  1017.                         tmpElenco = AccordiServizioParteSpecificaCostanti.LABEL_APS_TIPO_SERVIZIO;
  1018.                     } else {
  1019.                         tmpElenco = tmpElenco + ", " + AccordiServizioParteSpecificaCostanti.LABEL_APS_TIPO_SERVIZIO;
  1020.                     }
  1021.                 }
  1022.                 if (idSoggErogatore.equals("")) {
  1023.                     if (tmpElenco.equals("")) {
  1024.                         tmpElenco = AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO;
  1025.                     } else {
  1026.                         tmpElenco = tmpElenco + ", " + AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO;
  1027.                     }
  1028.                 }
  1029.                 if (idAccordo.equals("")) {
  1030.                     if (tmpElenco.equals("")) {
  1031.                         tmpElenco = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO_SOLO_PARTE_COMUNE;
  1032.                     } else {
  1033.                         tmpElenco = tmpElenco + ", " + AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO_SOLO_PARTE_COMUNE;
  1034.                     }
  1035.                 }
  1036.                 if (versione.equals("")) {
  1037.                     if (tmpElenco.equals("")) {
  1038.                         tmpElenco = AccordiServizioParteSpecificaCostanti.LABEL_APS_VERSIONE_APS;
  1039.                     } else {
  1040.                         tmpElenco = tmpElenco + ", " + AccordiServizioParteSpecificaCostanti.LABEL_APS_VERSIONE_APS;
  1041.                     }  
  1042.                 }
  1043.                 this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_CON_PARAMETRO, tmpElenco));
  1044.                 return false;
  1045.             }
  1046.            
  1047.             if (!isModalitaAvanzata || this.apsCore.isPortTypeObbligatorioImplementazioniSOAP()) {
  1048.                 switch (serviceBinding) {
  1049.                 case REST:
  1050.                    
  1051.                     break;
  1052.                 case SOAP:
  1053.                 default:
  1054.                     if (portType == null || "".equals(portType) || "-".equals(portType)) {
  1055.                         if(ptList==null || ptList.length == 0){
  1056.                             this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_SERVIZIO_OBBLIGATORIO_PORT_TYPE_NON_PRESENTI);
  1057.                             return false;
  1058.                         }
  1059.                        
  1060.                         this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_SERVIZIO_OBBLIGATORIO);
  1061.                         return false;
  1062.                     }
  1063.                     break;
  1064.                 }
  1065.             }
  1066.            

  1067.             // Controllo che non ci siano spazi nei campi di testo
  1068.             if ((nomeservizio.indexOf(" ") != -1) || (tiposervizio.indexOf(" ") != -1)) {
  1069.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_SPAZI_BIANCHI_NON_CONSENTITI);
  1070.                 return false;
  1071.             }

  1072.             // Il nome deve contenere solo lettere e numeri e '_' '-' '.'
  1073.             if(!this.checkNCName(nomeservizio,AccordiServizioParteSpecificaCostanti.LABEL_APS_NOME_SERVIZIO)){
  1074.                 return false;
  1075.             }

  1076.             // Il tipo deve contenere solo lettere e numeri
  1077.             if(!this.checkNCName(tiposervizio,AccordiServizioParteSpecificaCostanti.LABEL_APS_TIPO_SERVIZIO)){
  1078.                 return false;
  1079.             }

  1080.             // Versione deve essere un numero intero
  1081.             if (!versione.equals("") && !this.checkNumber(versione, AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VERSIONE, false)) {
  1082.                 return false;
  1083.             }
  1084.            
  1085.             // Check lunghezza
  1086.             if(!this.checkLength255(nomeservizio, AccordiServizioParteSpecificaCostanti.LABEL_APS_NOME_SERVIZIO)) {
  1087.                 return false;
  1088.             }
  1089.             if(descrizione!=null && !"".equals(descrizione) &&
  1090.                 !this.checkLength4000(descrizione, AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_DESCRIZIONE)) {
  1091.                 return false;
  1092.             }
  1093.            
  1094.             if (tipoOp.equals(TipoOperazione.ADD) &&
  1095.                 (!this.canaleCheckData(canaleStato, canale, gestioneCanaliEnabled))
  1096.             ){
  1097.                 return false;
  1098.             }
  1099.            
  1100.             // Controllo dell'end-point
  1101.             // Non li puo' prendere dalla servtlet
  1102.             boolean connettoreStatic = false;
  1103.             if(gestioneFruitori) {
  1104.                 connettoreStatic = this.apsCore.isConnettoreStatic(protocollo);
  1105.             }
  1106.             if(!connettoreStatic &&
  1107.                 !this.endPointCheckData(serviceBinding, protocollo, gestioneErogatori,
  1108.                         endpointtype, url, nome, tipo,
  1109.                         user, password, initcont, urlpgk, provurl, connfact,
  1110.                         sendas, httpsurl, httpstipologia, httpshostverify,
  1111.                         httpsTrustVerifyCert, httpspath, httpstipo, httpspwd, httpsalgoritmo, httpsstato,
  1112.                         httpskeystore, httpspwdprivatekeytrust, httpspathkey,
  1113.                         httpstipokey, httpspwdkey,
  1114.                         httpspwdprivatekey, httpsalgoritmokey,
  1115.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  1116.                         tipoconn,autenticazioneHttp,
  1117.                         proxyEnabled, proxyHost, proxyPort, proxyUsername, proxyPassword,
  1118.                         tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  1119.                         opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  1120.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  1121.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  1122.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  1123.                         autenticazioneToken, tokenPolicy,
  1124.                         autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  1125.                         listExtendedConnettore,erogazioneServizioApplicativoServerEnabled,erogazioneServizioApplicativoServer)) {
  1126.                 return false;
  1127.             }

  1128.             // Controllo che i campi "checkbox" abbiano uno dei valori
  1129.             // ammessi
  1130.             if ((servcorr != null) && !servcorr.equals(Costanti.CHECK_BOX_ENABLED) && !servcorr.equals(Costanti.CHECK_BOX_DISABLED)) {
  1131.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_SERVIZIO_CORRELATO_DEV_ESSERE_SELEZIONATO_O_DESELEZIONATO);
  1132.                 return false;
  1133.             }

  1134.             // Controllo che il provider appartenga alla lista di
  1135.             // providers disponibili
  1136.             boolean trovatoProv = false;
  1137.             for (int i = 0; i < soggettiList.length; i++) {
  1138.                 String tmpSogg = soggettiList[i];
  1139.                 if (tmpSogg.equals(idSoggErogatore)) {
  1140.                     trovatoProv = true;
  1141.                 }
  1142.             }
  1143.             if (!trovatoProv) {
  1144.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_IL_SOGGETTO_INDICATO_NON_AUTORIZZATO_A_EROGARE);
  1145.                 return false;
  1146.             }

  1147.             // Controllo che l'accordo appartenga alla lista di
  1148.             // accordi disponibili
  1149.             boolean trovatoAcc = false;
  1150.             for (int i = 0; i < accordiList.length; i++) {
  1151.                 String tmpAcc = accordiList[i];
  1152.                 if (tmpAcc.equals(idAccordo)) {
  1153.                     trovatoAcc = true;
  1154.                 }
  1155.             }
  1156.             if (!trovatoAcc) {
  1157.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ACCORDO_SERVIZIO_DEV_ESSERE_SCELTO_TRA_QUELLI_DEFINITI_NEL_PANNELLO_ACCORDI_SERVIZIO);
  1158.                 return false;
  1159.             }


  1160.             // Visibilita rispetto al soggetto erogatore
  1161.             if(visibilitaServizio==visibile){
  1162.                 org.openspcoop2.core.registry.Soggetto tmpSogg = this.soggettiCore.getSoggettoRegistro(new IDSoggetto(tipoErogatore, nomeErogatore));
  1163.                 if(tmpSogg.getPrivato()!=null && tmpSogg.getPrivato()){
  1164.                     this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_USO_SOGGETTO_EROGATORE_CON_VISIBILITA_PRIVATA_IN_UN_SERVIZIO_CON_VISIBILITA_PUBBLICA);
  1165.                     return false;
  1166.                 }
  1167.             }


  1168.             // Se il connettore e' disabilitato devo controllare che il
  1169.             // connettore del soggetto non sia disabilitato se è di tipo operativo
  1170.             if(!gestioneFruitori && !gestioneErogatori && !connettoreStatic &&
  1171.                  (endpointtype.equals(TipiConnettore.DISABILITATO.getNome()))
  1172.                  ){
  1173.                 String eptypeprov = TipiConnettore.DISABILITATO.getNome();

  1174.                 org.openspcoop2.core.registry.Soggetto soggetto = this.soggettiCore.getSoggettoRegistro(new IDSoggetto(tipoErogatore, nomeErogatore));
  1175.                 if(this.pddCore.isPddEsterna(soggetto.getPortaDominio())){
  1176.                     Connettore connettore = soggetto.getConnettore();
  1177.                     if ((connettore != null) && (connettore.getTipo() != null)) {
  1178.                         eptypeprov = connettore.getTipo();
  1179.                     }
  1180.    
  1181.                     if (eptypeprov.equals(TipiConnettore.DISABILITATO.getNome())) {
  1182.                         if(!this.isModalitaCompleta() && tipoOp.equals(TipoOperazione.ADD)) {
  1183.                             this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_IL_CONNETTORE_SUL_SERVIZIO_NON_PUO_ESSERE_DISABILITATO_POICHE_NON_E_STATO_DEFINITO_UN_CONNETTORE_EROGAZIONE);
  1184.                         }
  1185.                         else {
  1186.                             this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_IL_CONNETTORE_DEL_SERVIZIO_DEVE_ESSERE_SPECIFICATO_SE_NON_EGRAVE_STATO_DEFINITO_UN_CONNETTORE_PER_IL_SOGGETTO_EROGATORE);
  1187.                         }
  1188.                         return false;
  1189.                     }
  1190.                 }
  1191.                 else{
  1192.                     if(tipoOp.equals(TipoOperazione.CHANGE)){
  1193.                         boolean escludiSoggettiEsterni = true;
  1194.                         boolean trovatoServ = this.apsCore.existFruizioniServizioWithoutConnettore(idInt,escludiSoggettiEsterni);
  1195.                         if (trovatoServ) {
  1196.                             this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_IL_CONNETTORE_SUL_SERVIZIO_NON_PUO_ESSERE_DISABILITATO_POICHE_NON_E_STATO_DEFINITO_UN_CONNETTORE_SUL_SOGGETTO_EROGATORE_ED_ESISTONO_FRUIZIONI_DEL_SERVIZIO_DA_PARTE_DI_SOGGETTI_OPERATIVI_CHE_NON_HANNO_UN_CONNETTORE_DEFINITO);
  1197.                             return false;
  1198.                         }
  1199.                     }
  1200.                    
  1201.                     else {
  1202.                         if(!this.isModalitaCompleta() && generaPACheckSoggetto) {
  1203.                             this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_IL_CONNETTORE_SUL_SERVIZIO_NON_PUO_ESSERE_DISABILITATO_POICHE_NON_E_STATO_DEFINITO_UN_CONNETTORE_EROGAZIONE);
  1204.                             return false;
  1205.                         }
  1206.                     }
  1207.                 }
  1208.             }

  1209.             // idSoggettoErogatore
  1210.             long idSoggettoErogatore = Long.parseLong(idSoggErogatore);
  1211.             if (idSoggettoErogatore < 0)
  1212.                 throw new ControlStationCoreException(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ID_SOGGETTO_EROGATORE_NON_DEFINITO);

  1213.             // idAccordo Servizio
  1214.             long idAccordoServizio = Long.parseLong(idAccordo);
  1215.             if (idAccordoServizio < 0)
  1216.                 throw new ControlStationCoreException(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ID_ACCORDO_SERVIZIO_NON_DEFINITO);

  1217.             // Dati Servizio
  1218.             long idSoggettoErogatoreLong = Long.parseLong(idSoggErogatore);
  1219.             Soggetto soggettoErogatore = this.soggettiCore.getSoggettoRegistro(idSoggettoErogatoreLong);
  1220.             tipoErogatore = soggettoErogatore.getTipo();
  1221.             nomeErogatore = soggettoErogatore.getNome();
  1222.             long idAccordoServizioParteComuneLong = Long.parseLong(idAccordo);
  1223.             AccordoServizioParteComuneSintetico accordoServizioParteComune = this.apcCore.getAccordoServizioSintetico(idAccordoServizioParteComuneLong);
  1224.             String uriAccordoServizioParteComune = this.idAccordoFactory.getUriFromAccordo(accordoServizioParteComune);
  1225.             IDServizio idAccordoServizioParteSpecifica = this.idServizioFactory.getIDServizioFromValues(tiposervizio, nomeservizio,
  1226.                     tipoErogatore, nomeErogatore, versioneInt);
  1227.            
  1228.             // Controllo non esistenza gia' del servizio
  1229.             if (
  1230.                     (!tipoOp.equals(TipoOperazione.CHANGE))
  1231.                     ||
  1232.                     (
  1233.                             tipoOp.equals(TipoOperazione.CHANGE)
  1234.                             &&
  1235.                             (
  1236.                                 (!oldTiposervizio.equals(tiposervizio))
  1237.                                     ||
  1238.                                 (!oldNomeservizio.equals(nomeservizio))
  1239.                                     ||
  1240.                                 (oldVersioneServizio!=versioneInt)
  1241.                                     ||
  1242.                                 (cambiaErogatore
  1243.                                     &&
  1244.                                     (
  1245.                                         (!oldTipoSoggettoErogatore.equals(tipoErogatore))
  1246.                                             ||
  1247.                                         (!oldNomeSoggettoErogatore.equals(nomeErogatore))
  1248.                                     )
  1249.                                 )
  1250.                             )
  1251.                     )
  1252.                 ){
  1253.                
  1254.                 StringBuilder inUsoMessage = new StringBuilder();
  1255.                
  1256.                 boolean alreadyExists = AccordiServizioParteSpecificaUtilities.alreadyExists(this.apsCore, this,
  1257.                         idSoggettoErogatore, idAccordoServizioParteSpecifica, uriAccordoServizioParteComune,
  1258.                         tipoFruitore, nomeFruitore,
  1259.                         protocollo, profilo, portType,
  1260.                         gestioneFruitori, gestioneErogatori,
  1261.                         inUsoMessage);
  1262.                
  1263.                 if(alreadyExists) {
  1264.                     this.pd.setMessage(inUsoMessage.toString());
  1265.                     return false;
  1266.                 }
  1267.             }

  1268.             /*
  1269.              * Controllo che non esistano 2 servizi con stesso soggetto erogatore e accordo di servizio
  1270.              * che siano entrambi correlati o non correlati.
  1271.              * Al massimo possono esistere 2 servizi di uno stesso accordo erogati da uno stesso soggetto,
  1272.              * purche' siano uno correlato e uno no.
  1273.              * Se tipoOp = change, devo fare attenzione a non escludere il servizio selezionato che sto
  1274.              * cambiando
  1275.              */
  1276.            
  1277.             long idAccordoServizioParteSpecificaLong = idInt;
  1278.             boolean servizioCorrelato = false;
  1279.             if ((servcorr != null) && (servcorr.equals(Costanti.CHECK_BOX_ENABLED) || servcorr.equals(CostantiConfigurazione.ABILITATO.getValue()))) {
  1280.                 servizioCorrelato = true;
  1281.             }
  1282.             try{
  1283.                 this.apsCore.controlloUnicitaImplementazioneAccordoPerSoggetto(portType,
  1284.                         new IDSoggetto(soggettoErogatore.getTipo(), soggettoErogatore.getNome()), idSoggettoErogatoreLong,
  1285.                         this.idAccordoFactory.getIDAccordoFromAccordo(accordoServizioParteComune), idAccordoServizioParteComuneLong,
  1286.                         idAccordoServizioParteSpecifica, idAccordoServizioParteSpecificaLong,
  1287.                         tipoOp, servizioCorrelato);
  1288.             }catch(Exception e){
  1289.                 this.pd.setMessage(e.getMessage());
  1290.                 return false;
  1291.             }

  1292.            
  1293.             // Controllo che non esistano altri accordi di servizio parte specifica con stesso nome, versione e soggetto
  1294.             if (tipoOp.equals(TipoOperazione.ADD)){
  1295.                 if(!gestioneFruitori && !gestioneErogatori && this.apsCore.existsAccordoServizioParteSpecifica(idAccordoServizioParteSpecifica)){
  1296.                     /**if(this.apsCore.isSupportatoVersionamentoAccordiServizioParteSpecifica(protocollo))*/
  1297.                     this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ESISTE_GIA_UN_ACCORDO_DI_SERVIZIO_PARTE_SPECIFICA_CON_TIPO_NOME_VERSIONE_E_SOGGETTO_INDICATO);
  1298.                     /**else
  1299.                     //  this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ESISTE_GIA_UN_ACCORDO_DI_SERVIZIO_PARTE_SPECIFICA_CON_TIPO_NOME_VERSIONE_E_SOGGETTO_INDICATO);*/
  1300.                     return false;
  1301.                 }
  1302.             }else{
  1303.                 // change
  1304.                
  1305.                 try{
  1306.                     AccordoServizioParteSpecifica servizio =  this.apsCore.getServizio(idAccordoServizioParteSpecifica);
  1307.                     if(servizio!=null &&
  1308.                         (idInt != servizio.getId())
  1309.                         ){
  1310.                         if(!gestioneFruitori && !gestioneErogatori) {
  1311.                             /**if(this.apsCore.isSupportatoVersionamentoAccordiServizioParteSpecifica(protocollo))*/
  1312.                                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ESISTE_GIA_UN_ACCORDO_DI_SERVIZIO_PARTE_SPECIFICA_CON_TIPO_NOME_VERSIONE_E_SOGGETTO_INDICATO);
  1313.                             /**else
  1314.                             //  this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ESISTE_GIA_UN_ACCORDO_DI_SERVIZIO_PARTE_SPECIFICA_CON_TIPO_NOME_VERSIONE_E_SOGGETTO_INDICATO);*/
  1315.                             return false;
  1316.                         }
  1317.                         else {
  1318.                             // Per adesso non gestito, vedi spiegazione nel metodo
  1319.                             if(!AccordiServizioParteSpecificaCostanti.isModificaDatiIdentificativiVersoApsEsistente()) {
  1320.                                 if(gestioneFruitori) {
  1321.                                     this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_CAMBIO_EROGATORE_NON_COMPATIBILE_ESISTE_EROGAZIONE,
  1322.                                             this.getLabelIdServizio(servizio)));
  1323.                                 }
  1324.                                 else {
  1325.                                     this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_CAMBIO_EROGATORE_NON_COMPATIBILE_ESISTE_FRUIZIONE,
  1326.                                             this.getLabelIdServizio(servizio)));
  1327.                                 }
  1328.                                 return false;
  1329.                             }
  1330.                         }
  1331.                     }
  1332.                 }catch(DriverRegistroServiziNotFound dNotFound){
  1333.                     // ignore
  1334.                 }
  1335.             }

  1336.             // Lettura accordo di servizio
  1337.             AccordoServizioParteComune as = null;
  1338.             try{
  1339.                 as = this.apcCore.getAccordoServizioFull(Long.parseLong(idAccordo));
  1340.             }catch(Exception e){
  1341.                 this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_API_SELEZIONATA_NON_ESISTENTE_CON_PARAMETRI, idAccordo,
  1342.                         e.getMessage()));
  1343.                 return false;
  1344.             }

  1345.             AccordoServizioParteSpecifica aps = new AccordoServizioParteSpecifica();
  1346.             aps.setTipo(tiposervizio);
  1347.             aps.setNome(nomeservizio);
  1348.             if(versione!=null)
  1349.                 aps.setVersione(Integer.parseInt(versione));
  1350.             if(Costanti.CHECK_BOX_ENABLED.equals(servcorr)){
  1351.                 aps.setTipologiaServizio(TipologiaServizio.CORRELATO);
  1352.             }
  1353.             else{
  1354.                 aps.setTipologiaServizio(TipologiaServizio.NORMALE);
  1355.             }
  1356.             aps.setTipoSoggettoErogatore(tipoErogatore);
  1357.             aps.setNomeSoggettoErogatore(nomeErogatore);

  1358.             ValidazioneResult v = this.apsCore.validazione(aps, this.soggettiCore);
  1359.             if(!v.isEsito()){
  1360.                 String msg = MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_VALIDAZIONE_PROTOCOLLO_CON_PARAMETRI, protocollo, v.getMessaggioErrore());
  1361.                 this.pd.setMessage(msg);
  1362.                 if(v.getException()!=null)
  1363.                     this.logError(msg,v.getException());
  1364.                 else
  1365.                     this.logError(msg);
  1366.                 return false;
  1367.             }  

  1368.             // Validazione Documenti
  1369.             if(validazioneDocumenti && tipoOp.equals(TipoOperazione.ADD)){
  1370.                
  1371.                 FormatoSpecifica formato = null;
  1372.                 if(as!=null) {
  1373.                     formato = as.getFormatoSpecifica();
  1374.                 }
  1375.                
  1376.                 String wsdlimplerS = wsdlimpler.getValue() != null ? new String(wsdlimpler.getValue()) : null;
  1377.                 byte [] wsdlImplementativoErogatore = this.apsCore.getInterfaceAsByteArray(formato, wsdlimplerS);
  1378.                 String wsdlimplfruS = wsdlimplfru.getValue() != null ? new String(wsdlimplfru.getValue()) : null;
  1379.                 byte [] wsdlImplementativoFruitore = this.apsCore.getInterfaceAsByteArray(formato, wsdlimplfruS);
  1380.                
  1381.                 aps.setByteWsdlImplementativoErogatore(wsdlImplementativoErogatore);
  1382.                 aps.setByteWsdlImplementativoFruitore(wsdlImplementativoFruitore);

  1383.                 ValidazioneResult result = this.apsCore.validaInterfacciaWsdlParteSpecifica(aps, as, this.soggettiCore);
  1384.                 if(!result.isEsito()){
  1385.                     this.pd.setMessage(result.getMessaggioErrore());
  1386.                     return false;
  1387.                 }  

  1388.             }

  1389.             if(tipoOp.equals(TipoOperazione.ADD)){
  1390.                
  1391.                 String gestioneToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN);
  1392.                 String gestioneTokenPolicy = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  1393.                 String gestioneTokenValidazioneInput = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  1394.                 String gestioneTokenIntrospection = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  1395.                 String gestioneTokenUserInfo = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  1396.                 String gestioneTokenTokenForward = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  1397.                
  1398.                 String autorizzazioneAutenticatiToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE_TOKEN);
  1399.                 String autorizzazioneRuoliToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_TOKEN);
  1400.                
  1401.                 String autorizzazioneToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN);
  1402.                 String autorizzazioneTokenOptions = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_OPTIONS);
  1403.                 String autorizzazioneScope = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE);
  1404.                 String autorizzazioneScopeMatch = this.getParameter(CostantiControlStation.PARAMETRO_SCOPE_MATCH);

  1405.                 String autorizzazioneContenutiStato = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_STATO);
  1406.                 String autorizzazioneContenuti = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI);
  1407.                 String autorizzazioneContenutiProperties = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_PROPERTIES);
  1408.                
  1409.                 String identificazioneAttributiStato = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO);
  1410.                 String [] attributeAuthoritySelezionate = this.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  1411.                 String attributeAuthorityAttributi = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI);
  1412.                
  1413.                 if(gestioneFruitori) {
  1414.                    
  1415.                     if(this.controlloAccessiCheck(tipoOp, fruizioneAutenticazione, fruizioneAutenticazioneOpzionale, fruizioneAutenticazionePrincipal, fruizioneAutenticazioneParametroList,
  1416.                             fruizioneAutorizzazione, fruizioneAutorizzazioneAutenticati, fruizioneAutorizzazioneRuoli,
  1417.                             fruizioneAutorizzazioneRuoliTipologia, fruizioneAutorizzazioneRuoliMatch,
  1418.                             true, true, null, null,gestioneToken, gestioneTokenPolicy,
  1419.                             gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  1420.                             autorizzazioneAutenticatiToken, autorizzazioneRuoliToken,
  1421.                             autorizzazioneToken,autorizzazioneTokenOptions,
  1422.                             autorizzazioneScope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  1423.                             autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties,
  1424.                             protocollo,
  1425.                             identificazioneAttributiStato, attributeAuthoritySelezionate, attributeAuthorityAttributi)==false){
  1426.                         return false;
  1427.                     }
  1428.                 }
  1429.                 else {
  1430.                
  1431.                    
  1432.                     if(this.controlloAccessiCheck(tipoOp, erogazioneAutenticazione, erogazioneAutenticazioneOpzionale, erogazioneAutenticazionePrincipal, erogazioneAutenticazioneParametroList,
  1433.                             erogazioneAutorizzazione, erogazioneAutorizzazioneAutenticati, erogazioneAutorizzazioneRuoli,
  1434.                             erogazioneAutorizzazioneRuoliTipologia, erogazioneAutorizzazioneRuoliMatch,
  1435.                             isSupportatoAutenticazione, false, null, null,gestioneToken, gestioneTokenPolicy,
  1436.                             gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  1437.                             autorizzazioneAutenticatiToken, autorizzazioneRuoliToken,
  1438.                             autorizzazioneToken,autorizzazioneTokenOptions,
  1439.                             autorizzazioneScope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  1440.                             autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties,
  1441.                             protocollo,
  1442.                             identificazioneAttributiStato, attributeAuthoritySelezionate, attributeAuthorityAttributi)==false){
  1443.                         return false;
  1444.                     }
  1445.                 }
  1446.             }
  1447.            
  1448.            
  1449.             return true;
  1450.         } catch (Exception e) {
  1451.             this.logError("Exception: " + e.getMessage(), e);
  1452.             throw new Exception(e);
  1453.         }
  1454.     }


  1455.     // Controlla i dati del fruitore del servizio
  1456.     public boolean serviziFruitoriCheckData(TipoOperazione tipoOp, String[] soggettiList,
  1457.             String id, String nomeservizio, String tiposervizio, Integer versioneservizio,
  1458.             String nomeprov, String tipoprov, String idSoggettoFruitore,
  1459.             String endpointtype, String url, String nome, String tipo,
  1460.             String user, String password, String initcont,
  1461.             String urlpgk, String provurl, String connfact,
  1462.             String sendas, BinaryParameter wsdlimpler, BinaryParameter wsdlimplfru,
  1463.             String myId,
  1464.             String httpsurl, String httpstipologia, boolean httpshostverify,
  1465.             boolean httpsTrustVerifyCert, String httpspath, String httpstipo, String httpspwd,
  1466.             String httpsalgoritmo, boolean httpsstato, String httpskeystore,
  1467.             String httpspwdprivatekeytrust, String httpspathkey,
  1468.             String httpstipokey, String httpspwdkey,
  1469.             String httpspwdprivatekey, String httpsalgoritmokey,
  1470.             String httpsKeyAlias, String httpsTrustStoreCRLs, String httpsTrustStoreOCSPPolicy, String httpsKeyStoreBYOKPolicy,
  1471.             String tipoconn,
  1472.             boolean validazioneDocumenti, String backToStato,
  1473.             String autenticazioneHttp,
  1474.             String proxyEnabled, String proxyHost, String proxyPort, String proxyUsername, String proxyPassword,
  1475.             String tempiRispostaEnabled, String tempiRispostaConnectionTimeout, String tempiRispostaReadTimeout, String tempiRispostaTempoMedioRisposta,
  1476.             String opzioniAvanzate, String transferMode, String transferModeChunkSize, String redirectMode, String redirectMaxHop,
  1477.             String requestOutputFileName, String requestOutputFileNamePermissions, String requestOutputFileNameHeaders, String requestOutputFileNameHeadersPermissions,
  1478.             String requestOutputParentDirCreateIfNotExists,String requestOutputOverwriteIfExists,
  1479.             String responseInputMode, String responseInputFileName, String responseInputFileNameHeaders, String responseInputDeleteAfterRead, String responseInputWaitTime,
  1480.             String fruizioneServizioApplicativo,String fruizioneRuolo,String fruizioneAutenticazione,String fruizioneAutenticazioneOpzionale, TipoAutenticazionePrincipal fruizioneAutenticazionePrincipal, List<String> fruizioneAutenticazioneParametroList, String fruizioneAutorizzazione,
  1481.             String fruizioneAutorizzazioneAutenticati,String fruizioneAutorizzazioneRuoli, String fruizioneAutorizzazioneRuoliTipologia, String fruizioneAutorizzazioneRuoliMatch,BinaryParameter allegatoXacmlPolicy,
  1482.             boolean autenticazioneToken, String tokenPolicy,
  1483.             String autenticazioneApiKey, boolean useOAS3Names, boolean useAppId, String apiKeyHeader, String apiKeyValue, String appIdHeader, String appIdValue,
  1484.             List<ExtendedConnettore> listExtendedConnettore)
  1485.                     throws Exception {
  1486.         try {
  1487.             // ripristina dello stato solo in modalita change
  1488.             if(backToStato != null && tipoOp.equals(TipoOperazione.CHANGE)){
  1489.                 return true;
  1490.             }

  1491.             int myIdInt = 0;
  1492.             if (tipoOp.equals(TipoOperazione.CHANGE)) {
  1493.                 myIdInt = Integer.parseInt(myId);
  1494.             }
  1495.             if (idSoggettoFruitore == null) {
  1496.                 idSoggettoFruitore = "";
  1497.             }
  1498.             if (url == null) {
  1499.                 url = "";
  1500.             }
  1501.             if (nome == null) {
  1502.                 nome = "";
  1503.             }
  1504.             if (tipo == null) {
  1505.                 tipo = "";
  1506.             }
  1507.             if (user == null) {
  1508.                 user = "";
  1509.             }
  1510.             if (password == null) {
  1511.                 password = "";
  1512.             }
  1513.             if (initcont == null) {
  1514.                 initcont = "";
  1515.             }
  1516.             if (urlpgk == null) {
  1517.                 urlpgk = "";
  1518.             }
  1519.             if (provurl == null) {
  1520.                 provurl = "";
  1521.             }
  1522.             if (connfact == null) {
  1523.                 connfact = "";
  1524.             }
  1525.             if (sendas == null) {
  1526.                 sendas = "";
  1527.             }
  1528.             // Campi obbligatori
  1529.             if (idSoggettoFruitore.equals("")) {
  1530.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_SOGGETTO_MANCANTE);
  1531.                 return false;
  1532.             }

  1533.             int idInt = 0;
  1534.             if (!nomeservizio.equals("")) {
  1535.                 IDSoggetto ids = new IDSoggetto(tipoprov, nomeprov);
  1536.                 IDServizio idserv = this.idServizioFactory.getIDServizioFromValues(tiposervizio, nomeservizio, ids, versioneservizio);
  1537.                 AccordoServizioParteSpecifica myServ = this.apsCore.getServizio(idserv);
  1538.                 idInt = myServ.getId().intValue();
  1539.             } else {
  1540.                 idInt = Integer.parseInt(id);
  1541.             }
  1542.             AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(idInt);
  1543.             String protocollo = ProtocolFactoryManager.getInstance().getProtocolByServiceType(asps.getTipo());
  1544.            
  1545. //          String tipologia = ServletUtils.getObjectFromSession(this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  1546. //          boolean gestioneFruitori = false;
  1547. //          if(tipologia!=null) {
  1548. //              if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  1549. //                  gestioneFruitori = true;
  1550. //              }
  1551. //          }
  1552. //          boolean connettoreOnly = gestioneFruitori;
  1553.            
  1554.             String tmpModificaProfilo = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_PROFILO);
  1555.             boolean modificaProfilo = false;
  1556.             if(tmpModificaProfilo!=null) {
  1557.                 modificaProfilo = "true".equals(tmpModificaProfilo);
  1558.             }
  1559.            
  1560.             // Se il connettore e' disabilitato devo controllare che il
  1561.             // connettore del soggetto non sia disabilitato se è di tipo operativo
  1562.             //if (this.isModalitaAvanzata() || connettoreOnly) {
  1563.             if ( !modificaProfilo && (this.isModalitaAvanzata() || TipoOperazione.CHANGE.equals(tipoOp)) ) {
  1564.                 if (endpointtype.equals(TipiConnettore.DISABILITATO.getNome())) {
  1565.                     String eptypeprov = TipiConnettore.DISABILITATO.getNome();
  1566.    
  1567.                     org.openspcoop2.core.registry.Soggetto soggetto = this.soggettiCore.getSoggettoRegistro(Long.parseLong(idSoggettoFruitore));
  1568.                     if(this.pddCore.isPddEsterna(soggetto.getPortaDominio())==false){
  1569.                         // sto attivando una fruizione su un soggetto operativo
  1570.    
  1571.                         Connettore connettore = asps.getConfigurazioneServizio().getConnettore();
  1572.                         if ((connettore != null) && (connettore.getTipo() != null)) {
  1573.                             eptypeprov = connettore.getTipo();
  1574.                         }
  1575.                         if (eptypeprov.equals(TipiConnettore.DISABILITATO.getNome())) {
  1576.                        
  1577.                             org.openspcoop2.core.registry.Soggetto soggettoErogatore =
  1578.                                     this.soggettiCore.getSoggettoRegistro(new IDSoggetto(asps.getTipoSoggettoErogatore(), asps.getNomeSoggettoErogatore()));
  1579.                             connettore = soggettoErogatore.getConnettore();
  1580.                             if ((connettore != null) && (connettore.getTipo() != null)) {
  1581.                                 eptypeprov = connettore.getTipo();
  1582.                             }
  1583.            
  1584.                             boolean connettoreStatic = this.apsCore.isConnettoreStatic(protocollo);
  1585.                            
  1586.                             if (!connettoreStatic && eptypeprov.equals(TipiConnettore.DISABILITATO.getNome())) {
  1587.                                 if(tipoOp.equals(TipoOperazione.CHANGE)){
  1588.                                     this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_PER_POTER_DISABILITARE_IL_CONNETTORE_DEVE_PRIMA_ESSERE_DEFINITO_UN_CONNETTORE_SUL_SERVIZIO_O_SUL_SOGGETTO_EROGATORE);
  1589.                                 }
  1590.                                 else{
  1591.                                     if(this.isModalitaAvanzata()){
  1592.                                         this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_PER_POTER_AGGIUNGERE_IL_FRUITORE_DEVE_ESSERE_DEFINITO_IL_CONNETTORE_BR_IN_ALTERNATIVA_E_POSSIBILE_CONFIGURARE_UN_CONNETTORE_SUL_SERVIZIO_O_SUL_SOGGETTO_EROGATORE_PRIMA_DI_PROCEDERE_CON_LA_CREAZIONE_DEL_FRUITORE);
  1593.                                     }
  1594.                                     else{
  1595.                                         this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_PER_POTER_AGGIUNGERE_IL_FRUITORE_DEVE_PRIMA_ESSERE_DEFINITO_UN_CONNETTORE_SUL_SERVIZIO_O_SUL_SOGGETTO_EROGATORE);
  1596.                                     }
  1597.                                 }
  1598.                                 return false;
  1599.                             }
  1600.                            
  1601.                         }
  1602.                        
  1603.                     }
  1604.                    
  1605.                 }
  1606.            
  1607.                 boolean servizioApplicativoServerEnabled = false;
  1608.                 String servizioApplicativoServer = null;
  1609.                 // Controllo dell'end-point
  1610.                 // Non li puo' prendere dalla servtlet
  1611.                 if (!this.endPointCheckData(null, protocollo, false,
  1612.                         endpointtype, url, nome, tipo,
  1613.                         user, password, initcont, urlpgk, provurl, connfact,
  1614.                         sendas, httpsurl, httpstipologia, httpshostverify,
  1615.                         httpsTrustVerifyCert, httpspath, httpstipo, httpspwd, httpsalgoritmo, httpsstato,
  1616.                         httpskeystore, httpspwdprivatekeytrust, httpspathkey,
  1617.                         httpstipokey, httpspwdkey,
  1618.                         httpspwdprivatekey, httpsalgoritmokey,
  1619.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  1620.                         tipoconn,autenticazioneHttp,
  1621.                         proxyEnabled, proxyHost, proxyPort, proxyUsername, proxyPassword,
  1622.                         tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  1623.                         opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  1624.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  1625.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  1626.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  1627.                         autenticazioneToken, tokenPolicy,
  1628.                         autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  1629.                         listExtendedConnettore,servizioApplicativoServerEnabled,servizioApplicativoServer)) {
  1630.                     return false;
  1631.                 }
  1632.             }
  1633.            

  1634.             // 2 fruitori dello stesso servizio non possono avere lo stesso
  1635.             // provider
  1636.             if (tipoOp.equals(TipoOperazione.CHANGE)) {
  1637.                 Fruitore myFru = this.apsCore.getServizioFruitore(myIdInt);
  1638.                 String nomeSogg = myFru.getNome();
  1639.                 String tipoSogg = myFru.getTipo();
  1640.                 IDSoggetto idfru = new IDSoggetto(tipoSogg, nomeSogg);
  1641.                 Soggetto mySogg = this.soggettiCore.getSoggettoRegistro(idfru);
  1642.                 int idProv = mySogg.getId().intValue();

  1643.                 IDServizio idserv = this.idServizioFactory.getIDServizioFromAccordo(asps);
  1644.                 long idFru = this.apsCore.getServizioFruitore(idserv, idProv);
  1645.                 if ((idFru != 0) && (tipoOp.equals(TipoOperazione.ADD) || ((tipoOp.equals(TipoOperazione.CHANGE)) && (myIdInt != idFru)))) {
  1646.                     this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ESISTE_GI_AGRAVE_UN_FRUITORE_DEL_SERVIZIO_CON_LO_STESSO_SOGGETTO);
  1647.                     return false;
  1648.                 }
  1649.             }
  1650.             else{

  1651.                 // Lettura accordo di servizio
  1652.                 AccordoServizioParteComune as = null;
  1653.                 IDAccordo idAccordo = this.idAccordoFactory.getIDAccordoFromUri(asps.getAccordoServizioParteComune());
  1654.                 try{
  1655.                     as = this.apcCore.getAccordoServizioFull(idAccordo);
  1656.                 }catch(Exception e){
  1657.                     this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_API_SELEZIONATA_NON_ESISTENTE_CON_PARAMETRI, idAccordo,e.getMessage()));
  1658.                     return false;
  1659.                 }

  1660.                 // Validazione Documenti
  1661.                 if(validazioneDocumenti && tipoOp.equals(TipoOperazione.ADD) && this.isModalitaAvanzata() ){
  1662.                    
  1663.                     FormatoSpecifica formato = null;
  1664.                     if(as!=null) {
  1665.                         formato = as.getFormatoSpecifica();
  1666.                     }
  1667.                    
  1668.                     String wsdlimplerS = wsdlimpler.getValue() != null ? new String(wsdlimpler.getValue()) : null;
  1669.                     byte [] wsdlImplementativoErogatore = this.apsCore.getInterfaceAsByteArray(formato, wsdlimplerS);
  1670.                     String wsdlimplfruS = wsdlimplfru.getValue() != null ? new String(wsdlimplfru.getValue()) : null;
  1671.                     byte [] wsdlImplementativoFruitore = this.apsCore.getInterfaceAsByteArray(formato, wsdlimplfruS);

  1672.                     Fruitore f = new Fruitore();
  1673.                     f.setByteWsdlImplementativoErogatore(wsdlImplementativoErogatore);
  1674.                     f.setByteWsdlImplementativoFruitore(wsdlImplementativoFruitore);

  1675.                     ValidazioneResult result = this.apsCore.validaInterfacciaWsdlParteSpecifica(f,asps, as, this.soggettiCore);
  1676.                     if(!result.isEsito()){
  1677.                         this.pd.setMessage(result.getMessaggioErrore());
  1678.                         return false;
  1679.                     }  

  1680.                 }
  1681.                
  1682.                 String gestioneToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN);
  1683.                 String gestioneTokenPolicy = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  1684.                 String gestioneTokenValidazioneInput = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  1685.                 String gestioneTokenIntrospection = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  1686.                 String gestioneTokenUserInfo = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  1687.                 String gestioneTokenTokenForward = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  1688.                
  1689.                 String autorizzazioneAutenticatiToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE_TOKEN);
  1690.                 String autorizzazioneRuoliToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_TOKEN);
  1691.                
  1692.                 String autorizzazione_token = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN);
  1693.                 String autorizzazione_tokenOptions = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_OPTIONS);
  1694.                 String autorizzazioneScope = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE);
  1695.                 String autorizzazioneScopeMatch = this.getParameter(CostantiControlStation.PARAMETRO_SCOPE_MATCH);
  1696.                                
  1697.                 String autorizzazioneContenutiStato = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_STATO);
  1698.                 String autorizzazioneContenuti = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI);
  1699.                 String autorizzazioneContenutiProperties = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_PROPERTIES);
  1700.                
  1701.                 String identificazioneAttributiStato = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO);
  1702.                 String [] attributeAuthoritySelezionate = this.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  1703.                 String attributeAuthorityAttributi = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI);
  1704.                
  1705.                 if(this.controlloAccessiCheck(tipoOp, fruizioneAutenticazione, fruizioneAutenticazioneOpzionale, fruizioneAutenticazionePrincipal, fruizioneAutenticazioneParametroList,
  1706.                         fruizioneAutorizzazione, fruizioneAutorizzazioneAutenticati, fruizioneAutorizzazioneRuoli,
  1707.                         fruizioneAutorizzazioneRuoliTipologia, fruizioneAutorizzazioneRuoliMatch,
  1708.                         true, true, null, null,gestioneToken, gestioneTokenPolicy,
  1709.                         gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  1710.                         autorizzazioneAutenticatiToken, autorizzazioneRuoliToken,
  1711.                         autorizzazione_token,autorizzazione_tokenOptions,
  1712.                         autorizzazioneScope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  1713.                         autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties,
  1714.                         protocollo,
  1715.                         identificazioneAttributiStato, attributeAuthoritySelezionate, attributeAuthorityAttributi)==false){
  1716.                     return false;
  1717.                 }
  1718.             }

  1719.             return true;

  1720.         } catch (Exception e) {
  1721.             this.logError("Exception: " + e.getMessage(), e);
  1722.             throw new Exception(e);
  1723.         }
  1724.     }

  1725.     private static boolean documentoUnivocoIndipendentementeTipo = true;
  1726.     public static boolean isDocumentoUnivocoIndipendentementeTipo() {
  1727.         return documentoUnivocoIndipendentementeTipo;
  1728.     }
  1729.     public static void setDocumentoUnivocoIndipendentementeTipo(boolean documentoUnivocoIndipendentementeTipo) {
  1730.         AccordiServizioParteSpecificaHelper.documentoUnivocoIndipendentementeTipo = documentoUnivocoIndipendentementeTipo;
  1731.     }
  1732.     public boolean serviziAllegatiCheckData(TipoOperazione tipoOp,FormFile formFile,Documento documento, IProtocolFactory<?> pf)
  1733.             throws Exception {

  1734.         try{

  1735.             String ruolo = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_RUOLO);

  1736.             // Campi obbligatori
  1737.             if (ruolo.equals("")) {
  1738.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_IL_TIPO_DI_DOCUMENTO);
  1739.                 return false;
  1740.             }

  1741.             if(formFile==null || formFile.getFileName()!=null && "".equals(formFile.getFileName())){
  1742.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_DOCUMENTO_OBBLIGATORIO);
  1743.                 return false;
  1744.             }

  1745.             if(formFile==null || formFile.getFileSize()<=0){
  1746.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_DOCUMENTO_SELEZIONATO_NON_PUO_ESSERE_VUOTO);
  1747.                 return false;
  1748.             }

  1749.             if(documento.getTipo()==null || "".equals(documento.getTipo()) || documento.getTipo().length()>30 || formFile.getFileName().lastIndexOf(".")==-1){
  1750.                 if(documento.getTipo()==null || "".equals(documento.getTipo()) || formFile.getFileName().lastIndexOf(".")==-1){
  1751.                     this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ESTENSIONE_DEL_DOCUMENTO_NON_VALIDA);
  1752.                 }else{
  1753.                     this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ESTENSIONE_DEL_DOCUMENTO_NON_VALIDA_DIMENSIONE_ESTENSIONE_TROPPO_LUNGA);
  1754.                 }
  1755.                 return false;
  1756.             }

  1757.             String labelServizio = getLabelServizioMessaggioErroreDocumentoDuplicato();
  1758.            
  1759.             if(this.archiviCore.existsDocumento(documento,ProprietariDocumento.servizio,documentoUnivocoIndipendentementeTipo)){

  1760.                 String tipo = documento.getTipo();
  1761.                 String ruoloDoc = documento.getRuolo();
  1762.                 String allegatoMsg = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ALLEGATO_CON_NOME_TIPO_GIA_PRESENTE_NEL_SERVIZIO_CON_PARAMETRI;
  1763.                 String specificaMsg = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_LA_SPECIFICA_CON_NOME_TIPO_GIA_PRESENTE_NEL_SERVIZIO;
  1764.                 if(documentoUnivocoIndipendentementeTipo) {
  1765.                     tipo = null;
  1766.                     ruoloDoc = null;
  1767.                     allegatoMsg = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ALLEGATO_CON_NOME_TIPO_GIA_PRESENTE_NEL_SERVIZIO_CON_PARAMETRI_SENZA_TIPO;
  1768.                     specificaMsg = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_LA_SPECIFICA_CON_NOME_TIPO_GIA_PRESENTE_NEL_SERVIZIO_SENZA_TIPO;
  1769.                 }
  1770.                
  1771.                 //check se stesso documento
  1772.                 Documento existing = this.archiviCore.getDocumento(documento.getFile(),tipo,ruoloDoc,documento.getIdProprietarioDocumento(),false,ProprietariDocumento.servizio);
  1773.                 if(existing.getId().longValue() == documento.getId().longValue())
  1774.                     return true;

  1775.                 if(RuoliDocumento.allegato.toString().equals(documento.getRuolo()) || documentoUnivocoIndipendentementeTipo) {
  1776.                     if(documentoUnivocoIndipendentementeTipo) {
  1777.                         this.pd.setMessage(MessageFormat.format(allegatoMsg,
  1778.                                 documento.getFile(),labelServizio));
  1779.                     }
  1780.                     else {
  1781.                         this.pd.setMessage(MessageFormat.format(allegatoMsg,
  1782.                                 documento.getFile(), documento.getTipo(),labelServizio));
  1783.                     }
  1784.                 }else {
  1785. //                  if(documentoUnivocoIndipendentementeTipo) {
  1786. //                      this.pd.setMessage(MessageFormat.format(specificaMsg, documento.getRuolo(),
  1787. //                              documento.getFile(),labelServizio));
  1788. //                  }
  1789. //                  else {
  1790.                     this.pd.setMessage(MessageFormat.format(specificaMsg, documento.getRuolo(),
  1791.                             documento.getFile(), documento.getTipo(),labelServizio));
  1792. //                  }
  1793.                 }
  1794.                
  1795.                 return false;
  1796.             }
  1797.            

  1798.             ValidazioneResult valida = pf.createValidazioneDocumenti().valida (documento);
  1799.             if(!valida.isEsito()) {
  1800.                 this.pd.setMessage(valida.getMessaggioErrore());
  1801.                 return false;
  1802.             }


  1803.             return true;

  1804.         } catch (Exception e) {
  1805.             this.logError("Exception: " + e.getMessage(), e);
  1806.             throw new Exception(e);
  1807.         }
  1808.     }
  1809.     private String getLabelServizioMessaggioErroreDocumentoDuplicato() {
  1810.         String labelServizio = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ALLEGATO_LABEL_SERVIZIO;
  1811.         String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  1812.         boolean gestioneFruitori = false;
  1813.         if(tipologia!=null) {
  1814.             if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  1815.                 gestioneFruitori = true;
  1816.             }
  1817.         }
  1818.         //Boolean vistaErogazioni = ServletUtils.getBooleanAttributeFromSession(ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI, this.session, this.request).getValue();
  1819.         //if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  1820.             if(gestioneFruitori) {
  1821.                 labelServizio = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ALLEGATO_LABEL_FRUIZIONE;
  1822.             } else {
  1823.                 labelServizio = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ALLEGATO_LABEL_EROGAZIONE;
  1824.             }
  1825.         /*} else {
  1826.             if(gestioneFruitori) {
  1827.                 labelServizio = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ALLEGATO_LABEL_FRUIZIONE;
  1828.             }
  1829.             else {
  1830.                 labelServizio = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ALLEGATO_LABEL_EROGAZIONE;
  1831.             }
  1832.         }*/
  1833.         return labelServizio;
  1834.     }
  1835.    
  1836.     @SuppressWarnings("incomplete-switch")
  1837.     public boolean serviziAllegatiCheckData(TipoOperazione tipoOp, List<BinaryParameter> binaryParameterDocumenti, Long idProprietarioDocumento, IProtocolFactory<?> pf)
  1838.             throws Exception {

  1839.         try{

  1840.             String ruolo = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_RUOLO);
  1841.             String tipoFile = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_FILE  );

  1842.             // Campi obbligatori
  1843.             if (ruolo.equals("")) {
  1844.                 this.pd.setMessage(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_DATI_INCOMPLETI_E_NECESSARIO_INDICARE_IL_TIPO_DI_DOCUMENTO);
  1845.                 return false;
  1846.             }
  1847.            
  1848.             // 1. Controllo selezione almeno un documento -> cioe' almento un value della lista non e' vuoto
  1849.             boolean almenoUnoSelezionato = false;
  1850.             for (int i = 0; i < binaryParameterDocumenti.size() ; i++) {
  1851.                 BinaryParameter binaryParameter = binaryParameterDocumenti.get(i);
  1852.                
  1853.                 // al primo file non vuoto che trovo mi fermo
  1854.                 if(binaryParameter.getValue() != null && binaryParameter.getValue().length > 0){
  1855.                     almenoUnoSelezionato = true;
  1856.                     break;
  1857.                 }
  1858.             }
  1859.            
  1860.             if(!almenoUnoSelezionato) {
  1861.                 this.pd.setMessage("&Egrave; necessario selezionare almeno un documento.");
  1862.                 return false;
  1863.             }
  1864.            
  1865.             List<String> listaErrori = new ArrayList<>();
  1866.             String labelServizio = getLabelServizioMessaggioErroreDocumentoDuplicato();
  1867.            
  1868.             for (int i = 0; i < binaryParameterDocumenti.size() ; i++) {
  1869.                 BinaryParameter binaryParameter = binaryParameterDocumenti.get(i);
  1870.                
  1871.                 if(StringUtils.isBlank(binaryParameter.getFilename())){
  1872.                     listaErrori.add("Il documento selezionato in posizione ("+(i+1)+") non ha un nome valido.");
  1873.                     continue;
  1874.                 }

  1875.                 if(binaryParameter.getValue()==null || binaryParameter.getValue().length<=0){
  1876.                     listaErrori.add("Il documento '"+ binaryParameter.getFilename() +"' &egrave; vuoto.");
  1877.                     continue;
  1878.                 }
  1879.            
  1880.                 String tipo = null;
  1881.                 switch (RuoliDocumento.valueOf(ruolo)) {
  1882.                     case allegato:
  1883.                         tipo = binaryParameter.getFilename().substring(binaryParameter.getFilename().lastIndexOf('.')+1, binaryParameter.getFilename().length());
  1884.                         break;
  1885.                     case specificaSemiformale:
  1886.                         tipo = TipiDocumentoSemiformale.valueOf(tipoFile).getNome();
  1887.                         break;
  1888.                     case specificaSicurezza:
  1889.                         tipo = TipiDocumentoSicurezza.valueOf(tipoFile).getNome();
  1890.                         break;
  1891.                     case specificaLivelloServizio:
  1892.                         tipo = TipiDocumentoLivelloServizio.valueOf(tipoFile).getNome();
  1893.                         break;
  1894.                 }
  1895.                
  1896.                
  1897.                 if(tipo==null || "".equals(tipo) || tipo.length()>30 || binaryParameter.getFilename().lastIndexOf(".")==-1){
  1898.                     if(tipo==null || "".equals(tipo) || binaryParameter.getFilename().lastIndexOf(".")==-1){
  1899.                         listaErrori.add("L'estensione del documento '"+ binaryParameter.getFilename() +"' non &egrave; valida.");
  1900.                     }else{
  1901.                         listaErrori.add("L'estensione del documento '"+ binaryParameter.getFilename() +"' non &egrave; valida. La dimensione dell'estensione &egrave; troppo lunga.");
  1902.                     }
  1903.                     continue;
  1904.                 }
  1905.                
  1906.                 Documento documento = new Documento();
  1907.                 documento.setRuolo(RuoliDocumento.valueOf(ruolo).toString());
  1908.                 documento.setByteContenuto(binaryParameter.getValue());
  1909.                 documento.setFile(binaryParameter.getFilename());

  1910.                 switch (RuoliDocumento.valueOf(ruolo)) {
  1911.                     case allegato:
  1912.                         documento.setTipo(binaryParameter.getFilename().substring(binaryParameter.getFilename().lastIndexOf('.')+1, binaryParameter.getFilename().length()));
  1913.                         break;
  1914.                     case specificaSemiformale:
  1915.                         documento.setTipo(TipiDocumentoSemiformale.valueOf(tipoFile).getNome());
  1916.                         break;
  1917.                     case specificaSicurezza:
  1918.                         documento.setTipo(TipiDocumentoSicurezza.valueOf(tipoFile).getNome());
  1919.                         break;
  1920.                     case specificaLivelloServizio:
  1921.                         documento.setTipo(TipiDocumentoLivelloServizio.valueOf(tipoFile).getNome());
  1922.                         break;
  1923.                 }
  1924.                 documento.setIdProprietarioDocumento(idProprietarioDocumento);
  1925.                
  1926.                 boolean documentoUnivocoIndipendentementeTipo = true;
  1927.                 if(this.archiviCore.existsDocumento(documento,ProprietariDocumento.servizio,documentoUnivocoIndipendentementeTipo)){
  1928.    
  1929.                     tipo = documento.getTipo();
  1930.                     String ruoloDoc = documento.getRuolo();
  1931.                     String allegatoMsg = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ALLEGATO_CON_NOME_TIPO_GIA_PRESENTE_NEL_SERVIZIO_CON_PARAMETRI;
  1932.                     String specificaMsg = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_LA_SPECIFICA_CON_NOME_TIPO_GIA_PRESENTE_NEL_SERVIZIO;
  1933.                     if(documentoUnivocoIndipendentementeTipo) {
  1934.                         tipo = null;
  1935.                         ruoloDoc = null;
  1936.                         allegatoMsg = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_ALLEGATO_CON_NOME_TIPO_GIA_PRESENTE_NEL_SERVIZIO_CON_PARAMETRI_SENZA_TIPO;
  1937.                         specificaMsg = AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_LA_SPECIFICA_CON_NOME_TIPO_GIA_PRESENTE_NEL_SERVIZIO_SENZA_TIPO;
  1938.                     }
  1939.                    
  1940.                     Documento existing = this.archiviCore.getDocumento(documento.getFile(),tipo,ruoloDoc,documento.getIdProprietarioDocumento(),false,ProprietariDocumento.servizio);
  1941.                     if(!(existing.getId().longValue() == documento.getId().longValue())) {
  1942.                         if(RuoliDocumento.allegato.toString().equals(documento.getRuolo()) || documentoUnivocoIndipendentementeTipo) {
  1943.                             if(documentoUnivocoIndipendentementeTipo) {
  1944.                                 listaErrori.add(MessageFormat.format(allegatoMsg, documento.getFile(), labelServizio));
  1945.                             }
  1946.                             else {
  1947.                                 listaErrori.add(MessageFormat.format(allegatoMsg, documento.getFile(), documento.getTipo(), labelServizio));
  1948.                             }
  1949.                         }else {
  1950. //                          if(documentoUnivocoIndipendentementeTipo) {
  1951. //                              listaErrori.add(MessageFormat.format(specificaMsg, documento.getRuolo(), documento.getFile(), labelServizio));
  1952. //                          }
  1953. //                          else {
  1954.                             listaErrori.add(MessageFormat.format(specificaMsg, documento.getRuolo(), documento.getFile(), documento.getTipo(), labelServizio));
  1955. //                          }
  1956.                         }
  1957.    
  1958.                         continue;
  1959.                     }
  1960.                 }
  1961.    
  1962.                 ValidazioneResult valida = pf.createValidazioneDocumenti().valida (documento);
  1963.                 if(!valida.isEsito()) {
  1964.                     listaErrori.add(valida.getMessaggioErrore());
  1965.                     continue;
  1966.                 }
  1967.             }
  1968.            
  1969.             if(!listaErrori.isEmpty()) {
  1970.                 StringBuilder sb = new StringBuilder();
  1971.                
  1972.                 for (int i = 0; i < listaErrori.size(); i++) {
  1973.                     if(i != 0) {
  1974.                         sb.append("<br/>");
  1975.                     }
  1976.                     sb.append(listaErrori.get(i));
  1977.                 }
  1978.                
  1979.                 this.pd.setMessage(sb.toString());
  1980.                 return false;
  1981.             }
  1982.            
  1983.             return true;

  1984.         } catch (Exception e) {
  1985.             this.logError("Exception: " + e.getMessage(), e);
  1986.             throw new Exception(e);
  1987.         }
  1988.     }

  1989.     public void prepareServiziAllegatiList(AccordoServizioParteSpecifica asps, ISearch ricerca, List<Documento> lista) throws Exception {
  1990.         try {
  1991.            
  1992.             String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  1993.             boolean gestioneFruitori = false;
  1994.             if(tipologia!=null) {
  1995.                 if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  1996.                     gestioneFruitori = true;
  1997.                 }
  1998.             }
  1999.            
  2000.             String id = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID);      
  2001.            
  2002.             String tipoSoggettoFruitore = null;
  2003.             String nomeSoggettoFruitore = null;
  2004.             IDSoggetto idSoggettoFruitore = null;
  2005.             Parameter pTipoSoggettoFruitore = null;
  2006.             Parameter pNomeSoggettoFruitore = null;
  2007.             if(gestioneFruitori) {
  2008.                 tipoSoggettoFruitore = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE);
  2009.                 nomeSoggettoFruitore = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE);
  2010.                 idSoggettoFruitore = new IDSoggetto(tipoSoggettoFruitore, nomeSoggettoFruitore);
  2011.                 pTipoSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE, tipoSoggettoFruitore);
  2012.                 pNomeSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE, nomeSoggettoFruitore);
  2013.             }
  2014.            
  2015.             Parameter pModificaAPI = null;
  2016.             String modificaAPI = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_API);
  2017.             if(modificaAPI!=null) {
  2018.                 pModificaAPI = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_API, modificaAPI);
  2019.             }
  2020.            
  2021.             List<Parameter> listAllegatiSession = new ArrayList<>();
  2022.             listAllegatiSession.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id));
  2023.             if(gestioneFruitori) {
  2024.                 listAllegatiSession.add(pTipoSoggettoFruitore);
  2025.                 listAllegatiSession.add(pNomeSoggettoFruitore);
  2026.             }
  2027.             if(pModificaAPI!=null) {
  2028.                 listAllegatiSession.add(pModificaAPI);
  2029.             }
  2030.             ServletUtils.addListElementIntoSession(this.request, this.session, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_ALLEGATI,
  2031.                     listAllegatiSession.toArray(new Parameter[1]));

  2032.             int idLista = Liste.SERVIZI_ALLEGATI;
  2033.             int limit = ricerca.getPageSize(idLista);
  2034.             int offset = ricerca.getIndexIniziale(idLista);
  2035.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  2036.             this.pd.setIndex(offset);
  2037.             this.pd.setPageSize(limit);
  2038.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  2039.                        
  2040.             String tipoProtocollo = this.apsCore.getProtocolloAssociatoTipoServizio(asps.getTipo());
  2041.            
  2042.             String tmpTitle = this.getLabelServizio(idSoggettoFruitore, gestioneFruitori, asps, tipoProtocollo);
  2043.            
  2044.             // setto la barra del titolo
  2045.             List<Parameter> lstParam = new ArrayList<>();

  2046.             Boolean vistaErogazioni = ServletUtils.getBooleanAttributeFromSession(ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI, this.session, this.request).getValue();
  2047.             if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  2048.                 if(gestioneFruitori) {
  2049.                     lstParam.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_FRUIZIONI, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST));
  2050.                 } else {
  2051.                     lstParam.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_EROGAZIONI, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST));
  2052.                 }
  2053.                 List<Parameter> listErogazioniChange = new ArrayList<>();
  2054.                 Parameter pIdServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId()+ "");
  2055.                 Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  2056.                 Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  2057.                 listErogazioniChange.add(pIdServizio);
  2058.                 listErogazioniChange.add(pNomeServizio);
  2059.                 listErogazioniChange.add(pTipoServizio);
  2060.                 if(gestioneFruitori) {
  2061.                     listErogazioniChange.add(pNomeSoggettoFruitore);
  2062.                     listErogazioniChange.add(pTipoSoggettoFruitore);
  2063.                 }
  2064.                 if(pModificaAPI!=null) {
  2065.                     listErogazioniChange.add(pModificaAPI);
  2066.                 }
  2067.                 lstParam.add(new Parameter(tmpTitle, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_CHANGE,
  2068.                         listErogazioniChange.toArray(new Parameter[1])));
  2069.                
  2070.                 lstParam.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_MODIFICA_SERVIZIO_INFO_GENERALI, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE,
  2071.                         listErogazioniChange.toArray(new Parameter[1])));
  2072.                
  2073.                 if(search.equals("")){
  2074.                     this.pd.setSearchDescription("");
  2075.                     lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI, null));
  2076.                 }else{
  2077.                     lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI,
  2078.                             AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ALLEGATI_LIST,
  2079.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId() + "")
  2080.                             ));
  2081.                     lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  2082.                 }
  2083.             } else {
  2084.                 if(gestioneFruitori) {
  2085.                     lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  2086.                 }
  2087.                 else {
  2088.                     lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  2089.                 }
  2090.                
  2091.                 if(search.equals("")){
  2092.                     this.pd.setSearchDescription("");
  2093.                     lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI_DI + tmpTitle, null));
  2094.                 }else{
  2095.                     lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI_DI + tmpTitle,
  2096.                             AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ALLEGATI_LIST,
  2097.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId() + "")
  2098.                             ));
  2099.                     lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  2100.                 }
  2101.             }
  2102.            

  2103.             // setto la barra del titolo
  2104.             ServletUtils.setPageDataTitle(this.pd, lstParam );

  2105.             // controllo eventuali risultati ricerca
  2106.             this.pd.setSearchLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_NOME_FILE);
  2107.             if (!search.equals("")) {
  2108.                 ServletUtils.enabledPageDataSearch(this.pd, AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI, search);
  2109.             }

  2110.             // setto le label delle colonne
  2111.             String[] labels = {
  2112.                     AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_NOME_FILE,
  2113.                     AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_RUOLO,
  2114.                     AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPO_FILE,
  2115.                     AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_THE_FILE
  2116.             };
  2117.             this.pd.setLabels(labels);

  2118.             // preparo i dati
  2119.             List<List<DataElement>> dati = new ArrayList<>();

  2120.             if (lista != null) {
  2121.                 Iterator<Documento> it = lista.iterator();
  2122.                 while (it.hasNext()) {
  2123.                     Documento doc = it.next();

  2124.                     Parameter pIdAllegato= new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_ALLEGATO, doc.getId() + "");
  2125.                     Parameter pId= new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId() + "");
  2126.                     Parameter pNomeDoc= new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_DOCUMENTO, doc.getFile());

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

  2128.                     DataElement de = new DataElement();
  2129.                     List<Parameter> listAllegatiChange = new ArrayList<>();
  2130.                     listAllegatiChange.add(pIdAllegato);
  2131.                     listAllegatiChange.add(pId);
  2132.                     listAllegatiChange.add(pNomeDoc);
  2133.                     if(gestioneFruitori) {
  2134.                         listAllegatiChange.add(pTipoSoggettoFruitore);
  2135.                         listAllegatiChange.add(pNomeSoggettoFruitore);
  2136.                     }
  2137.                     if(pModificaAPI!=null) {
  2138.                         listAllegatiChange.add(pModificaAPI);
  2139.                     }
  2140.                     de.setUrl(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ALLEGATI_CHANGE,
  2141.                             listAllegatiChange.toArray(new Parameter[1]));
  2142.                     de.setValue(doc.getFile());
  2143.                     de.setIdToRemove(""+doc.getId());
  2144.                     e.add(de);

  2145.                     de = new DataElement();
  2146.                     de.setValue(doc.getRuolo());
  2147.                     e.add(de);

  2148.                     de = new DataElement();
  2149.                     de.setValue(doc.getTipo());
  2150.                     e.add(de);

  2151.                     de = new DataElement();
  2152.                     if(this.core.isShowAllegati()) {
  2153.                         de.setUrl(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ALLEGATI_VIEW,
  2154.                                 pIdAllegato,pId,pNomeDoc);
  2155.                         de.setValue(Costanti.LABEL_VISUALIZZA);
  2156.                     }
  2157.                     else {
  2158.                         Parameter pIdAccordo = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_ACCORDO, asps.getId() + "");
  2159.                         Parameter pTipoDoc = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_DOCUMENTO, "asps");
  2160.                         de.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT,
  2161.                                 pIdAllegato,pId,pNomeDoc,pIdAccordo,pTipoDoc);
  2162.                         de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_APS_DOWNLOAD.toLowerCase());
  2163.                         de.setDisabilitaAjaxStatus();
  2164.                     }
  2165.                     e.add(de);

  2166.                     dati.add(e);
  2167.                 }
  2168.             }

  2169.             this.pd.setDati(dati);

  2170.             if(this.isShowGestioneWorkflowStatoDocumenti() && StatiAccordo.finale.toString().equals(asps.getStatoPackage())){
  2171.                 this.pd.setAddButton(false);
  2172.                 this.pd.setRemoveButton(false);
  2173.                 this.pd.setSelect(false);
  2174.             }else{
  2175.                 this.pd.setAddButton(true);
  2176.                 this.pd.setRemoveButton(true);
  2177.                 this.pd.setSelect(true);
  2178.             }

  2179.         } catch (Exception e) {
  2180.             this.logError("Exception: " + e.getMessage(), e);
  2181.             throw new Exception(e);
  2182.         }
  2183.     }

  2184.     public void prepareServiziList(ISearch ricerca, List<AccordoServizioParteSpecifica> lista)
  2185.             throws Exception {
  2186.         try {

  2187.             if(lista==null) {
  2188.                 throw new Exception("Lista is null");
  2189.             }
  2190.            
  2191.             ServletUtils.addListElementIntoSession(this.request, this.session, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS);

  2192.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);

  2193.             User user = ServletUtils.getUserFromSession(this.request, this.session);

  2194.             Boolean isAccordiCooperazione = user.getPermessi().isAccordiCooperazione();
  2195.             Boolean isServizi = user.getPermessi().isServizi();

  2196.             String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  2197.            
  2198.             boolean showProtocolli = this.core.countProtocolli(this.request, this.session)>1;
  2199.             boolean showServiceBinding = true;
  2200.             if( !showProtocolli ) {
  2201.                 List<String> l = this.core.getProtocolli(this.request, this.session);
  2202.                 if(l.size()>0) {
  2203.                     IProtocolFactory<?> p = ProtocolFactoryManager.getInstance().getProtocolFactoryByName(l.get(0));
  2204.                     if(p.getManifest().getBinding().getRest()==null || p.getManifest().getBinding().getSoap()==null) {
  2205.                         showServiceBinding = false;
  2206.                     }
  2207.                 }
  2208.             }
  2209.            
  2210.             int idLista = Liste.SERVIZI;
  2211.             int limit = ricerca.getPageSize(idLista);
  2212.             int offset = ricerca.getIndexIniziale(idLista);
  2213.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  2214.             addFilterProtocol(ricerca, idLista);
  2215.            
  2216.             if(showServiceBinding) {
  2217.                 String filterTipoAccordo = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_SERVICE_BINDING);
  2218.                 this.addFilterServiceBinding(filterTipoAccordo,false,true);
  2219.             }
  2220.            
  2221.             if(this.isShowGestioneWorkflowStatoDocumenti()){
  2222.                 if(this.core.isGestioneWorkflowStatoDocumentiVisualizzaStatoLista()) {
  2223.                     String filterStatoAccordo = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_STATO_ACCORDO);
  2224.                     this.addFilterStatoAccordo(filterStatoAccordo,false);
  2225.                 }
  2226.             }
  2227.            
  2228.             boolean showConfigurazionePA = false;
  2229.             boolean showConfigurazionePD = false;
  2230.             boolean showSoggettoFruitore = false;
  2231.             boolean showSoggettoErogatore = false;
  2232.             boolean showFruitori = false;
  2233.             boolean showConnettorePA = false;
  2234.             boolean showConnettorePD = false;
  2235.             boolean gestioneFruitori = false;
  2236.            
  2237.             if(tipologia==null) {
  2238.                 String filterDominio = null;
  2239.                 if(this.core.isGestionePddAbilitata(this)==false) {
  2240.                     filterDominio = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_DOMINIO);
  2241.                     this.addFilterDominio(filterDominio, false);
  2242.                 }
  2243.                 PddTipologia pddTipologiaFilter = null;
  2244.                 if(filterDominio!=null && !"".equals(filterDominio)) {
  2245.                     pddTipologiaFilter = PddTipologia.toPddTipologia(filterDominio);
  2246.                 }
  2247.                
  2248.                 showConfigurazionePA = pddTipologiaFilter==null || !PddTipologia.ESTERNO.equals(pddTipologiaFilter);
  2249.                 if(showConfigurazionePA) {
  2250.                     showConnettorePA = true; // altrimenti non vi e' un modo per modificarlo come invece succede per la fruizione nel caso multitenant
  2251.                 }
  2252.                 showFruitori = pddTipologiaFilter==null || this.isModalitaCompleta() || PddTipologia.ESTERNO.equals(pddTipologiaFilter);
  2253.                 showSoggettoErogatore = true;
  2254.             }
  2255.             else {
  2256.                 if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE.equals(tipologia)) {
  2257.                     showConfigurazionePA = true;
  2258.                     showSoggettoErogatore = false; // si e' deciso che non si fa vedere essendo solo uno
  2259.                     showConnettorePA = true;
  2260.                 }
  2261.                 if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  2262.                     gestioneFruitori = true;
  2263.                     showConfigurazionePD = true;
  2264.                     //showSoggettoFruitore = true;
  2265.                     showSoggettoFruitore = false; // si e' deciso che non si fa vedere essendo solo uno
  2266.                     showSoggettoErogatore = true;
  2267.                     showConnettorePD = true;
  2268.                 }
  2269.             }
  2270.            
  2271.             this.pd.setIndex(offset);
  2272.             this.pd.setPageSize(limit);
  2273.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  2274.             // setto la barra del titolo
  2275.             List<Parameter> lstParm = new ArrayList<>();

  2276.             if(showConfigurazionePD) {
  2277.                 lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  2278.             }
  2279.             else {
  2280.                 lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  2281.             }
  2282. //          lstParm.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_ELENCO,
  2283. //                  AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  2284.             this.pd.setSearchLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_RICERCA_SERVIZIO_SOGGETTO);
  2285.             if(search.equals("")){
  2286.                 this.pd.setSearchDescription("");
  2287.             }else{
  2288.                 lstParm.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  2289.             }

  2290.             // setto la barra del titolo
  2291.             ServletUtils.setPageDataTitle(this.pd, lstParm );

  2292.             // controllo eventuali risultati ricerca
  2293.             if (!search.equals("")) {
  2294.                 ServletUtils.enabledPageDataSearch(this.pd, AccordiServizioParteSpecificaCostanti.LABEL_APS, search);
  2295.             }

  2296.             // setto le label delle colonne
  2297.             String[] labels = null;
  2298.             //String servizioLabel = AccordiServizioParteSpecificaCostanti.LABEL_APS;

  2299.             String asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO;

  2300.             if(isServizi && !isAccordiCooperazione){
  2301.                 asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO_SOLO_PARTE_COMUNE;
  2302.             }

  2303.             if(!isServizi  && isAccordiCooperazione){
  2304.                 asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO_SOLO_COMPOSTO;
  2305.             }

  2306.             if(isServizi  && isAccordiCooperazione){
  2307.                 asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO;
  2308.             }

  2309.             @SuppressWarnings("unused")
  2310.             String correlatoLabel = AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_RUOLO;

  2311.             String fruitoriLabel = AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI;

  2312.            
  2313.             List<AccordoServizioParteComuneSintetico> listApc = new ArrayList<AccordoServizioParteComuneSintetico>();
  2314.             List<String> protocolli = new ArrayList<>();
  2315.            
  2316.             boolean showRuoli = false;
  2317.             for (AccordoServizioParteSpecifica asps : lista) {
  2318.                 AccordoServizioParteComuneSintetico apc = this.apcCore.getAccordoServizioSintetico(asps.getIdAccordo());
  2319.                 ServiceBinding serviceBinding = this.apcCore.toMessageServiceBinding(apc.getServiceBinding());
  2320.                 String tipoSoggetto = asps.getTipoSoggettoErogatore();
  2321.                 String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(tipoSoggetto);
  2322.                 showRuoli = showRuoli ||  this.core.isProfiloDiCollaborazioneAsincronoSupportatoDalProtocollo(protocollo,serviceBinding);
  2323.                
  2324.                 listApc.add(apc);
  2325.                 protocolli.add(protocollo);
  2326.             }
  2327.                        
  2328.             // controllo visualizzazione colonna ruolo
  2329.             List<String> listaLabelTabella = new ArrayList<>();

  2330.             listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_SERVIZIO);
  2331.             if(showSoggettoErogatore) {
  2332.                 listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO_EROGATORE);
  2333.             }
  2334.             if(showSoggettoFruitore) {
  2335.                 listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO_FRUITORE);
  2336.             }
  2337.             if( showProtocolli ) {
  2338.                 listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROTOCOLLO_COMPACT);
  2339.             }
  2340.             listaLabelTabella.add(asLabel);
  2341.            
  2342.             // serviceBinding
  2343.             if(showServiceBinding) {
  2344.                 listaLabelTabella.add(AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_SERVICE_BINDING);
  2345.             }

  2346.             if(showConfigurazionePA) {
  2347.                 listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_DATI_INVOCAZIONE);
  2348.                 if(showConnettorePA) {
  2349.                     listaLabelTabella.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE);
  2350.                     listaLabelTabella.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_VERIFICA_CONNETTORE);
  2351.                     listaLabelTabella.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONFIGURAZIONE_CONNETTORI_MULTIPLI);
  2352.                     listaLabelTabella.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_ELENCO_CONNETTORI_MULTIPLI);
  2353.                 }
  2354.                 listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_APPLICATIVE);
  2355.             }
  2356.            
  2357.             if(showConfigurazionePD) {
  2358.                 listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_DATI_INVOCAZIONE);
  2359.                 if(showConnettorePD) {
  2360.                     listaLabelTabella.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE);
  2361.                 }
  2362.                 listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_DELEGATE);
  2363.             }
  2364.            
  2365.             if(showRuoli) {
  2366.                 //listaLabelTabella.add(correlatoLabel);
  2367.             }
  2368.             if(this.isShowGestioneWorkflowStatoDocumenti()) {
  2369.                 if(this.core.isGestioneWorkflowStatoDocumentiVisualizzaStatoLista()) {
  2370.                     listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_STATO);
  2371.                 }
  2372.             }
  2373.             if(showFruitori) {
  2374.                 listaLabelTabella.add(fruitoriLabel);
  2375.             }
  2376.             if(!this.isModalitaStandard()) {
  2377.                 listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI);
  2378.             }

  2379.             labels = listaLabelTabella.toArray(new String[listaLabelTabella.size()]);

  2380.             // "Politiche SLA" };
  2381.             this.pd.setLabels(labels);

  2382.             // Prendo la lista di accordi dell'utente connesso
  2383.             /*List<Long> idsAcc = new ArrayList<Long>();
  2384.             List<AccordoServizio> listaAcc = this.core.accordiList(superUser, new Search(true));
  2385.             Iterator<AccordoServizio> itA = listaAcc.iterator();
  2386.             while (itA.hasNext()) {
  2387.                 AccordoServizio as = (AccordoServizio) itA.next();
  2388.                 idsAcc.add(as.getId());
  2389.             }*/

  2390.             // preparo i dati
  2391.             List<List<DataElement>> dati = new ArrayList<>();

  2392.             for (int i = 0; i < lista.size(); i++) {
  2393.                 AccordoServizioParteSpecifica asps = lista.get(i);

  2394.                 Fruitore fruitore = null;
  2395.                 if(showConfigurazionePD) {
  2396.                     fruitore = asps.getFruitore(0); // NOTA: il metodo 'soggettiServizioList' ritorna un unico fruitore in caso di gestioneFruitori abiltata per ogni entry. Crea cioè un accordo con fruitore per ogni fruitore esistente
  2397.                 }
  2398.                
  2399.                 String protocollo = protocolli.get(i);
  2400.                
  2401.                 List<DataElement> e = new ArrayList<>();

  2402.                 Parameter pIdsoggErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, ""+asps.getIdSoggetto());
  2403.                 Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  2404.                 Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  2405.                 @SuppressWarnings("unused")
  2406.                 Parameter pVersioneServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VERSIONE, asps.getVersione().intValue()+"");

  2407.                 String uriASPS = this.idServizioFactory.getUriFromAccordo(asps);
  2408.                
  2409.                 Soggetto sog = this.soggettiCore.getSoggettoRegistro(asps.getIdSoggetto());
  2410.                 boolean isPddEsterna = this.pddCore.isPddEsterna(sog.getPortaDominio());
  2411.                
  2412.                 DataElement de = new DataElement();
  2413.                 de.setUrl(
  2414.                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE,
  2415.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId() + ""),
  2416.                     pNomeServizio, pTipoServizio, pIdsoggErogatore);
  2417.                 de.setValue(this.getLabelNomeServizio(protocollo, asps.getTipo(), asps.getNome(), asps.getVersione()));
  2418.                 de.setIdToRemove(uriASPS);
  2419.                 e.add(de);

  2420.                        
  2421.                 if(showSoggettoErogatore) {
  2422.                     de = new DataElement();
  2423.                     de.setUrl(
  2424.                             SoggettiCostanti.SERVLET_NAME_SOGGETTI_CHANGE,
  2425.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_ID, asps.getIdSoggetto() + ""),
  2426.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_TIPO, asps.getTipoSoggettoErogatore()),
  2427.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_NOME, asps.getNomeSoggettoErogatore()));
  2428.                     de.setValue(this.getLabelNomeSoggetto(protocollo, asps.getTipoSoggettoErogatore() , asps.getNomeSoggettoErogatore()));
  2429.                     e.add(de);
  2430.                 }
  2431.                
  2432.                 if(showSoggettoFruitore) {
  2433.                     de = new DataElement();
  2434.                     de.setUrl(
  2435.                             SoggettiCostanti.SERVLET_NAME_SOGGETTI_CHANGE,
  2436.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_ID, fruitore.getIdSoggetto() + ""),
  2437.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_TIPO, fruitore.getTipo()),
  2438.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_NOME, fruitore.getNome()));
  2439.                     de.setValue(this.getLabelNomeSoggetto(protocollo, fruitore.getTipo() , fruitore.getNome()));
  2440.                     e.add(de);
  2441.                 }
  2442.                
  2443.                 if(showProtocolli) {
  2444.                     de = new DataElement();
  2445.                     de.setValue(this.getLabelProtocollo(protocollo));
  2446.                     e.add(de);
  2447.                 }
  2448.                
  2449.                 de = new DataElement();
  2450.                 AccordoServizioParteComuneSintetico apc = listApc.get(i);
  2451.                 ServiceBinding serviceBinding = this.apcCore.toMessageServiceBinding(apc.getServiceBinding());

  2452.                 Parameter pTipoAccordo = AccordiServizioParteComuneUtilities.getParametroAccordoServizio(apc);

  2453.                 de.setUrl(
  2454.                         AccordiServizioParteComuneCostanti.SERVLET_NAME_APC_CHANGE,
  2455.                         new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getIdAccordo() + ""),
  2456.                         new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME, apc.getNome()), pTipoAccordo);
  2457.                 de.setValue(this.getLabelIdAccordo(apc));
  2458.                 e.add(de);
  2459.                
  2460.                 if(showServiceBinding) {
  2461.                     de = new DataElement();
  2462.                     switch (serviceBinding) {
  2463.                     case REST:
  2464.                         de.setValue(CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_REST);
  2465.                         break;
  2466.                     case SOAP:
  2467.                     default:
  2468.                         de.setValue(CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_SOAP);
  2469.                         break;
  2470.                     }
  2471.                     e.add(de);
  2472.                 }
  2473.                
  2474.                 // colonna configurazioni
  2475.                 if(showConfigurazionePA) {
  2476.                    
  2477.                     // Utilizza la configurazione come parent
  2478.                     ServletUtils.setObjectIntoSession(this.request, this.session, PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE, PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT);
  2479.                                        
  2480.                     IDServizio idServizio = this.idServizioFactory.getIDServizioFromAccordo(asps);
  2481.                    
  2482.                     Parameter paIdSogg = null;
  2483.                     Parameter paNomePorta = null;
  2484.                     Parameter paIdPorta = null;
  2485.                     Parameter paIdAsps = null;
  2486.                     Parameter paConfigurazioneDati = null;
  2487.                     Parameter paIdProvider = null;
  2488.                     Parameter paIdPortaPerSA = null;
  2489.                     Parameter paConnettoreDaListaAPS = null;
  2490.                     IDPortaApplicativa idPA = null;
  2491.                     PortaApplicativa paDefault = null;
  2492.                     PortaApplicativaServizioApplicativo paSADefault = null;
  2493.                     boolean connettoreMultiploEnabled = false;
  2494.                     boolean checkConnettore = false;
  2495.                     boolean visualizzaConnettore = true;
  2496.                     long idConnettore = 1;
  2497.                     if(!isPddEsterna){
  2498.                         idPA = this.porteApplicativeCore.getIDPortaApplicativaAssociataDefault(idServizio);
  2499.                         if(idPA!=null) {
  2500.                             paDefault = this.porteApplicativeCore.getPortaApplicativa(idPA);
  2501.                         }
  2502.                         paIdSogg = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, asps.getIdSoggetto() + "");
  2503.                         paIdAsps = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, asps.getId()+ "");
  2504.                         paConfigurazioneDati = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONFIGURAZIONE_DATI_INVOCAZIONE, Costanti.CHECK_BOX_ENABLED_TRUE);
  2505.                         paConnettoreDaListaAPS = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS, Costanti.CHECK_BOX_ENABLED_TRUE);
  2506.                         if(paDefault!=null) {
  2507.                             paSADefault = paDefault.getServizioApplicativoList().get(0);
  2508.                             paNomePorta = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_PORTA, paDefault.getNome());
  2509.                             paIdPorta = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, ""+paDefault.getId());
  2510.                             paIdProvider = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_PROVIDER, paDefault.getIdSoggetto() + "");
  2511.                             paIdPortaPerSA = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_PORTA, ""+paDefault.getId());
  2512.                         }
  2513.                        
  2514.                         List<MappingErogazionePortaApplicativa> listaMappingErogazionePortaApplicativa = this.apsCore.mappingServiziPorteAppList(idServizio,asps.getId(), null);
  2515.                         List<PortaApplicativa> listaPorteApplicativeAssociate = new ArrayList<>();
  2516.                         for(MappingErogazionePortaApplicativa mappinErogazione : listaMappingErogazionePortaApplicativa) {
  2517.                             listaPorteApplicativeAssociate.add(this.porteApplicativeCore.getPortaApplicativa(mappinErogazione.getIdPortaApplicativa()));
  2518.                         }
  2519.                        
  2520.                         for (int z= 0; z < listaPorteApplicativeAssociate.size(); z++) {
  2521.                             PortaApplicativa paAssociata = listaPorteApplicativeAssociate.get(z);
  2522.                             MappingErogazionePortaApplicativa mapping = listaMappingErogazionePortaApplicativa.get(z);
  2523.                            
  2524.                             if(!mapping.isDefault()) {
  2525.                                 PortaApplicativaServizioApplicativo portaApplicativaAssociataServizioApplicativo = paAssociata.getServizioApplicativoList().get(0);
  2526.                                 boolean connettoreConfigurazioneRidefinito = this.isConnettoreRidefinito(paDefault, paSADefault, paAssociata, portaApplicativaAssociataServizioApplicativo, paAssociata.getServizioApplicativoList());
  2527.                                 if(connettoreConfigurazioneRidefinito) {
  2528.                                     visualizzaConnettore = false;
  2529.                                     break;
  2530.                                 }
  2531.                             }
  2532.                            
  2533.                         }
  2534.                        
  2535.                         if(visualizzaConnettore) {
  2536.                             if(paDefault!=null) {
  2537.                                 connettoreMultiploEnabled = paDefault.getBehaviour() != null;
  2538.                                 PortaApplicativaServizioApplicativo paDefautServizioApplicativo = paDefault.getServizioApplicativoList().get(0);
  2539.                                 IDServizioApplicativo idServizioApplicativo = new IDServizioApplicativo();
  2540.                                 idServizioApplicativo.setIdSoggettoProprietario(new IDSoggetto(paDefault.getTipoSoggettoProprietario(), paDefault.getNomeSoggettoProprietario()));
  2541.                                 idServizioApplicativo.setNome(paDefautServizioApplicativo.getNome());
  2542.                                 ServizioApplicativo sa = this.saCore.getServizioApplicativo(idServizioApplicativo);
  2543.                                 org.openspcoop2.core.config.Connettore connettore = sa.getInvocazioneServizio().getConnettore();
  2544.                                 idConnettore = connettore.getId();
  2545.                                 checkConnettore = org.openspcoop2.pdd.core.connettori.ConnettoreCheck.checkSupported(connettore);
  2546.                             }
  2547.                         }
  2548.                     }
  2549.                    
  2550.                    
  2551.                     // url invocazione
  2552.                     de = new DataElement();
  2553.                     if(isPddEsterna || this.isModalitaCompleta()){
  2554.                         de.setType(DataElementType.TEXT);
  2555.                         de.setValue("-");
  2556.                     }
  2557.                     else{                  
  2558.                         de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CHANGE,paIdSogg, paNomePorta, paIdPorta,paIdAsps,paConfigurazioneDati);
  2559.                         ServletUtils.setDataElementVisualizzaLabel(de);                    
  2560.                     }
  2561.                     e.add(de);
  2562.                    
  2563.                    
  2564.                     // connettore
  2565.                     if(showConnettorePA) {
  2566.                         de = new DataElement();
  2567.                         if(isPddEsterna || this.isModalitaCompleta()){
  2568.                             de.setType(DataElementType.TEXT);
  2569.                             de.setValue("-");
  2570.                         }
  2571.                         else{  
  2572.                            
  2573.                             boolean visualizzaLinkConfigurazioneConnettore =
  2574.                                     visualizzaConnettore &&
  2575.                                     (
  2576.                                             (!this.core.isConnettoriMultipliEnabled())
  2577.                                             ||
  2578.                                             ( !connettoreMultiploEnabled )
  2579.                                     );
  2580.                             if(visualizzaLinkConfigurazioneConnettore) {
  2581.                                 PortaApplicativaServizioApplicativo portaApplicativaServizioApplicativo = paDefault.getServizioApplicativoList().get(0);
  2582.                                 //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  2583.                                 de.setUrl(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT, paIdProvider, paIdPortaPerSA, paIdAsps,
  2584.                                         new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_NOME_SERVIZIO_APPLICATIVO, portaApplicativaServizioApplicativo.getNome()),
  2585.                                         new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_SERVIZIO_APPLICATIVO, portaApplicativaServizioApplicativo.getIdServizioApplicativo()+""),
  2586.                                         paConnettoreDaListaAPS);
  2587.                                 ServletUtils.setDataElementVisualizzaLabel(de);
  2588.                             } else {
  2589.                                 de.setType(DataElementType.TEXT);
  2590.                                 de.setValue("-");
  2591.                             }
  2592.                         }
  2593.                         e.add(de);
  2594.                        
  2595.                         // verifica
  2596.                         de = new DataElement();
  2597.                         Parameter pIdConnettore = new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ID, idConnettore+"");
  2598.                         Parameter pConnettoreAccessoDaGruppi = new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_GRUPPI, "false");
  2599.                         Parameter pConnettoreVerificaAccesso = new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_REGISTRO, "false");
  2600.                         if(isPddEsterna || this.isModalitaCompleta()){
  2601.                             de.setType(DataElementType.TEXT);
  2602.                             de.setValue("-");
  2603.                         }
  2604.                         else{
  2605.                             boolean visualizzaLinkCheckConnettore =
  2606.                                     visualizzaConnettore &&
  2607.                                     checkConnettore &&
  2608.                                     (
  2609.                                             !this.core.isConnettoriMultipliEnabled()
  2610.                                             ||
  2611.                                             ( !connettoreMultiploEnabled )
  2612.                                     );
  2613.                             if(visualizzaLinkCheckConnettore) {
  2614.                                 List<Parameter> listParametersVerificaConnettore = new ArrayList<>();
  2615.                                 paIdSogg = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, asps.getIdSoggetto() + "");
  2616.                                 listParametersVerificaConnettore.add(paIdSogg);
  2617.                                 listParametersVerificaConnettore.add(paIdPorta);
  2618.                                 listParametersVerificaConnettore.add(paIdAsps);
  2619.                                 listParametersVerificaConnettore.add(paConnettoreDaListaAPS);
  2620.                                 listParametersVerificaConnettore.add(pIdConnettore);
  2621.                                 listParametersVerificaConnettore.add(pConnettoreAccessoDaGruppi);
  2622.                                 listParametersVerificaConnettore.add(pConnettoreVerificaAccesso);
  2623.                                
  2624.                                 de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_VERIFICA_CONNETTORE,
  2625.                                         listParametersVerificaConnettore.toArray(new Parameter[1]));
  2626.                                 ServletUtils.setDataElementVisualizzaLabel(de);
  2627.                             } else {
  2628.                                 de.setType(DataElementType.TEXT);
  2629.                                 de.setValue("-");
  2630.                             }
  2631.                            
  2632.                         }
  2633.                         e.add(de);
  2634.                        
  2635.                         // configura connettori multipli
  2636.                         de = new DataElement();
  2637.                         if(isPddEsterna || this.isModalitaCompleta()){
  2638.                             de.setType(DataElementType.TEXT);
  2639.                             de.setValue("-");
  2640.                         }
  2641.                         else{
  2642.                             if(visualizzaConnettore && this.core.isConnettoriMultipliEnabled()) {
  2643.                                 List<Parameter> listParametersConfigutazioneConnettoriMultipli = new ArrayList<>();
  2644.                                 paIdSogg = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, asps.getIdSoggetto() + "");
  2645.                                 listParametersConfigutazioneConnettoriMultipli.add(paIdSogg);
  2646.                                 listParametersConfigutazioneConnettoriMultipli.add(paIdPorta);
  2647.                                 listParametersConfigutazioneConnettoriMultipli.add(paIdAsps);
  2648.                                 listParametersConfigutazioneConnettoriMultipli.add(paConnettoreDaListaAPS);
  2649.                                 listParametersConfigutazioneConnettoriMultipli.add(pIdConnettore);
  2650.                                 listParametersConfigutazioneConnettoriMultipli.add(pConnettoreAccessoDaGruppi);
  2651.                                 listParametersConfigutazioneConnettoriMultipli.add(pConnettoreVerificaAccesso);
  2652.                                
  2653.                                 de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONFIGURAZIONE_CONNETTORI_MULTIPLI,
  2654.                                         listParametersConfigutazioneConnettoriMultipli.toArray(new Parameter[1]));
  2655.                                 de.setValue(this.getStatoConnettoriMultipliPortaApplicativa(paDefault));
  2656.                                
  2657.                             } else {
  2658.                                 de.setType(DataElementType.TEXT);
  2659.                                 de.setValue("-");
  2660.                             }
  2661.                         }
  2662.                         e.add(de);
  2663.                        
  2664.                         // lista  connettori multipli
  2665.                         de = new DataElement();
  2666.                         if(isPddEsterna || this.isModalitaCompleta()){
  2667.                             de.setType(DataElementType.TEXT);
  2668.                             de.setValue("-");
  2669.                         }
  2670.                         else{
  2671.                             if(visualizzaConnettore && this.core.isConnettoriMultipliEnabled() && connettoreMultiploEnabled) {
  2672.                                 List<Parameter> listParametersConfigutazioneConnettoriMultipli = new ArrayList<>();
  2673.                                 paIdSogg = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, asps.getIdSoggetto() + "");
  2674.                                 listParametersConfigutazioneConnettoriMultipli.add(paIdSogg);
  2675.                                 listParametersConfigutazioneConnettoriMultipli.add(paIdPorta);
  2676.                                 listParametersConfigutazioneConnettoriMultipli.add(paIdAsps);
  2677.                                 listParametersConfigutazioneConnettoriMultipli.add(paConnettoreDaListaAPS);
  2678.                                 listParametersConfigutazioneConnettoriMultipli.add(pIdConnettore);
  2679.                                 listParametersConfigutazioneConnettoriMultipli.add(pConnettoreAccessoDaGruppi);
  2680.                                 listParametersConfigutazioneConnettoriMultipli.add(pConnettoreVerificaAccesso);
  2681.                                 listParametersConfigutazioneConnettoriMultipli.add(new Parameter(CostantiControlStation.PARAMETRO_ID_CONN_TAB, "0"));
  2682.                                
  2683.                                 de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_LIST,
  2684.                                         listParametersConfigutazioneConnettoriMultipli.toArray(new Parameter[1]));
  2685.                                
  2686.                                 if(contaListe)
  2687.                                     ServletUtils.setDataElementVisualizzaLabel(de, (long) paDefault.sizeServizioApplicativoList());
  2688.                                 else
  2689.                                     ServletUtils.setDataElementVisualizzaLabel(de);
  2690.                                    
  2691.                             }else {
  2692.                                 de.setType(DataElementType.TEXT);
  2693.                                 de.setValue("-");
  2694.                             }
  2695.                         }
  2696.                         e.add(de);
  2697.                     }
  2698.                    
  2699.                     // configurazione
  2700.                     de = new DataElement();
  2701.                     if(isPddEsterna){
  2702.                         de.setType(DataElementType.TEXT);
  2703.                         de.setValue("-");
  2704.                     }
  2705.                     else{
  2706.                         de.setUrl(
  2707.                                 AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_PORTE_APPLICATIVE_LIST,
  2708.                                 new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId() + ""),
  2709.                                 pNomeServizio, pTipoServizio, pIdsoggErogatore,
  2710.                                 new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_GRUPPI,"true"),
  2711.                                 new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_CONFIGURAZIONI,"true"));
  2712.                         // +"&nomeprov="+soggErogatore+"&tipoprov="+tipoSoggEr);
  2713.                         if (contaListe) {
  2714.                             // BugFix OP-674
  2715.                             //List<PortaApplicativa> lista1 = this.apsCore.serviziPorteAppList(servizio.getTipo(),servizio.getNome(),asps.getVersione(),
  2716.                             //      asps.getId().intValue(), asps.getIdSoggetto(), new Search(true));
  2717.                             ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  2718.                             this.apsCore.mappingServiziPorteAppList(idServizio, asps.getId(), searchForCount);
  2719.                             //int numPA = lista1.size();
  2720.                             int numPA = searchForCount.getNumEntries(Liste.CONFIGURAZIONE_EROGAZIONE);
  2721.                             ServletUtils.setDataElementVisualizzaLabel(de, (long) numPA );
  2722.                         } else
  2723.                             ServletUtils.setDataElementVisualizzaLabel(de);
  2724.                     }
  2725.                     e.add(de);
  2726.                    
  2727.                 }
  2728.                
  2729.                 if(showConfigurazionePD) {
  2730.                    
  2731.                     // Utilizza la configurazione come parent
  2732.                     ServletUtils.setObjectIntoSession(this.request, this.session, PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE, PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT);
  2733.                                        
  2734.                     IDServizio idServizio = this.idServizioFactory.getIDServizioFromAccordo(asps);
  2735.                     IDSoggetto idFruitore = new IDSoggetto(fruitore.getTipo(), fruitore.getNome());
  2736.                    
  2737.                     IDPortaDelegata idPD = this.porteDelegateCore.getIDPortaDelegataAssociataDefault(idServizio, idFruitore);
  2738.                     PortaDelegata pdDefault = this.porteDelegateCore.getPortaDelegata(idPD);
  2739.                        
  2740.                     Parameter pIdPD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + pdDefault.getId());
  2741.                     Parameter pNomePD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, pdDefault.getNome());
  2742.                     Parameter pIdSoggPD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, pdDefault.getIdSoggetto() + "");
  2743.                     Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, asps.getId()+"");
  2744.                     Parameter pId = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId()+"");
  2745.                     Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, asps.getIdSoggetto()+"");
  2746.                     Parameter pIdFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, fruitore.getId()+ "");
  2747.                     Parameter pConfigurazioneDati = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_DATI_INVOCAZIONE, Costanti.CHECK_BOX_ENABLED_TRUE);
  2748.                     Parameter pConnettoreDaListaAPS = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONNETTORE_DA_LISTA_APS, Costanti.CHECK_BOX_ENABLED_TRUE);
  2749.                                        
  2750.                     Long idSoggettoLong = fruitore.getIdSoggetto();
  2751.                     if(idSoggettoLong==null) {
  2752.                         idSoggettoLong = this.soggettiCore.getIdSoggetto(fruitore.getNome(), fruitore.getTipo());
  2753.                     }
  2754.                     Parameter pIdProviderFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE, idSoggettoLong + "");
  2755.                     Parameter pIdSogg = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO, idSoggettoLong + "");
  2756.                    
  2757.                     // url invocazione
  2758.                     de = new DataElement();            
  2759.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneDati);
  2760.                     ServletUtils.setDataElementVisualizzaLabel(de);                    
  2761.                     e.add(de);              
  2762.                    
  2763.                     // connettore  
  2764.                     if(showConnettorePD) {
  2765.                        
  2766.                         // Controllo se richiedere il connettore
  2767.                         boolean connettoreStatic = false;
  2768.                         if(gestioneFruitori) {
  2769.                             connettoreStatic = this.apsCore.isConnettoreStatic(protocollo);
  2770.                         }
  2771.                        
  2772.                         de = new DataElement();
  2773.                         if(!connettoreStatic) {
  2774.                             List<Parameter> listParameter = new ArrayList<>();
  2775.                             listParameter.add(pId);
  2776.                             listParameter.add(pIdFruitore);
  2777.                             listParameter.add(pIdSoggettoErogatore);
  2778.                             listParameter.add(pIdProviderFruitore);
  2779.                             listParameter.add(pConnettoreDaListaAPS);
  2780.                             de.setUrl(
  2781.                                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE,
  2782.                                     listParameter.toArray(new Parameter[1])
  2783.                                     );
  2784.                             ServletUtils.setDataElementVisualizzaLabel(de);
  2785.                         }
  2786.                         else {
  2787.                             de.setValue("-");
  2788.                         }
  2789.                         e.add(de);
  2790.                     }
  2791.                    
  2792.                     // configurazione
  2793.                     de = new DataElement();
  2794.                     de.setUrl(
  2795.                             AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_PORTE_DELEGATE_LIST,
  2796.                             pId, pIdSogg, pIdSoggettoErogatore, pNomeServizio, pTipoServizio, pIdFruitore,
  2797.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_GRUPPI,"true"),
  2798.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_CONFIGURAZIONI,"true"));
  2799.                     if (contaListe) {
  2800.                         // BugFix OP-674
  2801. //                              List<PortaDelegata> fruLista = this.apsCore.serviziFruitoriPorteDelegateList(this.soggettiCore.getIdSoggetto(fru.getNome(), fru.getTipo()),
  2802. //                                      serv.getTipo(), serv.getNome(), asps.getId(),
  2803. //                                      serv.getTipoSoggettoErogatore(), serv.getNomeSoggettoErogatore(), asps.getIdSoggetto(),
  2804. //                                      ricerca);
  2805.                         ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  2806.                         IDServizio idServizioFromAccordo = this.idServizioFactory.getIDServizioFromAccordo(asps);
  2807.                         //long idSoggetto = this.soggettiCore.getIdSoggetto(fru.getNome(), fru.getTipo());
  2808.                         this.apsCore.serviziFruitoriMappingList(fruitore.getId(), idFruitore , idServizioFromAccordo, searchForCount);
  2809.                         //int numPD = fruLista.size();
  2810.                         int numPD = searchForCount.getNumEntries(Liste.CONFIGURAZIONE_FRUIZIONE);
  2811.                         ServletUtils.setDataElementVisualizzaLabel(de, (long) numPD );
  2812.                     } else
  2813.                         ServletUtils.setDataElementVisualizzaLabel(de);
  2814.                     e.add(de);
  2815.                 }
  2816.                
  2817.                 // Colonna ruoli
  2818. //              if(showRuoli){
  2819. //                  de = new DataElement();
  2820. //                  if(this.core.isProfiloDiCollaborazioneAsincronoSupportatoDalProtocollo(protocollo,serviceBinding)){
  2821. //                      de.setValue((TipologiaServizio.CORRELATO.equals(asps.getTipologiaServizio()) ?
  2822. //                              AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_CORRELATO :
  2823. //                                  AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_NORMALE));
  2824. //  
  2825. //                  }else {
  2826. //                      de.setValue("-");
  2827. //                  }
  2828. //                  e.add(de);
  2829. //              }

  2830.                 if(this.isShowGestioneWorkflowStatoDocumenti()){
  2831.                     if(this.core.isGestioneWorkflowStatoDocumentiVisualizzaStatoLista()) {
  2832.                         de = new DataElement();
  2833.                         de.setValue(StatiAccordo.upper(asps.getStatoPackage()));
  2834.                         e.add(de);
  2835.                     }
  2836.                 }

  2837.                 if(showFruitori) {
  2838.                     de = new DataElement();
  2839.                     //if(!user.isPermitMultiTenant() && !isPddEsterna) {
  2840.                     if(!isPddEsterna) {
  2841.                         de.setValue("-");
  2842.                     }
  2843.                     else {
  2844.                         de.setUrl(
  2845.                                 AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_LIST,
  2846.                                 new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId() + ""),
  2847.                                 pNomeServizio, pTipoServizio, pIdsoggErogatore);
  2848.                         // +"&nomeprov="+soggErogatore+"&tipoprov="+tipoSoggEr);
  2849.                         if (contaListe) {
  2850.                             // BugFix OP-674
  2851.                             //List<Fruitore> lista1 = this.apsCore.serviziFruitoriList(asps.getId().intValue(), new Search(true));
  2852.                             ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  2853.                             this.apsCore.serviziFruitoriList(asps.getId().intValue(), searchForCount);
  2854.                             //int numFru = lista1.size();
  2855.                             int numFru = searchForCount.getNumEntries(Liste.SERVIZI_FRUITORI);
  2856.                             ServletUtils.setDataElementVisualizzaLabel(de, (long) numFru);
  2857.                         } else
  2858.                             ServletUtils.setDataElementVisualizzaLabel(de);
  2859.                     }
  2860.                     e.add(de);
  2861.                 }

  2862.                 // de = new DataElement();
  2863.                 // de.setUrl("serviziRuoli.do?id="+servizio.getId());
  2864.                 // de.setValue("visualizza");
  2865.                 // e.add(de);
  2866.                 //
  2867.                 // de = new DataElement();
  2868.                 // de.setValue("non disp.");
  2869.                 // e.add(de);

  2870.                 if(!this.isModalitaStandard()) {
  2871.                     de = new DataElement();
  2872.    
  2873.                     de.setUrl(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ALLEGATI_LIST,
  2874.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId() + ""));
  2875.                     if (contaListe) {
  2876.                         // BugFix OP-674
  2877.                         //List<org.openspcoop2.core.registry.Documento> tmpLista = this.apsCore.serviziAllegatiList(asps.getId().intValue(), new Search(true));
  2878.                         ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  2879.                         this.apsCore.serviziAllegatiList(asps.getId().intValue(), searchForCount);
  2880.                         //int numAllegati = tmpLista.size();
  2881.                         int numAllegati = searchForCount.getNumEntries(Liste.SERVIZI_ALLEGATI);
  2882.                         ServletUtils.setDataElementVisualizzaLabel(de, (long) numAllegati);
  2883.                     } else
  2884.                         ServletUtils.setDataElementVisualizzaLabel(de);
  2885.                     e.add(de);
  2886.                 }

  2887.                 dati.add(e);
  2888.             }

  2889.             this.pd.setDati(dati);
  2890.             this.pd.setAddButton(true);

  2891.             // preparo bottoni
  2892.             // String gestioneWSBL = (String) this.session
  2893.             // .getAttribute("GestioneWSBL");
  2894.             if(lista!=null && lista.size()>0){
  2895.                 if (this.core.isShowPulsantiImportExport()) {

  2896.                     ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);
  2897.                     if(exporterUtils.existsAtLeastOneExportMode(ArchiveType.ACCORDO_SERVIZIO_PARTE_SPECIFICA, this.request, this.session)){

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

  2899.                         AreaBottoni ab = new AreaBottoni();
  2900.                         List<DataElement> otherbott = new ArrayList<>();
  2901.                         DataElement de = new DataElement();
  2902.                         de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_APS_ESPORTA_SELEZIONATI);
  2903.                         de.setOnClick(AccordiServizioParteSpecificaCostanti.LABEL_APS_ESPORTA_SELEZIONATI_ONCLICK);
  2904.                         de.setDisabilitaAjaxStatus();
  2905.                         otherbott.add(de);
  2906.                         ab.setBottoni(otherbott);
  2907.                         bottoni.add(ab);

  2908.                         this.pd.setAreaBottoni(bottoni);

  2909.                     }
  2910.                 }
  2911.             }

  2912.         } catch (Exception e) {
  2913.             this.logError("Exception: " + e.getMessage(), e);
  2914.             throw new Exception(e);
  2915.         }
  2916.     }


  2917.     public void prepareServiziFruitoriList(List<Fruitore> lista, String id, ISearch ricerca)
  2918.             throws Exception {
  2919.         try {
  2920.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  2921.            
  2922.             ServletUtils.addListElementIntoSession(this.request, this.session, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI,
  2923.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id));

  2924.             int idLista = Liste.SERVIZI_FRUITORI;
  2925.             int limit = ricerca.getPageSize(idLista);
  2926.             int offset = ricerca.getIndexIniziale(idLista);
  2927.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  2928.             if(this.isShowGestioneWorkflowStatoDocumenti()){
  2929.                 if(this.core.isGestioneWorkflowStatoDocumentiVisualizzaStatoLista()) {
  2930.                     String filterStatoAccordo = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_STATO_ACCORDO);
  2931.                     this.addFilterStatoAccordo(filterStatoAccordo,false);
  2932.                 }
  2933.             }
  2934.            
  2935.             this.pd.setIndex(offset);
  2936.             this.pd.setPageSize(limit);
  2937.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  2938.             String idSoggettoErogatoreDelServizio = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);
  2939.             if ((idSoggettoErogatoreDelServizio == null) || idSoggettoErogatoreDelServizio.equals("")) {
  2940.                 PageData oldPD = ServletUtils.getPageDataFromSession(this.request, this.session);

  2941.                 idSoggettoErogatoreDelServizio = oldPD.getHidden(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);

  2942.                 if (idSoggettoErogatoreDelServizio == null || idSoggettoErogatoreDelServizio.equals("")) {
  2943.                     AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(id));
  2944.                     String tipoSoggettoErogatore = asps.getTipoSoggettoErogatore();
  2945.                     String nomesoggettoErogatore = asps.getNomeSoggettoErogatore();
  2946.                     IDSoggetto idSE = new IDSoggetto(tipoSoggettoErogatore, nomesoggettoErogatore);
  2947.                     Soggetto SE = this.soggettiCore.getSoggettoRegistro(idSE);
  2948.                     idSoggettoErogatoreDelServizio = "" + SE.getId();
  2949.                 }
  2950.             }

  2951.             // setto i dati come campi hidden nel pd per portarmeli dietro
  2952.             this.pd.addHidden(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, idSoggettoErogatoreDelServizio);

  2953.             // Prendo il nome e il tipo del servizio
  2954.             AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(id));
  2955.            
  2956.             String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(asps.getTipoSoggettoErogatore());
  2957.            
  2958.             // Prendo il nome e il tipo del soggetto erogatore del servizio
  2959.             //Soggetto sogg = this.soggettiCore.getSoggettoRegistro(Integer.parseInt(idSoggettoErogatoreDelServizio));

  2960.             String tmpTitle = this.getLabelIdServizio(asps);

  2961.             // setto la barra del titolo
  2962.             List<Parameter> lstParm = new ArrayList<>();

  2963.             lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));

  2964.             if (search.equals("")) {
  2965.                 this.pd.setSearchDescription("");
  2966.                 lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FUITORI_DI  + tmpTitle, null));
  2967.             }else {
  2968.                 lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FUITORI_DI  + tmpTitle,
  2969.                         AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_LIST ,
  2970.                         new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, ""+ id)
  2971.                         ));
  2972.                 lstParm.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  2973.             }

  2974.             // setto la barra del titolo
  2975.             ServletUtils.setPageDataTitle(this.pd, lstParm );


  2976.             // controllo eventuali risultati ricerca
  2977.             this.pd.setSearchLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO);
  2978.             if (!search.equals("")) {
  2979.                 ServletUtils.enabledPageDataSearch(this.pd, AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI, search);
  2980.             }

  2981.             // setto le label delle colonne
  2982.             //User user = ServletUtils.getUserFromSession(this.session);
  2983.             String labelFruitore = AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO;
  2984.             //if(this.core.isTerminologiaSICA_RegistroServizi()){
  2985.             //  labelFruitore = "Adesione";
  2986.             //}
  2987.             boolean showPoliticheSLA = false;
  2988.            
  2989.             List<String> listaLabelTabella = new ArrayList<>();
  2990.             listaLabelTabella.add(labelFruitore);
  2991.             if(this.isShowGestioneWorkflowStatoDocumenti() && this.core.isGestioneWorkflowStatoDocumentiVisualizzaStatoLista()){
  2992.                 listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_STATO);
  2993.             }
  2994.             listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_DATI_INVOCAZIONE);
  2995.             listaLabelTabella.add(AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_DELEGATE);
  2996.            
  2997.             this.pd.setLabels(listaLabelTabella.toArray(new String[1]));

  2998.             Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, idSoggettoErogatoreDelServizio);
  2999.             Parameter pId = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id);
  3000.             Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  3001.             Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  3002. //          @SuppressWarnings("unused")
  3003. //          Parameter pVersioneServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VERSIONE, asps.getVersione().intValue()+"");

  3004.             // preparo i dati
  3005.             List<List<DataElement>> dati = new ArrayList<>();

  3006.             Iterator<Fruitore> it = lista.iterator();
  3007.             Fruitore fru = null;
  3008.             while (it.hasNext()) {
  3009.                 fru = it.next();
  3010.                 List<DataElement> e = new ArrayList<>();

  3011.                 Parameter pMyId = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, fru.getId() + "");              

  3012.                 DataElement de = new DataElement();
  3013.                 de.setType(DataElementType.HIDDEN);
  3014.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_FRUITORE);
  3015.                 de.setValue("" + fru.getId());
  3016.                 e.add(de);

  3017.                 de = new DataElement();
  3018.                 de.setUrl(
  3019.                         AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE,
  3020.                         pId,    pMyId, pIdSoggettoErogatore,
  3021.                         new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE, fru.getIdSoggetto() + ""));

  3022.                 de.setValue(this.getLabelNomeSoggetto(protocollo, fru.getTipo() , fru.getNome()));
  3023.                 de.setIdToRemove(fru.getId().toString());
  3024.                 e.add(de);

  3025.                 if(this.isShowGestioneWorkflowStatoDocumenti()){
  3026.                     if(this.core.isGestioneWorkflowStatoDocumentiVisualizzaStatoLista()) {
  3027.                         de = new DataElement();
  3028.                         de.setValue(StatiAccordo.upper(fru.getStatoPackage()));
  3029.                         e.add(de);
  3030.                     }
  3031.                 }

  3032.                 Parameter pIdSogg = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO, fru.getIdSoggetto() + "");
  3033.                 // devo aggiungere le politiche di sicurezza come in
  3034.                 // accordiServizioApplicativoList
  3035.                                        
  3036.                 IDSoggetto fruitore = new IDSoggetto(fru.getTipo(), fru.getNome());
  3037.                 Soggetto fruitoreSogg = this.soggettiCore.getSoggettoRegistro(fruitore);
  3038.                
  3039.                 boolean esterno = this.pddCore.isPddEsterna(fruitoreSogg.getPortaDominio());

  3040.                 // Elimino eventuale configurazione messa come parent (tanto viene re-inserita se entro dentro la lista della configurazione)
  3041.                 ServletUtils.removeObjectFromSession(this.request, this.session, PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT);
  3042.                                    
  3043.                 IDServizio idServizio = this.idServizioFactory.getIDServizioFromAccordo(asps);
  3044.                
  3045.                 Parameter pIdPD = null;
  3046.                 Parameter pNomePD = null;
  3047.                 Parameter pIdSoggPD = null;
  3048.                 Parameter pIdAsps = null;
  3049.                 Parameter pIdFruitore = null;
  3050.                 Parameter pConfigurazioneDati = null;
  3051.                 if(!esterno){
  3052.                     IDPortaDelegata idPD = this.porteDelegateCore.getIDPortaDelegataAssociataDefault(idServizio, fruitore);
  3053.                     PortaDelegata pdDefault = this.porteDelegateCore.getPortaDelegata(idPD);
  3054.                    
  3055.                     pIdPD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + pdDefault.getId());
  3056.                     pNomePD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, pdDefault.getNome());
  3057.                     pIdSoggPD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, pdDefault.getIdSoggetto() + "");
  3058.                     pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, asps.getId()+"");
  3059.                     pIdFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, fru.getId()+ "");
  3060.                     pConfigurazioneDati = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_DATI_INVOCAZIONE, Costanti.CHECK_BOX_ENABLED_TRUE);
  3061.                 }

  3062.                 de = new DataElement();
  3063.                 if(esterno){
  3064.                     de.setType(DataElementType.TEXT);
  3065.                     de.setValue("-");
  3066.                 }
  3067.                 else{                  
  3068.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneDati);
  3069.                     ServletUtils.setDataElementVisualizzaLabel(de);                    
  3070.                 }
  3071.                 e.add(de);              
  3072.                
  3073.                 de = new DataElement();
  3074.                 if(esterno){
  3075.                     de.setValue("-");
  3076.                 }
  3077.                 else{
  3078.                     de.setUrl(
  3079.                             AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_PORTE_DELEGATE_LIST,
  3080.                             pId, pIdSogg, pIdSoggettoErogatore, pNomeServizio, pTipoServizio, pMyId,
  3081.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_GRUPPI,"true"),
  3082.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_CONFIGURAZIONI,"true"));
  3083.                     if (contaListe) {
  3084.                         // BugFix OP-674
  3085. //                          List<PortaDelegata> fruLista = this.apsCore.serviziFruitoriPorteDelegateList(this.soggettiCore.getIdSoggetto(fru.getNome(), fru.getTipo()),
  3086. //                                  serv.getTipo(), serv.getNome(), asps.getId(),
  3087. //                                  serv.getTipoSoggettoErogatore(), serv.getNomeSoggettoErogatore(), asps.getIdSoggetto(),
  3088. //                                  ricerca);
  3089.                         ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  3090.                         IDServizio idServizioFromAccordo = this.idServizioFactory.getIDServizioFromAccordo(asps);
  3091.                         //long idSoggetto = this.soggettiCore.getIdSoggetto(fru.getNome(), fru.getTipo());
  3092.                         IDSoggetto idSoggettoFruitore = new IDSoggetto(fru.getNome(), fru.getTipo());
  3093.                         this.apsCore.serviziFruitoriMappingList(fru.getId(), idSoggettoFruitore , idServizioFromAccordo, searchForCount);
  3094.                         //int numPD = fruLista.size();
  3095.                         int numPD = searchForCount.getNumEntries(Liste.CONFIGURAZIONE_FRUIZIONE);
  3096.                         ServletUtils.setDataElementVisualizzaLabel(de, (long) numPD );
  3097.                     } else
  3098.                         ServletUtils.setDataElementVisualizzaLabel(de);
  3099.                 }
  3100.                 e.add(de);
  3101.                
  3102.                 if(showPoliticheSLA){
  3103.                     de = new DataElement();
  3104.                     de.setValue(Costanti.LABEL_NON_DISPONIBILE);
  3105.                     e.add(de);
  3106.                 }

  3107.                 dati.add(e);
  3108.             }

  3109.             this.pd.setDati(dati);
  3110.             this.pd.setAddButton(true);

  3111.             // preparo bottoni
  3112.             /*
  3113.              * if(lista!=null && lista.size()>0){
  3114.              * if (AccordiServizioParteComuneUtilities.getImportaEsporta()) {
  3115.                 List<AreaBottoni> bottoni = new ArrayList<AreaBottoni>();

  3116.                 AreaBottoni ab = new AreaBottoni();
  3117.                 List<DataElement> otherbott = new ArrayList<>();
  3118.                 DataElement de = new DataElement();
  3119.                 de.setValue("Esporta");
  3120.                 de.setOnClick("Esporta()");
  3121.                 otherbott.addElement(de);
  3122.                 ab.setBottoni(otherbott);
  3123.                 bottoni.addElement(ab);

  3124.                 this.pd.setAreaBottoni(bottoni);
  3125.             }
  3126.             }*/

  3127.         } catch (Exception e) {
  3128.             this.logError("Exception: " + e.getMessage(), e);
  3129.             throw new Exception(e);
  3130.         }
  3131.     }

  3132.     public void prepareServiziConfigurazioneList(List<MappingErogazionePortaApplicativa> listaParam, String id, String idSoggettoErogatoreDelServizio, ISearch ricerca)
  3133.             throws Exception {
  3134.         try {
  3135.             Boolean contaListeObject = ServletUtils.getContaListeFromSession(this.session);
  3136.             boolean contaListe = contaListeObject!=null ? contaListeObject.booleanValue() : false;

  3137.             IExtendedListServlet extendedServletList = this.core.getExtendedServletPortaApplicativa();
  3138.            
  3139.             ServletUtils.addListElementIntoSession(this.request, this.session, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,
  3140.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id),
  3141.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, idSoggettoErogatoreDelServizio));

  3142.             String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  3143.             @SuppressWarnings("unused")
  3144.             boolean gestioneErogatori = false;
  3145.             if(tipologia!=null) {
  3146.                 if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE.equals(tipologia)) {
  3147.                     gestioneErogatori = true;
  3148.                 }
  3149.             }
  3150.            
  3151.             boolean gestioneGruppi = true;
  3152.             String paramGestioneGruppi = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_GRUPPI);
  3153.             if(paramGestioneGruppi!=null && !"".equals(paramGestioneGruppi)) {
  3154.                 gestioneGruppi = Boolean.valueOf(paramGestioneGruppi);
  3155.             }
  3156.            
  3157.             boolean gestioneConfigurazioni = true;
  3158.             String paramGestioneConfigurazioni = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_CONFIGURAZIONI);
  3159.             if(paramGestioneConfigurazioni!=null && !"".equals(paramGestioneConfigurazioni)) {
  3160.                 gestioneConfigurazioni = Boolean.valueOf(paramGestioneConfigurazioni);
  3161.             }
  3162.            
  3163.             boolean visualizzazioneTabs = !this.isModalitaCompleta();
  3164.             if(visualizzazioneTabs) {
  3165.                 gestioneGruppi = false;
  3166.                 this.pd.setCustomListViewName(ErogazioniCostanti.ASPS_EROGAZIONI_NOME_VISTA_CUSTOM_CONFIGURAZIONE);
  3167.             }
  3168.            
  3169.             // Prendo il nome e il tipo del servizio
  3170.             AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(id));
  3171.             AccordoServizioParteComuneSintetico apc = this.apcCore.getAccordoServizioSintetico(asps.getIdAccordo());
  3172.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding = apc.getServiceBinding();
  3173.             ServiceBinding serviceBindingMessage = this.apcCore.toMessageServiceBinding(apc.getServiceBinding());
  3174.             String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(asps.getTipoSoggettoErogatore());
  3175.            
  3176.             int idLista = Liste.CONFIGURAZIONE_EROGAZIONE;
  3177.             int limit = ricerca.getPageSize(idLista);
  3178.             int offset = ricerca.getIndexIniziale(idLista);
  3179.            
  3180.             Map<String,String> azioni = this.porteApplicativeCore.getAzioniConLabel(asps, apc, false, true, new ArrayList<>());
  3181.             String filtroAzione = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_AZIONE);
  3182.                        
  3183.             this.pd.setIndex(offset);
  3184.             this.pd.setPageSize(limit);
  3185.             this.pd.setSearch("");
  3186.            
  3187.             List<MappingErogazionePortaApplicativa> listaSenzaFiltro = this.impostaFiltroAzioneMappingErogazione(null, listaParam,ricerca, idLista);
  3188.            
  3189.             boolean showBottoneAggiungiNuovaConfigurazione =
  3190.                     (azioni!=null && azioni.size()>1)
  3191.                     ||
  3192.                     (listaSenzaFiltro.size()>1);
  3193.             if(showBottoneAggiungiNuovaConfigurazione) {
  3194.                 // verifico modalita identificazione
  3195.                 for (MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa : listaParam) {
  3196.                     if(mappingErogazionePortaApplicativa.isDefault()) {
  3197.                         PortaApplicativa paDefaullt = this.porteApplicativeCore.getPortaApplicativa(mappingErogazionePortaApplicativa.getIdPortaApplicativa());
  3198.                         if(paDefaullt.getAzione()!=null &&
  3199.                                 org.openspcoop2.core.config.constants.PortaApplicativaAzioneIdentificazione.STATIC.equals(paDefaullt.getAzione().getIdentificazione())) {
  3200.                             showBottoneAggiungiNuovaConfigurazione = false;
  3201.                         }
  3202.                         break;
  3203.                     }
  3204.                 }
  3205.             }
  3206.            
  3207.             List<MappingErogazionePortaApplicativa> lista = null;
  3208.             boolean chooseTabWithFilter = !this.isModalitaCompleta();
  3209.             if(chooseTabWithFilter) {
  3210.                 lista = listaSenzaFiltro;
  3211.                 if(lista.size()>1) {
  3212.                     MappingErogazionePortaApplicativa mappingContenenteAzione = getFiltroAzioneMappingErogazione(filtroAzione, listaParam);
  3213.                     if(mappingContenenteAzione!=null) {
  3214.                         int tab = -1;
  3215.                         for (int i = 0; i < lista.size(); i++) {
  3216.                             if(lista.get(i).getNome().equals(mappingContenenteAzione.getNome())) {
  3217.                                 tab = i;
  3218.                                 break;
  3219.                             }
  3220.                         }
  3221.                         if(tab>=0) {
  3222.                             ServletUtils.setObjectIntoSession(this.request, this.session, tab+"", CostantiControlStation.PARAMETRO_ID_TAB);
  3223.                         }
  3224.                     }
  3225.                    
  3226.                     this.pd.setLabelBottoneFiltra(CostantiControlStation.LABEL_BOTTONE_INDIVIDUA_GRUPPO);
  3227.                 }
  3228.             }
  3229.             else {
  3230.                 lista = this.impostaFiltroAzioneMappingErogazione(filtroAzione, listaParam,ricerca, idLista);
  3231.             }
  3232.            
  3233.             boolean allActionRedefined = false;
  3234.             List<String> actionNonRidefinite = null;
  3235.             if(listaSenzaFiltro!=null && listaSenzaFiltro.size()>1) {
  3236.                 List<String> azioniL = new ArrayList<>();
  3237.                 if(azioni != null && azioni.size() > 0)
  3238.                     azioniL.addAll(azioni.keySet());
  3239.                 allActionRedefined = this.allActionsRedefinedMappingErogazione(azioniL, listaSenzaFiltro);
  3240.                 if(!allActionRedefined) {
  3241.                     actionNonRidefinite = this.getAllActionsNotRedefinedMappingErogazione(azioniL, listaSenzaFiltro);
  3242.                 }
  3243.             }
  3244.            

  3245.             if(!gestioneGruppi && listaParam.size()<=1) {
  3246.                 ServletUtils.disabledPageDataSearch(this.pd);
  3247.             }
  3248.             else {
  3249.                 this.addFilterAzione(azioni, filtroAzione, serviceBindingMessage);
  3250.             }
  3251.            
  3252.             // Utilizza la configurazione come parent
  3253.             ServletUtils.setObjectIntoSession(this.request, this.session, PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE, PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT);
  3254.            
  3255.             //questo e' il soggetto virtuale
  3256.             if ((idSoggettoErogatoreDelServizio == null) || idSoggettoErogatoreDelServizio.equals("")) {
  3257.                 idSoggettoErogatoreDelServizio = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);
  3258.             }
  3259.            
  3260.             if ((idSoggettoErogatoreDelServizio == null) || idSoggettoErogatoreDelServizio.equals("")) {
  3261.                 PageData oldPD = ServletUtils.getPageDataFromSession(this.request, this.session);

  3262.                 idSoggettoErogatoreDelServizio = oldPD.getHidden(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);
  3263.             }

  3264.             // setto i dati come campi hidden nel pd per portarmeli dietro
  3265.             this.pd.addHidden(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, idSoggettoErogatoreDelServizio);

  3266.             String servizioTmpTile = this.getLabelIdServizio(asps);
  3267.            
  3268.             // setto la barra del titolo
  3269.             List<Parameter> lstParam = new ArrayList<>();

  3270.             Parameter pIdServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId()+ "");
  3271.             Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  3272.             Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  3273.             Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, asps.getIdSoggetto()+"");
  3274.             Boolean vistaErogazioni = ServletUtils.getBooleanAttributeFromSession(ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI, this.session, this.request).getValue();
  3275.             String labelAzioni = this.getLabelAzioni(serviceBindingMessage);
  3276.             if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  3277.                 lstParam.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_EROGAZIONI, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST));
  3278.                
  3279.                 lstParam.add(new Parameter(servizioTmpTile, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_CHANGE, pIdServizio,pNomeServizio, pTipoServizio));
  3280.                 String labelConfigurazione = gestioneConfigurazioni ? ErogazioniCostanti.LABEL_ASPS_GESTIONE_CONFIGURAZIONI :
  3281.                     (gestioneGruppi ? MessageFormat.format(ErogazioniCostanti.LABEL_ASPS_GESTIONE_GRUPPI_CON_PARAMETRO, labelAzioni) : AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_APPLICATIVE);
  3282.                
  3283.                 lstParam.add(new Parameter(labelConfigurazione, null));
  3284.             } else {
  3285.                 lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  3286.                 lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_CONFIGURAZIONI_DI + servizioTmpTile, null));
  3287.             }
  3288.            
  3289.             // setto la barra del titolo
  3290.             ServletUtils.setPageDataTitle(this.pd, lstParam );
  3291.            
  3292.             boolean visualizzaAllarmi = this.confCore.isVisualizzaConfigurazioneAllarmiEnabled();  // configurazione allarmi (solo se sono stati caricati dei plugin di tipo allarme)

  3293.             boolean visualizzaMTOM = true;
  3294.             boolean visualizzaSicurezza = true;
  3295.             boolean visualizzaCorrelazione = true;
  3296.             switch (serviceBinding) {
  3297.             case REST:
  3298.                 visualizzaMTOM = false;
  3299.                 visualizzaSicurezza = true;
  3300.                 visualizzaCorrelazione = true;
  3301.                 break;
  3302.             case SOAP:
  3303.             default:
  3304.                 visualizzaMTOM = true;
  3305.                 visualizzaSicurezza = true;
  3306.                 visualizzaCorrelazione = true;
  3307.                 break;
  3308.             }
  3309.            
  3310.             boolean showConnettoreLink = true;
  3311.             if(gestioneConfigurazioni && this.isModalitaStandard()) {
  3312.                 showConnettoreLink = false;
  3313.                
  3314.                 Iterator<MappingErogazionePortaApplicativa> it = lista.iterator();
  3315.                 MappingErogazionePortaApplicativa mapping= null;
  3316.                 while (it.hasNext()) {
  3317.                     mapping = it.next();
  3318.                     if(!mapping.isDefault()) {
  3319.                         PortaApplicativa paAssociata = this.porteApplicativeCore.getPortaApplicativa(mapping.getIdPortaApplicativa());
  3320.                         PortaApplicativaServizioApplicativo portaApplicativaServizioApplicativo = paAssociata.getServizioApplicativoList().get(0);
  3321.                         if(portaApplicativaServizioApplicativo.getNome().equals(paAssociata.getNome())) {
  3322.                             showConnettoreLink = true;
  3323.                             break;
  3324.                         }
  3325.                         // controllo che non sia un server
  3326.                         if(this.saCore.isApplicativiServerEnabled(this)) {
  3327.                             IDServizioApplicativo idSA = new IDServizioApplicativo();
  3328.                             idSA.setIdSoggettoProprietario(new IDSoggetto(paAssociata.getTipoSoggettoProprietario(), paAssociata.getNomeSoggettoProprietario()));
  3329.                             idSA.setNome(portaApplicativaServizioApplicativo.getNome());
  3330.                             ServizioApplicativo sa = this.saCore.getServizioApplicativo(idSA);
  3331.                             if(ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(sa.getTipo())) {
  3332.                                 showConnettoreLink = true;
  3333.                                 break;
  3334.                             }
  3335.                         }
  3336.                        
  3337.                     }
  3338.                 }
  3339.             }
  3340.             else {
  3341.                 // se non e' standard lo faccio vedere solo se ho più di un gruppo.
  3342.                 showConnettoreLink = lista!=null && lista.size()>1;
  3343.             }
  3344.            
  3345.             PortaApplicativa paAssociataDefault = null;
  3346.             PortaApplicativaServizioApplicativo portaApplicativaServizioApplicativoDefault = null;
  3347.             if(lista!=null) {
  3348.                 Iterator<MappingErogazionePortaApplicativa> itDef = lista.iterator();
  3349.                 MappingErogazionePortaApplicativa mappingDefault = null;
  3350.                 while (itDef.hasNext()) {
  3351.                     mappingDefault = itDef.next();
  3352.                     if(mappingDefault.isDefault()) {
  3353.                         paAssociataDefault = this.porteApplicativeCore.getPortaApplicativa(mappingDefault.getIdPortaApplicativa());
  3354.                         portaApplicativaServizioApplicativoDefault = paAssociataDefault.getServizioApplicativoList().get(0);
  3355.                         break;
  3356.                     }
  3357.                 }
  3358.             }
  3359.            
  3360.             // setto le label delle colonne
  3361.             List<String> listaLabel = new ArrayList<>();

  3362.             if(visualizzazioneTabs && (gestioneGruppi || listaParam.size()>1)) {
  3363.                 listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_NOME_GRUPPO);
  3364.             }
  3365.             if(gestioneConfigurazioni) {
  3366.                 /**listaLabel.add(PorteApplicativeCostanti.LABEL_COLUMN_PORTE_APPLICATIVE_STATO_PORTA);*/
  3367.                 listaLabel.add("");
  3368.             }
  3369.             if(!visualizzazioneTabs && (gestioneGruppi || listaParam.size()>1)) {
  3370.                 listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_NOME_GRUPPO);
  3371.             }
  3372.             if(gestioneGruppi || visualizzazioneTabs) { // visualizzata sia per i gruppi che per la modalita' tab
  3373.                 if(this.isModalitaCompleta()) {
  3374.                     listaLabel.add(labelAzioni);
  3375.                 }
  3376.                 else {
  3377.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_ELENCO_AZIONI_GRUPPI_PREFIX+labelAzioni);
  3378.                 }
  3379.             }
  3380.             if(gestioneConfigurazioni) {
  3381.                 if(showConnettoreLink) {
  3382.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE);
  3383.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_VERIFICA_CONNETTORE);
  3384.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONFIGURAZIONE_CONNETTORI_MULTIPLI);
  3385.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_ELENCO_CONNETTORI_MULTIPLI);
  3386.                 }
  3387.                
  3388.                 listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONTROLLO_ACCESSI);
  3389.                 listaLabel.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING);
  3390.                 listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_VALIDAZIONE_CONTENUTI);
  3391.                 listaLabel.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RESPONSE_CACHING);
  3392.                 if(visualizzaSicurezza) {
  3393.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY);
  3394.                 }
  3395.                 if(visualizzaMTOM) {
  3396.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MTOM);
  3397.                 }
  3398.                 listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI);
  3399.                 if(visualizzaCorrelazione) {
  3400.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRACCIAMENTO);
  3401.                 }
  3402.                 listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_DUMP_CONFIGURAZIONE);
  3403.                
  3404.                 if(visualizzaAllarmi) {
  3405.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_ALLARMI);
  3406.                 }
  3407.                
  3408.                 if(this.isModalitaAvanzata() || this.apsCore.isProprietaErogazioniShowModalitaStandard()) {
  3409.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_PROTOCOL_PROPERTIES);
  3410.                 }
  3411.                 if(this.isModalitaAvanzata()) {
  3412.                     listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_OPZIONI_AVANZATE);
  3413.                 }
  3414.                 if(extendedServletList!=null && extendedServletList.showExtendedInfo(this, protocollo)){
  3415.                     listaLabel.add(extendedServletList.getListTitle(this));
  3416.                 }
  3417.             }
  3418.             String[] labels = listaLabel.toArray(new String[listaLabel.size()]);
  3419.             this.pd.setLabels(labels);

  3420.             PropertiesSourceConfiguration propertiesSourceConfiguration = null;
  3421.             ConfigManager configManager = null;
  3422.             Configurazione configurazioneGenerale = null;
  3423.             if(visualizzazioneTabs) {
  3424.                 propertiesSourceConfiguration = this.apsCore.getMessageSecurityPropertiesSourceConfiguration();
  3425.                 configManager = ConfigManager.getinstance(ControlStationCore.getLog());
  3426.                 configManager.leggiConfigurazioni(propertiesSourceConfiguration, true);
  3427.                 configurazioneGenerale = this.confCore.getConfigurazioneGenerale();
  3428.             }
  3429.            
  3430.             impostaComandiMenuContestualePA(asps, protocollo, pNomeServizio, pTipoServizio, pIdSoggettoErogatore);
  3431.        
  3432.            
  3433.             // preparo i dati
  3434.             List<List<DataElement>> dati = new ArrayList<>();

  3435.             if(lista!=null) {
  3436.                 Iterator<MappingErogazionePortaApplicativa> it = lista.iterator();
  3437.                 MappingErogazionePortaApplicativa mapping= null;
  3438.                 int idTab = 0;
  3439.                 while (it.hasNext()) {
  3440.                     mapping = it.next();
  3441.                     PortaApplicativa paAssociata = this.porteApplicativeCore.getPortaApplicativa(mapping.getIdPortaApplicativa());
  3442.                    
  3443.                     List<DataElement> e = new ArrayList<>();
  3444.    
  3445.                     Parameter pNomePorta = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_PORTA, paAssociata.getNome());
  3446.                     Parameter pIdNome = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME, paAssociata.getNome());
  3447.                     Parameter pIdSogg = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, paAssociata.getIdSoggetto() + "");
  3448.                     Parameter pIdPorta = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, ""+paAssociata.getId());
  3449.                     Parameter pIdAsps = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, asps.getId()+ "");
  3450.                     Parameter pIdProvider = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_PROVIDER, paAssociata.getIdSoggetto() + "");
  3451.                     Parameter pIdPortaPerSA = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_PORTA, ""+paAssociata.getId());
  3452.                     Parameter pIdTAb = new Parameter(CostantiControlStation.PARAMETRO_ID_TAB, ""+idTab);
  3453.                    
  3454.                     @SuppressWarnings("unused")
  3455.                     Parameter pConfigurazioneDati = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONFIGURAZIONE_DATI_INVOCAZIONE, Costanti.CHECK_BOX_ENABLED_TRUE);
  3456.                     Parameter pConfigurazioneAltroPorta = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONFIGURAZIONE_ALTRO_PORTA, Costanti.CHECK_BOX_ENABLED_TRUE);
  3457.                    
  3458.                     Parameter pConfigurazioneDescrizione = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONFIGURAZIONE_DESCRIZIONE, Costanti.CHECK_BOX_ENABLED_TRUE);
  3459.    
  3460.                     // spostata direttamente nell'elenco delle erogazioni
  3461.     /**             // nome mapping
  3462.     //              DataElement de = new DataElement();
  3463.     //              //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  3464.     //              if(mapping.isDefault()) {
  3465.     //                  de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CHANGE,pIdSogg, pNomePorta, pIdPorta,pIdAsps,pConfigurazioneDati);
  3466.     //              }
  3467.     //              de.setValue(mapping.isDefault() ? PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MAPPING_EROGAZIONE_PA_NOME_DEFAULT : mapping.getNome());
  3468.     //              de.setIdToRemove(paAssociata.getNome());
  3469.     //              //de.setToolTip(StringUtils.isNotEmpty(paAssociata.getDescrizione()) ? paAssociata.getDescrizione() : paAssociata.getNome());
  3470.     //              e.add(de);*/
  3471.                    
  3472.                     if(gestioneConfigurazioni && mapping.isDefault() && allActionRedefined && (!showConnettoreLink)) {
  3473.                         int numEntries = ricerca.getNumEntries(idLista);
  3474.                         ricerca.setNumEntries(idLista, numEntries -1);
  3475.                         this.pd.setNumEntries(numEntries -1);
  3476.                         continue; // non faccio vedere la riga "disconnessa"
  3477.                     }
  3478.                    
  3479.                    
  3480.                     boolean statoPA = paAssociata.getStato().equals(StatoFunzionalita.ABILITATO);
  3481.                     String statoPAallRedefined = null;
  3482.                     String statoMapping = statoPA ? CostantiControlStation.LABEL_PARAMETRO_PORTA_ABILITATO_TOOLTIP : CostantiControlStation.LABEL_PARAMETRO_PORTA_DISABILITATO_TOOLTIP;
  3483.                     boolean urlCambiaStato = true;
  3484.                     if(mapping.isDefault() && allActionRedefined) {
  3485.                         statoPA = false;
  3486.                         statoPAallRedefined = "off";
  3487.                         statoMapping = this.getLabelAllAzioniRidefiniteTooltip(serviceBindingMessage);
  3488.                         urlCambiaStato = false;
  3489.                     }
  3490.                    
  3491.                     boolean descrizioneEmpty = paAssociata.getDescrizione()==null || StringUtils.isEmpty(paAssociata.getDescrizione()) ||
  3492.                             ImplementationConfiguration.isDescriptionDefault(paAssociata.getDescrizione());
  3493.                    

  3494.                     // Nome Gruppo
  3495.                     if(visualizzazioneTabs && (gestioneGruppi || listaParam.size()>1)) {
  3496.                         DataElement de = new DataElement();
  3497.                        
  3498.                         de.setWidthPx(10);
  3499.                         de.setType(DataElementType.CHECKBOX);
  3500.                        
  3501.                         de.setStatusToolTip(statoPA ? CostantiControlStation.LABEL_PARAMETRO_PORTA_ABILITATO_TOOLTIP_NO_ACTION : CostantiControlStation.LABEL_PARAMETRO_PORTA_DISABILITATO_TOOLTIP_NO_ACTION);
  3502.                         if(statoPAallRedefined!=null) {
  3503.                             de.setStatusType(statoPAallRedefined);
  3504.                         }
  3505.                         else {
  3506.                             de.setStatusType(statoPA ? CheckboxStatusType.ABILITATO : CheckboxStatusType.DISABILITATO);
  3507.                         }
  3508.                        
  3509.                         de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_NOME_GRUPPO);
  3510.                         de.setValue(mapping.getDescrizione());
  3511.                         de.setStatusValue(mapping.getDescrizione());
  3512.                        
  3513.                         if(!mapping.isDefault()) {
  3514.                             DataElementImage image = new DataElementImage();
  3515.                            
  3516.                             image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONFIGURAZIONE_CHANGE,pIdSogg, pIdPorta, pIdAsps,pIdTAb);
  3517.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_NOME_GRUPPO));
  3518.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  3519.                            
  3520.                             de.addImage(image );
  3521.                         }
  3522.                         if(!mapping.isDefault())
  3523.                             de.setIdToRemove(paAssociata.getNome());
  3524.                        
  3525.                         if(descrizioneEmpty) {
  3526.                            
  3527.                             DataElementImage image = new DataElementImage();
  3528.                             image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CHANGE,pIdSogg, pNomePorta, pIdPorta,pIdAsps,pConfigurazioneDescrizione,pIdTAb);
  3529.                             image.setToolTip(MessageFormat.format(CostantiControlStation.AGGIUNGI_DESCRIZIONE_TOOLTIP_CON_PARAMETRO, PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_DESCRIZIONE));
  3530.                             image.setImage(CostantiControlStation.ICONA_AGGIUNGI_DESCRIZIONE);
  3531.                            
  3532.                             de.addImage(image);
  3533.                         }
  3534.                        
  3535.                         if(urlCambiaStato) {
  3536.                             Parameter pAbilita = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ABILITA,  (statoPA ? Costanti.CHECK_BOX_DISABLED : Costanti.CHECK_BOX_ENABLED_TRUE));
  3537.                             de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_ABILITAZIONE,pIdSogg, pNomePorta, pIdPorta,pIdAsps, pAbilita);
  3538.                            
  3539.                             DataElementImage image = new DataElementImage();
  3540.                             image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_ABILITAZIONE,pIdSogg, pNomePorta, pIdPorta,pIdAsps, pAbilita,pIdTAb);
  3541.                             image.setToolTip(statoMapping);
  3542.                             image.setImage(statoPA ? CostantiControlStation.ICONA_MODIFICA_TOGGLE_ON : CostantiControlStation.ICONA_MODIFICA_TOGGLE_OFF);
  3543.                            
  3544.                             de.addImage(image);
  3545.                         }
  3546.                        
  3547.                         e.add(de);
  3548.                     }
  3549.                    
  3550.                     if(gestioneConfigurazioni && !visualizzazioneTabs) {
  3551.                        
  3552.                         // Abilitato
  3553.                         DataElement de = new DataElement();
  3554.                         /**if(visualizzazioneTabs)
  3555.                         //  de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_STATO);*/
  3556.                        
  3557.                         de.setWidthPx(10);
  3558.                         de.setType(DataElementType.CHECKBOX);
  3559.                         /**if(visualizzazioneTabs) {
  3560.                         //  de.setStatusValue(statoPA ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO) : this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO));
  3561.                         //  de.setStatusToolTip(statoPA ? CostantiControlStation.LABEL_PARAMETRO_PORTA_ABILITATO_TOOLTIP_NO_ACTION : CostantiControlStation.LABEL_PARAMETRO_PORTA_DISABILITATO_TOOLTIP_NO_ACTION);
  3562.                         //  if(statoPAallRedefined!=null) {
  3563.                         //      de.setStatusType(statoPAallRedefined);
  3564.                         //  }
  3565.                         //  else {
  3566.                         //      de.setStatusType(statoPA ? CheckboxStatusType.ABILITATO : CheckboxStatusType.DISABILITATO);
  3567.                         //  }
  3568.                         //} else {*/
  3569.                         de.setToolTip(statoMapping);
  3570.                        
  3571.                         if(statoPAallRedefined!=null) {
  3572.                             de.setSelected(statoPAallRedefined);
  3573.                         }
  3574.                         else {
  3575.                             de.setSelected(statoPA);
  3576.                         }
  3577.                         if(urlCambiaStato) {
  3578.                             Parameter pAbilita = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ABILITA,  (statoPA ? Costanti.CHECK_BOX_DISABLED : Costanti.CHECK_BOX_ENABLED_TRUE));
  3579.                             de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_ABILITAZIONE,pIdSogg, pNomePorta, pIdPorta,pIdAsps, pAbilita);
  3580.                            
  3581.                             DataElementImage image = new DataElementImage();
  3582.                             image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_ABILITAZIONE,pIdSogg, pNomePorta, pIdPorta,pIdAsps, pAbilita,pIdTAb);
  3583.                             image.setToolTip(statoMapping);
  3584.                             image.setImage(statoPA ? CostantiControlStation.ICONA_MODIFICA_TOGGLE_ON : CostantiControlStation.ICONA_MODIFICA_TOGGLE_OFF);
  3585.                            
  3586.                             de.setImage(image);
  3587.                         }
  3588.                         e.add(de);
  3589.                     }
  3590.                    
  3591.                     // NomeGruppo
  3592.                     if(!visualizzazioneTabs && (gestioneGruppi || listaParam.size()>1)) {
  3593.                                            
  3594.                         DataElement de = new DataElement();
  3595.                         de.setValue(mapping.getDescrizione());
  3596.                         if(gestioneGruppi && !mapping.isDefault()) {
  3597.                             de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONFIGURAZIONE_CHANGE,pIdSogg, pIdPorta, pIdAsps);
  3598.                         }
  3599.                         e.add(de);
  3600.                     }
  3601.                    
  3602.                     // lista delle azioni
  3603.                     if(gestioneGruppi || (visualizzazioneTabs && (listaParam.size()>1 || !mapping.isDefault()))) {  
  3604.                                            
  3605.                         List<String> listaAzioni = null;
  3606.                         String nomiAzioni = null;
  3607.                         long countAzioni = 0;
  3608.                         if(!mapping.isDefault()) {
  3609.                             listaAzioni = paAssociata.getAzione()!= null ?  paAssociata.getAzione().getAzioneDelegataList() : new ArrayList<>();
  3610.                            
  3611.                             if(!listaAzioni.isEmpty() && azioni.size()>0) {
  3612.                                
  3613.                                 StringBuilder sb = new StringBuilder();
  3614.                                 Iterator<String> itAz = azioni.keySet().iterator();
  3615.                                 while (itAz.hasNext()) {
  3616.                                     String idAzione = itAz.next();
  3617.                                     if(listaAzioni.contains(idAzione)) {
  3618.                                         if(sb.length() >0)
  3619.                                             sb.append(", ");
  3620.                                        
  3621.                                         sb.append(azioni.get(idAzione));
  3622.                                         countAzioni++;
  3623.                                     }
  3624.                                 }
  3625.                                 nomiAzioni = sb.toString();
  3626.                                
  3627.                             }
  3628.                         }
  3629.                        
  3630.                         DataElement de = new DataElement();
  3631.                         de.setSize(200);
  3632.                         de.setIdToRemove(paAssociata.getNome());
  3633.                        
  3634.                         if(visualizzazioneTabs) {
  3635.                             de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_ELENCO_AZIONI_GRUPPI_PREFIX+labelAzioni);
  3636.                         }
  3637.                        
  3638.                         if(listaSenzaFiltro.size()>1) {
  3639.                             DataElementImage image = new DataElementImage();
  3640.                            
  3641.                             if(!mapping.isDefault()) {
  3642.                                 de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_AZIONE_LIST,pIdSogg, pIdPorta, pIdAsps);
  3643.                                 if(this.isModalitaCompleta()) {
  3644.                                     ServletUtils.setDataElementVisualizzaLabel(de, countAzioni);
  3645.                                 }
  3646.                                 else {
  3647.                                     de.setValue(nomiAzioni);
  3648.                                 }
  3649.                                 de.setToolTip(nomiAzioni);
  3650.                                
  3651.                                 image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_AZIONE_LIST,pIdSogg, pIdPorta, pIdAsps,pIdTAb);
  3652.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_ELENCO_AZIONI_GRUPPI_PREFIX+labelAzioni));
  3653.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  3654.                                
  3655.                                 de.setImage(image);
  3656.                             }
  3657.                             else {
  3658.                                 if(actionNonRidefinite!=null && !actionNonRidefinite.isEmpty() && azioni.size()>0) {
  3659.                                    
  3660.                                     long countAzioniRidefinite = 0;
  3661.                                     StringBuilder sb = new StringBuilder();
  3662.                                     Iterator<String> itAz = azioni.keySet().iterator();
  3663.                                     while (itAz.hasNext()) {
  3664.                                         String idAzione = itAz.next();
  3665.                                         if(actionNonRidefinite.contains(idAzione)) {
  3666.                                             if(sb.length() >0)
  3667.                                                 sb.append(", ");
  3668.                                            
  3669.                                             sb.append(azioni.get(idAzione));
  3670.                                             countAzioniRidefinite++;
  3671.                                         }
  3672.                                     }
  3673.                                     String nomiAzioniNonRidefinite = sb.toString();
  3674.                                     de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_AZIONE_LIST,pIdSogg, pIdPorta, pIdAsps);
  3675.                                     if(this.isModalitaCompleta()) {
  3676.                                         ServletUtils.setDataElementVisualizzaLabel(de, countAzioniRidefinite);
  3677.                                     }
  3678.                                     else {
  3679.                                         de.setValue(nomiAzioniNonRidefinite);
  3680.                                     }
  3681.                                     de.setToolTip(nomiAzioniNonRidefinite);
  3682.                                    
  3683.                                     image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_AZIONE_LIST,pIdSogg, pIdPorta, pIdAsps,pIdTAb);
  3684.                                     image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_ELENCO_AZIONI_GRUPPI_PREFIX+labelAzioni));
  3685.                                     image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  3686.                                    
  3687.                                     de.setImage(image);
  3688.                                 }
  3689.                                 else {
  3690.                                     if(allActionRedefined) {
  3691.                                         de.setValue(this.getLabelAllAzioniRidefiniteTooltip(serviceBindingMessage));
  3692.                                     }
  3693.                                     else {
  3694.                                         de.setValue("-"); // ??
  3695.                                     }
  3696.                                 }
  3697.                             }
  3698.                         }
  3699.                         else {
  3700.                             if(org.openspcoop2.core.registry.constants.ServiceBinding.SOAP.equals(serviceBinding)) {
  3701.                                 de.setValue(CostantiControlStation.LABEL_TUTTE_AZIONI_DEFAULT);
  3702.                             }
  3703.                             else {
  3704.                                 de.setValue(CostantiControlStation.LABEL_TUTTE_RISORSE_DEFAULT);    
  3705.                             }
  3706.                         }
  3707.                         e.add(de);
  3708.                        
  3709.                     }
  3710.                    
  3711.                     // Descrizione
  3712.                     if(!descrizioneEmpty) {
  3713.                         DataElement de = new DataElement();
  3714.                         if(visualizzazioneTabs)
  3715.                             de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_DESCRIZIONE);
  3716.                         de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CHANGE,pIdSogg, pNomePorta, pIdPorta,pIdAsps,pConfigurazioneDescrizione);
  3717.                        
  3718.                         int length = 150;
  3719.                         String descrizione = paAssociata.getDescrizione();
  3720.                         if(descrizione!=null && descrizione.length()>length) {
  3721.                             descrizione = descrizione.substring(0, (length-4)) + " ...";
  3722.                         }
  3723.                         de.setValue(descrizione!=null ? StringEscapeUtils.escapeHtml(descrizione) : null);
  3724.                         de.setToolTip(paAssociata.getDescrizione());
  3725.                         de.setCopyToClipboard(paAssociata.getDescrizione());
  3726.                        
  3727.                         if(visualizzazioneTabs) {
  3728.                             DataElementImage image = new DataElementImage();
  3729.                            
  3730.                             image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CHANGE,pIdSogg, pNomePorta, pIdPorta,pIdAsps,pConfigurazioneDescrizione,pIdTAb);
  3731.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_DESCRIZIONE));
  3732.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  3733.                            
  3734.                             de.setImage(image);
  3735.                         }
  3736.                         e.add(de);
  3737.                     }
  3738.                    
  3739.                     if(gestioneConfigurazioni) {
  3740.                        
  3741.                         // connettore
  3742.                         if(showConnettoreLink) {
  3743.                            
  3744.                             Parameter paIdSogg = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, asps.getIdSoggetto() + "");
  3745.                            
  3746.                             DataElement de = new DataElement();
  3747.                             //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  3748.                             String servletConnettore = ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT;
  3749.                             PortaApplicativaServizioApplicativo portaApplicativaServizioApplicativo = paAssociata.getServizioApplicativoList().get(0);
  3750.                            
  3751.                             boolean connettoreMultiploEnabled = paAssociata.getBehaviour() != null;
  3752.                            
  3753.                             if(visualizzazioneTabs) {
  3754.                                 if(!connettoreMultiploEnabled)
  3755.                                     de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE);
  3756.                                 else
  3757.                                     de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI);
  3758.                             }
  3759.                            
  3760.                             IDServizioApplicativo idServizioApplicativo = new IDServizioApplicativo();
  3761.                             idServizioApplicativo.setIdSoggettoProprietario(new IDSoggetto(paAssociata.getTipoSoggettoProprietario(), paAssociata.getNomeSoggettoProprietario()));
  3762.                             idServizioApplicativo.setNome(portaApplicativaServizioApplicativo.getNome());
  3763.                             ServizioApplicativo sa = this.saCore.getServizioApplicativo(idServizioApplicativo);
  3764.                             org.openspcoop2.core.config.InvocazioneServizio is = sa.getInvocazioneServizio();
  3765.                             org.openspcoop2.core.config.Connettore connettore = is.getConnettore();
  3766.                            
  3767.                             boolean connettoreMultiploEnabledDefault = false;
  3768.                             if(!mapping.isDefault()) {
  3769.                                 connettoreMultiploEnabledDefault = paAssociataDefault!=null && paAssociataDefault.getBehaviour() != null;
  3770.                             }
  3771.                            
  3772.                            
  3773.                             boolean ridefinito = false;
  3774.                             boolean connettoreRidefinito = false;
  3775.                             boolean visualizzaLinkConfigurazioneConnettore =
  3776.                                     (!this.core.isConnettoriMultipliEnabled())
  3777.                                     ||
  3778.                                     ( !connettoreMultiploEnabled );
  3779.                             if(mapping.isDefault()) {
  3780.                                 if(visualizzazioneTabs) {
  3781.                                     if(!connettoreMultiploEnabled) {                                
  3782.                                         de.setValue(this.getLabelConnettore(sa,is,true));
  3783.                                         String tooltipConnettore = this.getTooltipConnettore(sa,is,true);
  3784.                                         de.setToolTip(tooltipConnettore);
  3785.                                         de.setCopyToClipboard(this.getClipBoardUrlConnettore(sa,is));
  3786.                                     } else {
  3787.                                         de.setValue(this.getNomiConnettoriMultipliPortaApplicativa(paAssociata));
  3788.                                         de.setToolTip(this.getToolTipConnettoriMultipliPortaApplicativa(paAssociata));
  3789.                                     }
  3790.                                 }
  3791.                                 else {
  3792.                                     if(visualizzaLinkConfigurazioneConnettore) {
  3793.                                         ServletUtils.setDataElementVisualizzaLabel(de);
  3794.                                     } else {
  3795.                                         de.setType(DataElementType.TEXT);
  3796.                                         de.setValue("-");
  3797.                                     }
  3798.                                 }
  3799.                                 if(visualizzaLinkConfigurazioneConnettore)
  3800.                                     de.setUrl(servletConnettore, pIdProvider, pIdPortaPerSA, pIdAsps,
  3801.                                         new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_NOME_SERVIZIO_APPLICATIVO, portaApplicativaServizioApplicativo.getNome()),
  3802.                                         new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_SERVIZIO_APPLICATIVO, portaApplicativaServizioApplicativo.getIdServizioApplicativo()+""));
  3803.                                
  3804.                                 if(visualizzazioneTabs &&
  3805.                                     (visualizzaLinkConfigurazioneConnettore)
  3806.                                     ){
  3807.                                     DataElementImage image = new DataElementImage();
  3808.                                     image.setUrl(servletConnettore, pIdProvider, pIdPortaPerSA, pIdAsps,pIdTAb,
  3809.                                             new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_NOME_SERVIZIO_APPLICATIVO, portaApplicativaServizioApplicativo.getNome()),
  3810.                                             new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_SERVIZIO_APPLICATIVO, portaApplicativaServizioApplicativo.getIdServizioApplicativo()+""));
  3811.                                     image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE));
  3812.                                     image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  3813.                                    
  3814.                                     de.addImage(image);
  3815.                                 }
  3816.                                
  3817.                             }else {
  3818.                                 // Connettore e' ridefinito se
  3819.                                 connettoreRidefinito = isConnettoreRidefinito(paAssociataDefault, portaApplicativaServizioApplicativoDefault, paAssociata, portaApplicativaServizioApplicativo, paAssociata.getServizioApplicativoList());
  3820.                                
  3821.                                 if(!connettoreRidefinito) {
  3822.                                     servletConnettore = PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORE_DEFAULT;
  3823.                                     if(visualizzazioneTabs) {                                  
  3824.                                         if(!connettoreMultiploEnabled && !connettoreMultiploEnabledDefault) {  
  3825.                                             de.setValue("["+org.openspcoop2.core.constants.Costanti.MAPPING_EROGAZIONE_PA_DESCRIZIONE_DEFAULT+"] "+this.getLabelConnettore(sa,is,true));
  3826.                                             String tooltipConnettore = this.getTooltipConnettore(sa,is,true);
  3827.                                             de.setToolTip(ConnettoriCostanti.LABEL_PARAMETRO_MODALITA_CONNETTORE_DEFAULT+CostantiControlStation.TOOLTIP_BREAK_LINE+tooltipConnettore);
  3828.                                             de.setCopyToClipboard(this.getClipBoardUrlConnettore(sa,is));
  3829.                                         }
  3830.                                         else if(connettoreMultiploEnabledDefault) {
  3831.                                             /**de.setValue("["+org.openspcoop2.core.constants.Costanti.MAPPING_EROGAZIONE_PA_DESCRIZIONE_DEFAULT+"] "+this.getNomiConnettoriMultipliPortaApplicativa(paAssociataDefault));*/
  3832.                                             de.setValue(this.getNomiConnettoriMultipliPortaApplicativa(paAssociataDefault)); // comunque i connettori vengono ridefiniti internamente, sono proprio istanze differenti, quindi non ha senso la descrizione
  3833.                                             de.setToolTip(this.getToolTipConnettoriMultipliPortaApplicativa(paAssociataDefault));
  3834.                                             /** Ci vuole, devo poter ridefinire il connettore visualizzaLinkConfigurazioneConnettore = false;*/
  3835.                                         }
  3836.                                         else {
  3837.                                             de.setValue(this.getNomiConnettoriMultipliPortaApplicativa(paAssociata));
  3838.                                             de.setToolTip(this.getToolTipConnettoriMultipliPortaApplicativa(paAssociata));
  3839.                                         }
  3840.                                     }
  3841.                                     else {
  3842.                                         if(visualizzaLinkConfigurazioneConnettore) {
  3843.                                             de.setValue(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_DEFAULT);
  3844.                                             String tooltipConnettore = this.getTooltipConnettore(sa, is,true);
  3845.                                             de.setToolTip(ConnettoriCostanti.LABEL_PARAMETRO_MODALITA_CONNETTORE_DEFAULT+CostantiControlStation.TOOLTIP_BREAK_LINE+tooltipConnettore);
  3846.                                             de.setCopyToClipboard(this.getClipBoardUrlConnettore(sa,is));
  3847.                                         } else {
  3848.                                             de.setType(DataElementType.TEXT);
  3849.                                             de.setValue("-");
  3850.                                         }
  3851.                                     }
  3852.                                 } else {
  3853.                                     ridefinito = true;
  3854.                                     servletConnettore = PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORE_RIDEFINITO;
  3855.                                     if(visualizzazioneTabs) {
  3856.                                         if(!connettoreMultiploEnabled) {    
  3857.                                             de.setValue(this.getLabelConnettore(sa,is,true));
  3858.                                             String tooltipConnettore = this.getTooltipConnettore(sa,is,true);
  3859.                                             de.setToolTip(ConnettoriCostanti.LABEL_PARAMETRO_MODALITA_CONNETTORE_RIDEFINITO+CostantiControlStation.TOOLTIP_BREAK_LINE+tooltipConnettore);
  3860.                                             de.setCopyToClipboard(this.getClipBoardUrlConnettore(sa,is));
  3861.                                         } else {
  3862.                                             de.setValue(this.getNomiConnettoriMultipliPortaApplicativa(paAssociata));
  3863.                                             de.setToolTip(this.getToolTipConnettoriMultipliPortaApplicativa(paAssociata));
  3864.                                         }
  3865.                                     }
  3866.                                     else {
  3867.                                         if(visualizzaLinkConfigurazioneConnettore) {
  3868.                                             de.setValue(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_RIDEFINITO);
  3869.                                             String tooltipConnettore = this.getTooltipConnettore(sa, is,true);
  3870.                                             de.setToolTip(ConnettoriCostanti.LABEL_PARAMETRO_MODALITA_CONNETTORE_RIDEFINITO+CostantiControlStation.TOOLTIP_BREAK_LINE+tooltipConnettore);
  3871.                                             de.setCopyToClipboard(this.getClipBoardUrlConnettore(sa,is));
  3872.                                         } else {
  3873.                                             de.setType(DataElementType.TEXT);
  3874.                                             de.setValue("-");
  3875.                                         }
  3876.                                     }
  3877.                                 }
  3878.                                 if(visualizzaLinkConfigurazioneConnettore) {
  3879.     /**                             if(!isPaDefaultMulti) {*/
  3880.                                         de.setUrl(servletConnettore, pIdSogg, pIdPorta, pIdAsps);
  3881.     /**                             }else {
  3882.     //                                  // solo modifica non ridefinizione
  3883.     //                                  de.setUrl(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT, pIdProvider, pIdPortaPerSA, pIdAsps,
  3884.     //                                          new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_NOME_SERVIZIO_APPLICATIVO, portaApplicativaServizioApplicativo.getNome()),
  3885.     //                                          new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_SERVIZIO_APPLICATIVO, portaApplicativaServizioApplicativo.getIdServizioApplicativo()+""));
  3886.     //                              }*/
  3887.                                 }
  3888.                                
  3889.                                 if(visualizzazioneTabs &&
  3890.                                     visualizzaLinkConfigurazioneConnettore) {
  3891.                                     DataElementImage image = new DataElementImage();
  3892. /**                                 if(!isPaDefaultMulti) {*/
  3893.                                         image.setUrl(servletConnettore, pIdSogg, pIdPorta, pIdAsps,pIdTAb);
  3894. /**                                 }else {
  3895. //                                      image.setUrl(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT, pIdProvider, pIdPortaPerSA, pIdAsps,pIdTAb,
  3896. //                                              new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_NOME_SERVIZIO_APPLICATIVO, portaApplicativaServizioApplicativo.getNome()),
  3897. //                                              new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_SERVIZIO_APPLICATIVO, portaApplicativaServizioApplicativo.getIdServizioApplicativo()+""));
  3898. //                                  }*/
  3899.                                    
  3900.                                     image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE));
  3901.                                     image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  3902.                                    
  3903.                                     de.addImage(image);
  3904.                                 }
  3905.                             }
  3906.                            
  3907.                             boolean checkConnettore = org.openspcoop2.pdd.core.connettori.ConnettoreCheck.checkSupported(connettore);
  3908.                             if(checkConnettore &&
  3909.                                 !mapping.isDefault() && !ridefinito) {
  3910.                                 checkConnettore = false;
  3911.                             }
  3912.                            
  3913.                             long idConnettore = connettore.getId();
  3914.                             boolean visualizzaLinkCheckConnettore =
  3915.                                     checkConnettore &&
  3916.                                     (
  3917.                                             (!this.core.isConnettoriMultipliEnabled())
  3918.                                             ||
  3919.                                             ( !connettoreMultiploEnabled )
  3920.                                     );
  3921.                            
  3922.                             Parameter pIdConnettore = new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ID, idConnettore+"");
  3923.                             Parameter pConnettoreAccessoDaGruppi = new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_GRUPPI, "true");
  3924.                             Parameter pConnettoreVerificaRegistro = new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_REGISTRO, "false");
  3925.                             if(visualizzazioneTabs &&
  3926.                                 visualizzaLinkCheckConnettore) {
  3927.                                 DataElementImage image = new DataElementImage();
  3928.                                 image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_VERIFICA_CONNETTORE, paIdSogg, pIdPorta, pIdAsps,pIdTAb,
  3929.                                         pIdConnettore,
  3930.                                         pConnettoreAccessoDaGruppi,
  3931.                                         pConnettoreVerificaRegistro);
  3932.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_VERIFICA_TOOLTIP_CON_PARAMETRO, PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE));
  3933.                                 image.setImage(CostantiControlStation.ICONA_VERIFICA);
  3934.                                
  3935.                                 de.addImage(image);
  3936.                             }
  3937.                            
  3938.                             de.allineaTdAlCentro();
  3939.                             e.add(de);
  3940.                            
  3941.                             if(!visualizzazioneTabs) {
  3942.                                 DataElement deVerificaConnettore = new DataElement();
  3943.                                
  3944.                                 if(visualizzaLinkCheckConnettore) {
  3945.                                     deVerificaConnettore.setValue(CostantiControlStation.LABEL_VERIFICA_CONNETTORE_VALORE_LINK);
  3946.                                     deVerificaConnettore.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_VERIFICA_CONNETTORE, paIdSogg, pIdPorta, pIdAsps,
  3947.                                             pIdConnettore,
  3948.                                             pConnettoreAccessoDaGruppi,
  3949.                                             pConnettoreVerificaRegistro);
  3950.                                 }
  3951.                                 else {
  3952.                                     deVerificaConnettore.setValue("-");
  3953.                                 }
  3954.                                 deVerificaConnettore.allineaTdAlCentro();
  3955.                                 e.add(deVerificaConnettore);
  3956.                             }
  3957.                            
  3958.                            
  3959.                             // configurazione connettori multipli
  3960.                             if(visualizzazioneTabs) {
  3961.                                 if(this.core.isConnettoriMultipliEnabled() && (connettoreRidefinito || mapping.isDefault())) {
  3962.                                     List<Parameter> listParametersConfigutazioneConnettoriMultipli = new ArrayList<>();
  3963.                                     listParametersConfigutazioneConnettoriMultipli.add(paIdSogg);
  3964.                                     listParametersConfigutazioneConnettoriMultipli.add(pIdPorta);
  3965.                                     listParametersConfigutazioneConnettoriMultipli.add(pIdAsps);
  3966.                                     listParametersConfigutazioneConnettoriMultipli.add(pIdTAb);
  3967.                                     listParametersConfigutazioneConnettoriMultipli.add(pConnettoreAccessoDaGruppi);
  3968.                                     listParametersConfigutazioneConnettoriMultipli.add(pConnettoreVerificaRegistro);
  3969.                                     listParametersConfigutazioneConnettoriMultipli.add(new Parameter(CostantiControlStation.PARAMETRO_ID_CONN_TAB, "0"));
  3970.                                    
  3971.                                     DataElementImage image = new DataElementImage();
  3972.                                     image.setToolTip(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_CONFIGURAZIONE_CONNETTORI_MULTIPLI_TOOLTIP);
  3973.                                     image.setImage(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_CONFIGURAZIONE_CONNETTORI_MULTIPLI);
  3974.                                     image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONFIGURAZIONE_CONNETTORI_MULTIPLI,
  3975.                                             listParametersConfigutazioneConnettoriMultipli.toArray(new Parameter[1]));
  3976.                                     de.addImage(image);
  3977.                                 }
  3978.                             } else {
  3979.                                 DataElement deConfiguraConnettoriMultipli = new DataElement();
  3980.                                
  3981.                                 if(this.core.isConnettoriMultipliEnabled() && (connettoreRidefinito || mapping.isDefault())) {
  3982.                                     deConfiguraConnettoriMultipli.setValue(this.getStatoConnettoriMultipliPortaApplicativa(paAssociata));
  3983.                                     deConfiguraConnettoriMultipli.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONFIGURAZIONE_CONNETTORI_MULTIPLI, paIdSogg, pIdPorta, pIdAsps,
  3984.                                             pConnettoreAccessoDaGruppi,
  3985.                                             pConnettoreVerificaRegistro,new Parameter(CostantiControlStation.PARAMETRO_ID_CONN_TAB, "0"));
  3986.                                 } else {
  3987.                                     deConfiguraConnettoriMultipli.setValue("-");
  3988.                                 }
  3989.                                
  3990.                                 deConfiguraConnettoriMultipli.allineaTdAlCentro();
  3991.                                 e.add(deConfiguraConnettoriMultipli);
  3992.                             }
  3993.                            
  3994.                            
  3995.                             // lista connettori multipli
  3996.                             if(visualizzazioneTabs) {
  3997.                                 if(this.core.isConnettoriMultipliEnabled() && connettoreMultiploEnabled) {
  3998.                                     List<Parameter> listParametersConfigutazioneConnettoriMultipli = new ArrayList<>();
  3999.                                     listParametersConfigutazioneConnettoriMultipli.add(paIdSogg);
  4000.                                     listParametersConfigutazioneConnettoriMultipli.add(pIdPorta);
  4001.                                     listParametersConfigutazioneConnettoriMultipli.add(pIdAsps);
  4002.                                     listParametersConfigutazioneConnettoriMultipli.add(pIdTAb);
  4003.                                     listParametersConfigutazioneConnettoriMultipli.add(pConnettoreAccessoDaGruppi);
  4004.                                     listParametersConfigutazioneConnettoriMultipli.add(pConnettoreVerificaRegistro);
  4005.                                    
  4006.                                     DataElementImage image = new DataElementImage();
  4007.                                     image.setToolTip(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_ELENCO_CONNETTORI_MULTIPLI_TOOLTIP);
  4008.                                     image.setImage(ErogazioniCostanti.ASPS_EROGAZIONI_ICONA_ELENCO_CONNETTORI_MULTIPLI);
  4009.                                     image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_LIST,
  4010.                                             listParametersConfigutazioneConnettoriMultipli.toArray(new Parameter[1]));
  4011.                                     de.addImage(image);
  4012.                                 }
  4013.                             } else {
  4014.                                 DataElement deListaConnettoriMultipli = new DataElement();
  4015.                                
  4016.                                 if(this.core.isConnettoriMultipliEnabled() && connettoreMultiploEnabled) {
  4017.                                     if(contaListe)
  4018.                                         ServletUtils.setDataElementVisualizzaLabel(deListaConnettoriMultipli, (long) paAssociata.sizeServizioApplicativoList());
  4019.                                     else
  4020.                                         ServletUtils.setDataElementVisualizzaLabel(deListaConnettoriMultipli);
  4021.                                     deListaConnettoriMultipli.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_LIST, paIdSogg, pIdPorta, pIdAsps,
  4022.                                             pConnettoreAccessoDaGruppi,
  4023.                                             pConnettoreVerificaRegistro);
  4024.                                 } else {
  4025.                                     deListaConnettoriMultipli.setValue("-");
  4026.                                 }
  4027.                                
  4028.                                 deListaConnettoriMultipli.allineaTdAlCentro();
  4029.                                 e.add(deListaConnettoriMultipli);
  4030.                             }
  4031.                            
  4032.                         }
  4033.                          
  4034.                         // controllo accessi
  4035.                         DataElement de = new DataElement();
  4036.                         if(visualizzazioneTabs)
  4037.                             de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONTROLLO_ACCESSI);
  4038.                         //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  4039.                         de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONTROLLO_ACCESSI, pIdSogg, pIdPorta, pIdAsps);
  4040.                         if(visualizzazioneTabs) {
  4041.                             this.setStatoControlloAccessiPortaApplicativa(protocollo, paAssociata, de);
  4042.                         }
  4043.                         else {
  4044.                             String statoControlloAccessi = getStatoControlloAccessiPortaApplicativa(protocollo, paAssociata);
  4045.                             de.setValue(statoControlloAccessi);
  4046.                         }
  4047.                         de.allineaTdAlCentro();
  4048.                         if(visualizzazioneTabs) {
  4049.                             DataElementImage image = new DataElementImage();
  4050.                            
  4051.                             image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONTROLLO_ACCESSI, pIdSogg, pIdPorta, pIdAsps,pIdTAb);
  4052.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONTROLLO_ACCESSI));
  4053.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4054.                            
  4055.                             de.setImage(image);
  4056.                         }
  4057.                         e.add(de);
  4058.                                            
  4059.                         // RateLimiting
  4060.                         de = new DataElement();
  4061.                         if(visualizzazioneTabs)
  4062.                             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING);
  4063.                        
  4064.                         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_LIST+"?"+
  4065.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_RUOLO_PORTA+"="+RuoloPolicy.APPLICATIVA.getValue()+"&"+
  4066.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_NOME_PORTA+"="+paAssociata.getNome()+"&"+
  4067.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_SERVICE_BINDING+"="+serviceBindingMessage.name()
  4068.                                 );
  4069.                         List<AttivazionePolicy> listaPolicy = null;
  4070.                         if(contaListe || visualizzazioneTabs) {
  4071.                             ConsoleSearch searchPolicy = new ConsoleSearch(true);
  4072.                             listaPolicy = this.confCore.attivazionePolicyList(searchPolicy, RuoloPolicy.APPLICATIVA, paAssociata.getNome());
  4073.                         }
  4074.                         if(visualizzazioneTabs) {
  4075.                             this.setStatoRateLimiting(de, listaPolicy);
  4076.                         }
  4077.                         else {
  4078.                             if(contaListe) {
  4079.                                 ServletUtils.setDataElementVisualizzaLabel(de, (long) listaPolicy.size() );
  4080.                             }
  4081.                             else {
  4082.                                 ServletUtils.setDataElementVisualizzaLabel(de);
  4083.                             }
  4084.                         }
  4085.                         de.allineaTdAlCentro();
  4086.                         if(visualizzazioneTabs) {
  4087.                             DataElementImage image = new DataElementImage();
  4088.                            
  4089.                             image.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_LIST,
  4090.                                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_RUOLO_PORTA,RuoloPolicy.APPLICATIVA.getValue()),
  4091.                                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_NOME_PORTA,paAssociata.getNome()),
  4092.                                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_SERVICE_BINDING,serviceBindingMessage.name()),
  4093.                                     pIdTAb
  4094.                                     );
  4095.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING));
  4096.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4097.                            
  4098.                             de.setImage(image);
  4099.                         }
  4100.                         e.add(de);
  4101.                        
  4102.                         // validazione contenuti
  4103.                         de = new DataElement();
  4104.                         if(visualizzazioneTabs)
  4105.                             de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_VALIDAZIONE_CONTENUTI);
  4106.                         //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  4107.                         de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_VALIDAZIONE_CONTENUTI, pIdSogg, pIdPorta, pIdAsps);
  4108.                         if(visualizzazioneTabs) {
  4109.                             setStatoValidazioneContenuti(de, paAssociata.getValidazioneContenutiApplicativi(), apc.getFormatoSpecifica());
  4110.                         }
  4111.                         else {
  4112.                             String statoValidazione = getStatoValidazionePortaApplicativa(paAssociata);
  4113.                             de.setValue(statoValidazione);
  4114.                         }
  4115.                         de.allineaTdAlCentro();
  4116.                         if(visualizzazioneTabs) {
  4117.                             DataElementImage image = new DataElementImage();
  4118.                            
  4119.                             image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_VALIDAZIONE_CONTENUTI, pIdSogg, pIdPorta, pIdAsps,pIdTAb);
  4120.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_VALIDAZIONE_CONTENUTI));
  4121.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4122.                            
  4123.                            
  4124.                             de.setImage(image);
  4125.                         }
  4126.                         e.add(de);
  4127.                        
  4128.                         // Response Caching
  4129.                         de = new DataElement();
  4130.                         if(visualizzazioneTabs)
  4131.                             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RESPONSE_CACHING);
  4132.                         //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  4133.                         de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_RESPONSE_CACHING, pIdSogg, pIdPorta, pIdAsps);
  4134.                         if(visualizzazioneTabs) {
  4135.                             setStatoCachingRisposta(de, paAssociata.getResponseCaching(), configurazioneGenerale);
  4136.                         }
  4137.                         else {
  4138.                             String statoResponseCaching = getStatoResponseCachingPortaApplicativa(paAssociata, false);
  4139.                             de.setValue(statoResponseCaching);
  4140.                         }
  4141.                         de.allineaTdAlCentro();
  4142.                         if(visualizzazioneTabs) {
  4143.                             DataElementImage image = new DataElementImage();
  4144.                            
  4145.                             image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_RESPONSE_CACHING, pIdSogg, pIdPorta, pIdAsps,pIdTAb);
  4146.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RESPONSE_CACHING));
  4147.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4148.                            
  4149.                            
  4150.                             de.setImage(image);
  4151.                         }
  4152.                         e.add(de);
  4153.                        
  4154.                         // message security
  4155.                         if(visualizzaSicurezza) {
  4156.                             de = new DataElement();
  4157.                             if(visualizzazioneTabs)
  4158.                                 de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY);
  4159.                             //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  4160.                             de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_MESSAGE_SECURITY, pIdSogg, pIdPorta, pIdAsps);
  4161.                             if(visualizzazioneTabs) {
  4162.                                 setStatoSicurezzaMessaggio(de, paAssociata.getMessageSecurity(), configManager, propertiesSourceConfiguration);
  4163.                             }
  4164.                             else {
  4165.                                 String statoMessageSecurity = getStatoMessageSecurityPortaApplicativa(paAssociata);
  4166.                                 de.setValue(statoMessageSecurity);
  4167.                             }
  4168.                             de.allineaTdAlCentro();
  4169.                             if(visualizzazioneTabs) {
  4170.                                 DataElementImage image = new DataElementImage();
  4171.                                
  4172.                                 image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_MESSAGE_SECURITY, pIdSogg, pIdPorta, pIdAsps,pIdTAb);
  4173.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY));
  4174.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4175.                                
  4176.                                 de.setImage(image);
  4177.                             }
  4178.                             e.add(de);
  4179.                         }
  4180.                        
  4181.                         //mtom
  4182.                         if(visualizzaMTOM) {
  4183.                             de = new DataElement();
  4184.                             if(visualizzazioneTabs)
  4185.                                 de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MTOM);
  4186.                             de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_MTOM,pIdPorta, pIdSogg, pIdAsps);
  4187.                             if(visualizzazioneTabs) {
  4188.                                 setStatoMTOM(de, paAssociata.getMtomProcessor());
  4189.                             }
  4190.                             else {
  4191.                                 String statoMTOM = getStatoMTOMPortaApplicativa(paAssociata);
  4192.                                 de.setValue(statoMTOM);
  4193.                             }
  4194.                             de.allineaTdAlCentro();
  4195.                             if(visualizzazioneTabs) {
  4196.                                 DataElementImage image = new DataElementImage();
  4197.                                
  4198.                                 image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_MTOM,pIdPorta, pIdSogg, pIdAsps,pIdTAb);
  4199.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MTOM));
  4200.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4201.                                
  4202.                                
  4203.                                 de.setImage(image);
  4204.                             }
  4205.                             e.add(de);
  4206.                         }
  4207.                        
  4208.                         // trasformazioni
  4209.                         de = new DataElement();
  4210.                         if(visualizzazioneTabs)
  4211.                             de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI);
  4212.                         //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  4213.                         de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_LIST, pIdSogg, pIdPorta, pIdAsps);
  4214.                         if(visualizzazioneTabs) {
  4215.                             setStatoTrasformazioni(de, paAssociata.getTrasformazioni(), serviceBindingMessage);
  4216.                         }
  4217.                         else {
  4218.                             if(contaListe) {
  4219.                                 long size = 0;
  4220.                                 if(paAssociata.getTrasformazioni()!=null) {
  4221.                                     size = paAssociata.getTrasformazioni().sizeRegolaList();
  4222.                                 }
  4223.                                 ServletUtils.setDataElementVisualizzaLabel(de, size);
  4224.                             }
  4225.                             else {
  4226.                                 ServletUtils.setDataElementVisualizzaLabel(de);
  4227.                             }  
  4228.                         }
  4229.                         de.allineaTdAlCentro();
  4230.                         if(visualizzazioneTabs) {
  4231.                             DataElementImage image = new DataElementImage();
  4232.                            
  4233.                             image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_LIST, pIdSogg, pIdPorta, pIdAsps,pIdTAb);
  4234.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI));
  4235.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4236.                            
  4237.                             de.setImage(image);
  4238.                         }
  4239.                         e.add(de);
  4240.                        
  4241.                         // correlazione applicativa
  4242.                         if(visualizzaCorrelazione) {
  4243.                             de = new DataElement();
  4244.                             if(visualizzazioneTabs)
  4245.                                 de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRACCIAMENTO);
  4246.                             de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CORRELAZIONE_APPLICATIVA, pIdSogg, pIdPorta, pIdNome,pIdAsps);
  4247.                             if(visualizzazioneTabs) {
  4248.                                 setStatoTracciamento(de, paAssociata.getCorrelazioneApplicativa(),
  4249.                                         paAssociata.getCorrelazioneApplicativaRisposta(),
  4250.                                         paAssociata.getTracciamento(),
  4251.                                         (configurazioneGenerale!=null && configurazioneGenerale.getTracciamento()!=null) ? configurazioneGenerale.getTracciamento().getPortaApplicativa() : null,
  4252.                                         paAssociata.getProprieta(),
  4253.                                         configurazioneGenerale);    
  4254.                             }
  4255.                             else {
  4256.                                 String statoTracciamento = getStatoTracciamentoPortaApplicativa(paAssociata);
  4257.                                 de.setValue(statoTracciamento);
  4258.                             }
  4259.                             de.allineaTdAlCentro();
  4260.                             if(visualizzazioneTabs) {
  4261.                                 DataElementImage image = new DataElementImage();
  4262.                                
  4263.                                 image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CORRELAZIONE_APPLICATIVA, pIdSogg, pIdPorta, pIdNome,pIdAsps,pIdTAb);
  4264.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRACCIAMENTO));
  4265.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4266.                                
  4267.                                 de.setImage(image);
  4268.                             }
  4269.                             e.add(de);
  4270.                         }
  4271.                        
  4272.                         // dump
  4273.                         de = new DataElement();
  4274.                         if(visualizzazioneTabs)
  4275.                             de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_DUMP_CONFIGURAZIONE);
  4276.                         //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  4277.                         de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_DUMP_CONFIGURAZIONE, pIdSogg, pIdPorta, pIdAsps);
  4278.                         if(visualizzazioneTabs) {
  4279.                             setStatoDump(de, paAssociata.getDump(), configurazioneGenerale, true);
  4280.                         }
  4281.                         else {
  4282.                             String statoDump = getStatoDumpPortaApplicativa(paAssociata,false);
  4283.                             de.setValue(statoDump);
  4284.                         }
  4285.                         de.allineaTdAlCentro();
  4286.                         if(visualizzazioneTabs) {
  4287.                             DataElementImage image = new DataElementImage();
  4288.                            
  4289.                             image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_DUMP_CONFIGURAZIONE, pIdSogg, pIdPorta, pIdAsps,pIdTAb);
  4290.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_DUMP_CONFIGURAZIONE));
  4291.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4292.                            
  4293.                             de.setImage(image);
  4294.                         }
  4295.                         e.add(de);
  4296.                        
  4297.                         // Allarmi
  4298.                         if(visualizzaAllarmi) {
  4299.                             de = new DataElement();
  4300.                             if(visualizzazioneTabs)
  4301.                                 de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI);
  4302.                            
  4303.                             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_LIST+"?"+
  4304.                                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA+"="+RuoloPorta.APPLICATIVA.getValue()+"&"+
  4305.                                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA+"="+paAssociata.getNome()+"&"+
  4306.                                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING+"="+serviceBindingMessage.name()
  4307.                                     );
  4308.                             List<ConfigurazioneAllarmeBean> listaAllarmi = null;
  4309.                             if(contaListe || visualizzazioneTabs) {
  4310.                                 ConsoleSearch searchPolicy = new ConsoleSearch(true);
  4311.                                 listaAllarmi = this.confCore.allarmiList(searchPolicy, RuoloPorta.APPLICATIVA, paAssociata.getNome());
  4312.                             }
  4313.                             if(visualizzazioneTabs) {
  4314.                                 this.setStatoAllarmi(de, listaAllarmi);
  4315.                             }
  4316.                             else {
  4317.                                 if(contaListe) {
  4318.                                     ServletUtils.setDataElementVisualizzaLabel(de, (long) listaAllarmi.size() );
  4319.                                 }
  4320.                                 else {
  4321.                                     ServletUtils.setDataElementVisualizzaLabel(de);
  4322.                                 }
  4323.                             }
  4324.                             de.allineaTdAlCentro();
  4325.                             if(visualizzazioneTabs) {
  4326.                                 DataElementImage image = new DataElementImage();
  4327.                                
  4328.                                 image.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_LIST,
  4329.                                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA,RuoloPorta.APPLICATIVA.getValue()),
  4330.                                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA,paAssociata.getNome()),
  4331.                                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING,serviceBindingMessage.name()),
  4332.                                         pIdTAb
  4333.                                         );
  4334.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI));
  4335.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4336.                                
  4337.                                 de.setImage(image);
  4338.                             }
  4339.                             e.add(de);
  4340.                         }
  4341.                        
  4342.                         // Protocol Properties
  4343.                         if(this.isModalitaAvanzata() || this.apsCore.isProprietaErogazioniShowModalitaStandard()) {
  4344.                             de = new DataElement();
  4345.                             if(visualizzazioneTabs)
  4346.                                 de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_PROTOCOL_PROPERTIES);
  4347.                             //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  4348.                             de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_PROPRIETA_PROTOCOLLO_LIST, pIdSogg, pIdPorta,pIdAsps);
  4349.                             if(visualizzazioneTabs) {
  4350.                                 setStatoProprieta(de, paAssociata.sizeProprietaList());
  4351.                             }
  4352.                             else {
  4353.                                 if (contaListe) {
  4354.                                     int numProp = paAssociata.sizeProprietaList();
  4355.                                     ServletUtils.setDataElementVisualizzaLabel(de, (long) numProp );
  4356.                                 } else
  4357.                                     ServletUtils.setDataElementVisualizzaLabel(de);
  4358.                             }
  4359.                             de.allineaTdAlCentro();
  4360.                             if(visualizzazioneTabs) {
  4361.                                 DataElementImage image = new DataElementImage();
  4362.                                
  4363.                                 image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_PROPRIETA_PROTOCOLLO_LIST, pIdSogg, pIdPorta,pIdAsps,pIdTAb);
  4364.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_PROTOCOL_PROPERTIES));
  4365.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4366.                                
  4367.                                 de.setImage(image);
  4368.                             }
  4369.                             e.add(de);
  4370.                         }
  4371.        
  4372.                         // Altro
  4373.                         if(this.isModalitaAvanzata()){
  4374.                             de = new DataElement();
  4375.                             if(visualizzazioneTabs)
  4376.                                 de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_OPZIONI_AVANZATE);
  4377.                             de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CHANGE,pIdSogg, pNomePorta, pIdPorta,pIdAsps,pConfigurazioneAltroPorta);
  4378.                             if(visualizzazioneTabs) {
  4379.                                 String behaviour = (!this.core.isConnettoriMultipliEnabled() && paAssociata.getBehaviour()!=null) ? paAssociata.getBehaviour().getNome() : null;
  4380.                                 setStatoOpzioniAvanzate(de,
  4381.                                         protocollo, serviceBindingMessage,
  4382.                                         paAssociata.getAllegaBody(), paAssociata.getScartaBody(),
  4383.                                         paAssociata.getIntegrazione(), behaviour,
  4384.                                         paAssociata.getProprietaRateLimitingList(),
  4385.                                         paAssociata.getStateless(), null,
  4386.                                         paAssociata.getRicevutaAsincronaSimmetrica(), paAssociata.getRicevutaAsincronaAsimmetrica(),
  4387.                                         paAssociata.getGestioneManifest(), paAssociata.getConfigurazioneHandler());
  4388.                             }
  4389.                             else {
  4390.                                 ServletUtils.setDataElementVisualizzaLabel(de);
  4391.                             }
  4392.                             de.allineaTdAlCentro();
  4393.                             if(visualizzazioneTabs) {
  4394.                                 DataElementImage image = new DataElementImage();
  4395.                                
  4396.                                 image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CHANGE,pIdSogg, pNomePorta, pIdPorta,pIdAsps,pConfigurazioneAltroPorta,pIdTAb);
  4397.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_OPZIONI_AVANZATE));
  4398.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4399.                                
  4400.                                 de.setImage(image);
  4401.                             }
  4402.                             e.add(de);
  4403.                         }
  4404.                        
  4405.                         // Extended Servlet List
  4406.                         if(extendedServletList!=null && extendedServletList.showExtendedInfo(this, protocollo)){
  4407.                             de = new DataElement();
  4408.                             if(visualizzazioneTabs)
  4409.                                 de.setLabel(extendedServletList.getListTitle(this));
  4410.                             de.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_EXTENDED_LIST, pIdPorta,pIdNome,pIdPorta, pIdSogg, pNomePorta, pIdAsps, pConfigurazioneAltroPorta);
  4411.                             if(visualizzazioneTabs) {
  4412.                                 int numExtended = extendedServletList.sizeList(paAssociata);
  4413.                                 String stato = extendedServletList.getStatoTab(this,paAssociata,mapping.isDefault());
  4414.                                 String statoTooltip = extendedServletList.getStatoTab(this,paAssociata,mapping.isDefault());
  4415.                                 setStatoExtendedList(de, numExtended, stato, statoTooltip);
  4416.                             }
  4417.                             else {
  4418.                                 if (contaListe) {
  4419.                                     int numExtended = extendedServletList.sizeList(paAssociata);
  4420.                                     ServletUtils.setDataElementVisualizzaLabel(de,Long.valueOf(numExtended));
  4421.                                 } else
  4422.                                     ServletUtils.setDataElementVisualizzaLabel(de);
  4423.                             }
  4424.                             de.allineaTdAlCentro();
  4425.                             if(visualizzazioneTabs) {
  4426.                                 DataElementImage image = new DataElementImage();
  4427.                                
  4428.                                 image.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_EXTENDED_LIST, pIdPorta,pIdNome,pIdPorta, pIdSogg, pNomePorta, pIdAsps, pConfigurazioneAltroPorta,pIdTAb);
  4429.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,extendedServletList.getListTitle(this)));
  4430.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  4431.                                
  4432.                                 de.setImage(image);
  4433.                             }
  4434.                             e.add(de);
  4435.                         }
  4436.                        
  4437.                         if(visualizzazioneTabs) {
  4438.                             // Proprieta Oggetto
  4439.                             this.addProprietaOggetto(e, paAssociata.getProprietaOggetto());
  4440.                         }
  4441.                     }
  4442.                    
  4443.                     dati.add(e);
  4444.                     idTab ++;
  4445.                 }
  4446.             }

  4447.             this.pd.setDati(dati);
  4448.             if(visualizzazioneTabs) {
  4449.                 this.pd.setSelect(true);
  4450.                 if(showBottoneAggiungiNuovaConfigurazione) {
  4451.                     this.pd.setAddButton(true);
  4452.                 }
  4453.                 else {
  4454.                     this.pd.setAddButton(false);
  4455.                 }
  4456.                 if(lista.size() > 1)
  4457.                     this.pd.setRemoveButton(true);
  4458.                 else
  4459.                     this.pd.setRemoveButton(false);
  4460.             } else {
  4461.                 if(gestioneGruppi) {
  4462.                     if(listaSenzaFiltro!=null && listaSenzaFiltro.size()>1) {
  4463.                         this.pd.setRemoveButton(true);
  4464.                         this.pd.setSelect(true);
  4465.                     }
  4466.                     else {
  4467.                         this.pd.setRemoveButton(false);
  4468.                         this.pd.setSelect(false);
  4469.                     }
  4470.                     this.pd.setAddButton(true);
  4471.                 }
  4472.                 else {
  4473.                     this.pd.setAddButton(false);
  4474.                     this.pd.setRemoveButton(false);
  4475.                     this.pd.setSelect(false);
  4476.                 }
  4477.             }
  4478.         } catch (Exception e) {
  4479.             this.logError("Exception: " + e.getMessage(), e);
  4480.             throw new Exception(e);
  4481.         }
  4482.     }
  4483.    
  4484.     private MappingErogazionePortaApplicativa getFiltroAzioneMappingErogazione(String filtroAzione, List<MappingErogazionePortaApplicativa> lista) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  4485.         if(StringUtils.isNotEmpty(filtroAzione) && !filtroAzione.equals(CostantiControlStation.DEFAULT_VALUE_AZIONE_RISORSA_NON_SELEZIONATA)) {
  4486.             MappingErogazionePortaApplicativa mappingTmp = null;
  4487.            
  4488.             for (MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa : lista) {
  4489.                 PortaApplicativa paAssociata = this.porteApplicativeCore.getPortaApplicativa(mappingErogazionePortaApplicativa.getIdPortaApplicativa());
  4490.                 if(paAssociata.getAzione() != null && paAssociata.getAzione().getAzioneDelegataList().contains(filtroAzione)) {
  4491.                     mappingTmp = mappingErogazionePortaApplicativa;
  4492.                     break;
  4493.                 }
  4494.             }
  4495.             if(mappingTmp == null) {
  4496.                 for (MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa : lista) {
  4497.                     if(mappingErogazionePortaApplicativa.isDefault()) {
  4498.                         mappingTmp = mappingErogazionePortaApplicativa;
  4499.                         break;
  4500.                     }
  4501.                 }
  4502.             }
  4503.             return mappingTmp;
  4504.         }
  4505.         else {
  4506.             return null;
  4507.         }
  4508.     }
  4509.    
  4510.     private List<MappingErogazionePortaApplicativa> impostaFiltroAzioneMappingErogazione(String filtroAzione, List<MappingErogazionePortaApplicativa> lista,
  4511.             ISearch ricerca, int idLista) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  4512.        
  4513.         MappingErogazionePortaApplicativa mapping = getFiltroAzioneMappingErogazione(filtroAzione, lista);
  4514.         if(mapping!=null) {
  4515.             List<MappingErogazionePortaApplicativa> newList = new ArrayList<>();
  4516.             newList.add(mapping);
  4517.             this.pd.setNumEntries(1);
  4518.             return newList;
  4519.         }
  4520.         else {
  4521.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  4522.             return lista;
  4523.         }
  4524.     }
  4525.    
  4526.     public boolean allActionsRedefinedMappingErogazionePaAssociate(List<String> azioni, List<PortaApplicativa> lista) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  4527.         // verifico se tutte le azioni sono definite in regole specifiche
  4528.         boolean all = true;
  4529.         if(azioni!=null && azioni.size()>0) {
  4530.             for (String azione : azioni) {
  4531.                 if(lista==null || lista.size()<=0) {
  4532.                     all  = false;
  4533.                     break;
  4534.                 }
  4535.                 boolean found = false;
  4536.                 for (PortaApplicativa paAssociata : lista) {
  4537.                     if(paAssociata.getAzione() != null && paAssociata.getAzione().getAzioneDelegataList().contains(azione)) {
  4538.                         found = true;
  4539.                         break;
  4540.                     }
  4541.                 }
  4542.                 if(!found) {
  4543.                     all  = false;
  4544.                     break;
  4545.                 }
  4546.             }
  4547.         }
  4548.         return all;
  4549.     }
  4550.    
  4551.     private MappingFruizionePortaDelegata getFiltroAzioneMappingFruizione(String filtroAzione, List<MappingFruizionePortaDelegata> lista) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  4552.         if(StringUtils.isNotEmpty(filtroAzione) && !filtroAzione.equals(CostantiControlStation.DEFAULT_VALUE_AZIONE_RISORSA_NON_SELEZIONATA)) {
  4553.             MappingFruizionePortaDelegata mappingTmp = null;
  4554.            
  4555.             for (MappingFruizionePortaDelegata mappingFruizionePortaDelegata : lista) {
  4556.                 PortaDelegata pdAssociata = this.porteDelegateCore.getPortaDelegata(mappingFruizionePortaDelegata.getIdPortaDelegata());
  4557.                 if(pdAssociata.getAzione() != null && pdAssociata.getAzione().getAzioneDelegataList().contains(filtroAzione)) {
  4558.                     mappingTmp = mappingFruizionePortaDelegata;
  4559.                     break;
  4560.                 }
  4561.             }
  4562.             if(mappingTmp == null) {
  4563.                 for (MappingFruizionePortaDelegata mappingFruizionePortaDelegata : lista) {
  4564.                     if(mappingFruizionePortaDelegata.isDefault()) {
  4565.                         mappingTmp = mappingFruizionePortaDelegata;
  4566.                         break;
  4567.                     }
  4568.                 }
  4569.             }
  4570.             return mappingTmp;
  4571.         }
  4572.         else {
  4573.             return null;
  4574.         }
  4575.     }
  4576.     private List<MappingFruizionePortaDelegata> impostaFiltroAzioneMappingFruizione(String filtroAzione, List<MappingFruizionePortaDelegata> lista,
  4577.             ISearch ricerca, int idLista) throws DriverConfigurazioneNotFound, DriverConfigurazioneException {
  4578.         MappingFruizionePortaDelegata mappingTmp = this.getFiltroAzioneMappingFruizione(filtroAzione, lista);  
  4579.         if(mappingTmp!=null) {
  4580.             List<MappingFruizionePortaDelegata> newList = new ArrayList<>();
  4581.             newList.add(mappingTmp);
  4582.             this.pd.setNumEntries(1);
  4583.             return newList;
  4584.         } else {
  4585.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));
  4586.             return lista;
  4587.         }
  4588.     }
  4589.    
  4590.     public List<String> getAllActionsNotRedefinedMappingFruizione(List<String> azioni, List<MappingFruizionePortaDelegata> lista) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  4591.         // verifico se tutte le azioni sono definite in regole specifiche
  4592.         List<String> l = new ArrayList<>();
  4593.         if(lista==null || lista.size()<=0) {
  4594.             return azioni;
  4595.         }
  4596.         l.addAll(azioni);
  4597.         for (MappingFruizionePortaDelegata mappingFruizionePortaDelegata : lista) {
  4598.             PortaDelegata pdAssociata = this.porteDelegateCore.getPortaDelegata(mappingFruizionePortaDelegata.getIdPortaDelegata());
  4599.             if(pdAssociata.getAzione() != null && !pdAssociata.getAzione().getAzioneDelegataList().isEmpty()) {
  4600.                 for (String azPA : pdAssociata.getAzione().getAzioneDelegataList()) {
  4601.                     l.remove(azPA);
  4602.                 }
  4603.             }
  4604.         }
  4605.         return l;
  4606.     }
  4607.    
  4608.     public boolean allActionsRedefinedMappingFruizione(List<String> azioni, List<MappingFruizionePortaDelegata> lista) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  4609.         // verifico se tutte le azioni sono definite in regole specifiche
  4610.         boolean all = true;
  4611.         if(azioni!=null && azioni.size()>0) {
  4612.             for (String azione : azioni) {
  4613.                 if(lista==null || lista.size()<=0) {
  4614.                     all  = false;
  4615.                     break;
  4616.                 }
  4617.                 boolean found = false;
  4618.                 for (MappingFruizionePortaDelegata mappingFruizionePortaDelegata : lista) {
  4619.                     PortaDelegata pdAssociata = this.porteDelegateCore.getPortaDelegata(mappingFruizionePortaDelegata.getIdPortaDelegata());
  4620.                     if(pdAssociata.getAzione() != null && pdAssociata.getAzione().getAzioneDelegataList().contains(azione)) {
  4621.                         found = true;
  4622.                         break;
  4623.                     }
  4624.                 }
  4625.                 if(!found) {
  4626.                     all  = false;
  4627.                     break;
  4628.                 }
  4629.             }
  4630.         }
  4631.         return all;
  4632.     }
  4633.    
  4634.     public boolean allActionsRedefinedMappingFruizionePdAssociate(List<String> azioni, List<PortaDelegata> lista) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  4635.         // verifico se tutte le azioni sono definite in regole specifiche
  4636.         boolean all = true;
  4637.         if(azioni!=null && azioni.size()>0) {
  4638.             for (String azione : azioni) {
  4639.                 if(lista==null || lista.size()<=0) {
  4640.                     all  = false;
  4641.                     break;
  4642.                 }
  4643.                 boolean found = false;
  4644.                 for (PortaDelegata pdAssociata : lista) {
  4645.                     if(pdAssociata.getAzione() != null && pdAssociata.getAzione().getAzioneDelegataList().contains(azione)) {
  4646.                         found = true;
  4647.                         break;
  4648.                     }
  4649.                 }
  4650.                 if(!found) {
  4651.                     all  = false;
  4652.                     break;
  4653.                 }
  4654.             }
  4655.         }
  4656.         return all;
  4657.     }


  4658.     public void serviziFruitoriPorteDelegateList(List<PortaDelegata> lista, String idServizio, String idSoggettoFruitore, String idFruzione, ISearch ricerca)
  4659.             throws Exception {
  4660.         try {
  4661.            
  4662.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);

  4663.             ServletUtils.addListElementIntoSession(this.request, this.session, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI_PORTE_DELEGATE,
  4664.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, idServizio),
  4665.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO, idSoggettoFruitore),
  4666.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, idFruzione));

  4667.             IExtendedListServlet extendedServletList = this.core.getExtendedServletPortaDelegata();
  4668.            
  4669.             int idLista = Liste.SERVIZI_FRUITORI_PORTE_DELEGATE;
  4670.             int limit = ricerca.getPageSize(idLista);
  4671.             int offset = ricerca.getIndexIniziale(idLista);
  4672.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  4673.             this.pd.setIndex(offset);
  4674.             this.pd.setPageSize(limit);
  4675.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  4676.             // Utilizza la configurazione come parent
  4677.             ServletUtils.setObjectIntoSession(this.request, this.session, PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE, PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT);

  4678.             // Prendo il nome e il tipo del servizio
  4679.             AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(idServizio));

  4680.             // Prendo il nome e il tipo del soggetto fruitore
  4681.             Soggetto soggFruitore = this.soggettiCore.getSoggettoRegistro(Integer.parseInt(idSoggettoFruitore));
  4682.            
  4683.             String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(soggFruitore.getTipo());
  4684.            
  4685.             String servizioTmpTile = asps.getTipoSoggettoErogatore() + "/" + asps.getNomeSoggettoErogatore() + "-" + asps.getTipo() + "/" + asps.getNome();
  4686.             Parameter pIdServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, idServizio+ "");
  4687.             Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  4688.             Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  4689.            
  4690.             String fruitoreTmpTile = "Fruitore "+soggFruitore.getTipo() + "/" + soggFruitore.getNome();
  4691.             Parameter pIdFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, idFruzione+ "");

  4692.             // setto la barra del titolo
  4693.             List<Parameter> lstParm = new ArrayList<>();

  4694.             lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  4695.             lstParm.add(new Parameter(servizioTmpTile, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE, pIdServizio,pNomeServizio, pTipoServizio));
  4696.             lstParm.add(new Parameter(fruitoreTmpTile, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE, pIdServizio,pIdFruitore));
  4697.            
  4698.             if (search.equals("")) {
  4699.                 this.pd.setSearchDescription("");
  4700.                 lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_DELEGATE, null));
  4701.             }else {
  4702.                 lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_DELEGATE,
  4703.                         AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_PORTE_DELEGATE_LIST,
  4704.                         new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, idServizio),
  4705.                         new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO, idSoggettoFruitore)));
  4706.                 lstParm.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  4707.             }          
  4708.            
  4709.             // setto la barra del titolo
  4710.             ServletUtils.setPageDataTitle(this.pd, lstParm );

  4711.             // controllo eventuali risultati ricerca
  4712.             if (!search.equals("")) {
  4713.                 ServletUtils.enabledPageDataSearch(this.pd, AccordiServizioParteSpecificaCostanti.LABEL_APS_CONFIGURAZIONI, search);
  4714.             }


  4715.             List<String> listaLabel = new ArrayList<>();

  4716.             listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  4717.             //listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SOGGETTO);
  4718.             //listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_DESCRIZIONE);
  4719.             listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_SERVIZI_APPLICATIVI);
  4720.             listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_RUOLI);
  4721.             listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY);
  4722.             //if(InterfaceType.AVANZATA.equals(ServletUtils.getUserFromSession(this.session).getInterfaceType())){
  4723.             listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM);
  4724.             //}
  4725.             listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_BR_RICHIESTA);
  4726.             listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_BR_RISPOSTA);
  4727.             if(extendedServletList!=null && extendedServletList.showExtendedInfo(this, protocollo)){
  4728.                 listaLabel.add(extendedServletList.getListTitle(this));
  4729.             }

  4730.             String[] labels = listaLabel.toArray(new String[listaLabel.size()]);
  4731.             this.pd.setLabels(labels);

  4732.             // preparo i dati
  4733.             List<List<DataElement>> dati = new ArrayList<>();

  4734.             Iterator<PortaDelegata> it = lista.iterator();
  4735.             PortaDelegata pd = null;
  4736.             while (it.hasNext()) {
  4737.                 pd = it.next();
  4738.                 List<DataElement> e = new ArrayList<>();

  4739.                
  4740.                 DataElement de = new DataElement();
  4741.                 de.setType(DataElementType.HIDDEN);
  4742.                 de.setValue("" + pd.getId());
  4743.                 e.add(de);
  4744.                
  4745.                
  4746.                 de = new DataElement();
  4747.                 de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,
  4748.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  4749.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA,pd.getNome()),
  4750.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + pd.getId())
  4751.                         );
  4752.                 de.setValue(pd.getNome());
  4753.                 de.setIdToRemove(pd.getId().toString());
  4754.                 de.setToolTip(pd.getDescrizione());
  4755.                 e.add(de);
  4756.                
  4757.                 // NON SERVE: sono già dentro un soggetto fruitore
  4758. //              de = new DataElement();
  4759. //              de.setValue(pd.getTipoSoggettoProprietario()+"/"+pd.getNomeSoggettoProprietario());
  4760. //              e.add(de);
  4761.                
  4762. //              de = new DataElement();
  4763. //              de.setValue(pd.getDescrizione());
  4764. //              e.add(de);
  4765.                
  4766.                 de = new DataElement();
  4767.                 if(TipoAutorizzazione.isAuthenticationRequired(pd.getAutorizzazione())
  4768.                         ||
  4769.                         !TipoAutorizzazione.getAllValues().contains(pd.getAutorizzazione()) ){  // custom ){
  4770.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_SERVIZIO_APPLICATIVO_LIST,
  4771.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  4772.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId())
  4773.                             );
  4774.                     if (contaListe) {
  4775.                         int numSA = pd.sizeServizioApplicativoList();
  4776.                         ServletUtils.setDataElementVisualizzaLabel(de,Long.valueOf(numSA));
  4777.                     } else
  4778.                         ServletUtils.setDataElementVisualizzaLabel(de);
  4779.                 }
  4780.                 else{
  4781.                     de.setValue("-");
  4782.                 }
  4783.                 e.add(de);
  4784.                
  4785.                 de = new DataElement();
  4786.                 if(TipoAutorizzazione.isRolesRequired(pd.getAutorizzazione())
  4787.                         ||
  4788.                         !TipoAutorizzazione.getAllValues().contains(pd.getAutorizzazione()) ){  // custom ){
  4789.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_RUOLI_LIST,
  4790.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  4791.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId())
  4792.                             );
  4793.                     if (contaListe) {
  4794.                         int numSA = 0;
  4795.                         if(pd.getRuoli()!=null){
  4796.                             numSA= pd.getRuoli().sizeRuoloList();
  4797.                         }
  4798.                         ServletUtils.setDataElementVisualizzaLabel(de,Long.valueOf(numSA));
  4799.                     } else
  4800.                         ServletUtils.setDataElementVisualizzaLabel(de);
  4801.                 }
  4802.                 else{
  4803.                     de.setValue("-");
  4804.                 }
  4805.                 e.add(de);      

  4806.                 de = new DataElement();
  4807.                 de.setUrl(
  4808.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY,
  4809.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  4810.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId())
  4811.                         );
  4812.                 de.setValue(pd.getStatoMessageSecurity());
  4813.                 e.add(de);

  4814.                 //if(InterfaceType.AVANZATA.equals(ServletUtils.getUserFromSession(this.session).getInterfaceType())){
  4815.                 de = new DataElement();
  4816.                 de.setUrl(
  4817.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM,
  4818.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  4819.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId())
  4820.                         );

  4821.                 boolean isMTOMAbilitatoReq = false;
  4822.                 boolean isMTOMAbilitatoRes= false;
  4823.                 if(pd.getMtomProcessor()!= null){
  4824.                     if(pd.getMtomProcessor().getRequestFlow() != null){
  4825.                         if(pd.getMtomProcessor().getRequestFlow().getMode() != null){
  4826.                             MTOMProcessorType mode = pd.getMtomProcessor().getRequestFlow().getMode();
  4827.                             if(!mode.equals(MTOMProcessorType.DISABLE))
  4828.                                 isMTOMAbilitatoReq = true;
  4829.                         }
  4830.                     }

  4831.                     if(pd.getMtomProcessor().getResponseFlow() != null){
  4832.                         if(pd.getMtomProcessor().getResponseFlow().getMode() != null){
  4833.                             MTOMProcessorType mode = pd.getMtomProcessor().getResponseFlow().getMode();
  4834.                             if(!mode.equals(MTOMProcessorType.DISABLE))
  4835.                                 isMTOMAbilitatoRes = true;
  4836.                         }
  4837.                     }
  4838.                 }

  4839.                 if(isMTOMAbilitatoReq || isMTOMAbilitatoRes)
  4840.                     de.setValue(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_ABILITATO);
  4841.                 else
  4842.                     de.setValue(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM_DISABILITATO);
  4843.                 e.add(de);
  4844.                 //}

  4845.                 de = new DataElement();
  4846.                 de.setUrl(
  4847.                         PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_REQUEST_LIST,
  4848.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  4849.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId()),
  4850.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME,pd.getNome())
  4851.                         );
  4852.                 if (contaListe) {
  4853.                     int numCorrelazione = 0;
  4854.                     if (pd.getCorrelazioneApplicativa() != null)
  4855.                         numCorrelazione = pd.getCorrelazioneApplicativa().sizeElementoList();
  4856.                     ServletUtils.setDataElementVisualizzaLabel(de,Long.valueOf(numCorrelazione));
  4857.                 } else
  4858.                     ServletUtils.setDataElementVisualizzaLabel(de);
  4859.                 e.add(de);

  4860.                 de = new DataElement();
  4861.                 de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA_RESPONSE_LIST,
  4862.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  4863.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId()),
  4864.                         new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME,pd.getNome())
  4865.                         );
  4866.                 if (contaListe) {
  4867.                     int numCorrelazione = 0;
  4868.                     if (pd.getCorrelazioneApplicativaRisposta() != null)
  4869.                         numCorrelazione = pd.getCorrelazioneApplicativaRisposta().sizeElementoList();
  4870.                     ServletUtils.setDataElementVisualizzaLabel(de,Long.valueOf(numCorrelazione));
  4871.                 } else
  4872.                     ServletUtils.setDataElementVisualizzaLabel(de);
  4873.                 e.add(de);

  4874.                 if(extendedServletList!=null && extendedServletList.showExtendedInfo(this, protocollo)){
  4875.                     de = new DataElement();
  4876.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_EXTENDED_LIST,
  4877.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  4878.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, ""+pd.getId()),
  4879.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME,pd.getNome())
  4880.                             );
  4881.                     if (contaListe) {
  4882.                         int numExtended = extendedServletList.sizeList(pd);
  4883.                         ServletUtils.setDataElementVisualizzaLabel(de,Long.valueOf(numExtended));
  4884.                     } else
  4885.                         ServletUtils.setDataElementVisualizzaLabel(de);
  4886.                     e.add(de);
  4887.                 }
  4888.                
  4889.                 dati.add(e);
  4890.             }

  4891.             this.pd.setDati(dati);
  4892.             this.pd.setAddButton(false);

  4893.         } catch (Exception e) {
  4894.             this.logError("Exception: " + e.getMessage(), e);
  4895.             throw new Exception(e);
  4896.         }
  4897.     }
  4898.    
  4899.     public void serviziFruitoriMappingList(List<MappingFruizionePortaDelegata> listaParam, String idServizio,
  4900.             String idSoggFruitoreDelServizio, IDSoggetto idSoggettoFruitore, String idFruzione, ISearch ricerca)    throws Exception {
  4901.         try {
  4902.            
  4903.             Boolean contaListeObject = ServletUtils.getContaListeFromSession(this.session);
  4904.             boolean contaListe = contaListeObject!=null ? contaListeObject.booleanValue() : false;
  4905.            
  4906.             Parameter parametroTipoSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE, idSoggettoFruitore.getTipo());
  4907.             Parameter parametroNomeSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE, idSoggettoFruitore.getNome());
  4908.            
  4909.             ServletUtils.addListElementIntoSession(this.request, this.session, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI_PORTE_DELEGATE,
  4910.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, idServizio),
  4911.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO, idSoggFruitoreDelServizio),
  4912.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, idFruzione),
  4913.                     parametroTipoSoggettoFruitore, parametroNomeSoggettoFruitore);

  4914.             IExtendedListServlet extendedServletList = this.core.getExtendedServletPortaDelegata();
  4915.            
  4916.             int idLista = Liste.CONFIGURAZIONE_FRUIZIONE;
  4917.             int limit = ricerca.getPageSize(idLista);
  4918.             int offset = ricerca.getIndexIniziale(idLista);

  4919.             String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  4920.             boolean gestioneFruitori = false;
  4921.             if(tipologia!=null &&
  4922.                 AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  4923.                 gestioneFruitori = true;
  4924.             }
  4925.            
  4926.             boolean gestioneGruppi = true;
  4927.             String paramGestioneGruppi = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_GRUPPI);
  4928.             if(paramGestioneGruppi!=null && !"".equals(paramGestioneGruppi)) {
  4929.                 gestioneGruppi = Boolean.valueOf(paramGestioneGruppi);
  4930.             }
  4931.            
  4932.             boolean gestioneConfigurazioni = true;
  4933.             String paramGestioneConfigurazioni = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_CONFIGURAZIONI);
  4934.             if(paramGestioneConfigurazioni!=null && !"".equals(paramGestioneConfigurazioni)) {
  4935.                 gestioneConfigurazioni = Boolean.valueOf(paramGestioneConfigurazioni);
  4936.             }
  4937.            
  4938.             boolean visualizzazioneTabs = !this.isModalitaCompleta();
  4939.             if(visualizzazioneTabs) {
  4940.                     gestioneGruppi = false;
  4941.                     this.pd.setCustomListViewName(ErogazioniCostanti.ASPS_EROGAZIONI_NOME_VISTA_CUSTOM_CONFIGURAZIONE);
  4942.             }
  4943.            
  4944.             // Prendo il nome e il tipo del servizio
  4945.             AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(idServizio));
  4946.             AccordoServizioParteComuneSintetico apc = this.apcCore.getAccordoServizioSintetico(asps.getIdAccordo());
  4947.             org.openspcoop2.core.registry.constants.ServiceBinding serviceBinding = apc.getServiceBinding();
  4948.             ServiceBinding serviceBindingMessage = this.apcCore.toMessageServiceBinding(apc.getServiceBinding());
  4949.            
  4950.             Map<String,String> azioni = this.porteApplicativeCore.getAzioniConLabel(asps, apc, false, true, new ArrayList<>());
  4951.             String filtroAzione = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_AZIONE);
  4952.            
  4953.             this.pd.setIndex(offset);
  4954.             this.pd.setPageSize(limit);
  4955.             this.pd.setSearch("");

  4956.             // Utilizza la configurazione come parent
  4957.             ServletUtils.setObjectIntoSession(this.request, this.session, PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE, PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT);
  4958.            
  4959.             List<MappingFruizionePortaDelegata> listaSenzaFiltro = this.impostaFiltroAzioneMappingFruizione(null, listaParam,ricerca, idLista);
  4960.            
  4961.             boolean showBottoneAggiungiNuovaConfigurazione =
  4962.                     (azioni!=null && azioni.size()>1)
  4963.                     ||
  4964.                     (listaSenzaFiltro.size()>1);
  4965.             if(showBottoneAggiungiNuovaConfigurazione) {
  4966.                 // verifico modalita identificazione
  4967.                 for (MappingFruizionePortaDelegata mappingFruizionePortaDelegata : listaParam) {
  4968.                     if(mappingFruizionePortaDelegata.isDefault()) {
  4969.                         PortaDelegata pdDefaullt = this.porteDelegateCore.getPortaDelegata(mappingFruizionePortaDelegata.getIdPortaDelegata());
  4970.                         if(pdDefaullt.getAzione()!=null &&
  4971.                                 org.openspcoop2.core.config.constants.PortaDelegataAzioneIdentificazione.STATIC.equals(pdDefaullt.getAzione().getIdentificazione())) {
  4972.                             showBottoneAggiungiNuovaConfigurazione = false;
  4973.                         }
  4974.                         break;
  4975.                     }
  4976.                 }
  4977.             }
  4978.                        
  4979.             List<MappingFruizionePortaDelegata> lista = null;
  4980.             boolean chooseTabWithFilter = !this.isModalitaCompleta();
  4981.             if(chooseTabWithFilter) {
  4982.                 lista = listaSenzaFiltro;
  4983.                 if(lista.size()>1) {
  4984.                     MappingFruizionePortaDelegata mappingContenenteAzione = getFiltroAzioneMappingFruizione(filtroAzione, listaParam);
  4985.                     if(mappingContenenteAzione!=null) {
  4986.                         int tab = -1;
  4987.                         for (int i = 0; i < lista.size(); i++) {
  4988.                             if(lista.get(i).getNome().equals(mappingContenenteAzione.getNome())) {
  4989.                                 tab = i;
  4990.                                 break;
  4991.                             }
  4992.                         }
  4993.                         if(tab>=0) {
  4994.                             ServletUtils.setObjectIntoSession(this.request, this.session, tab+"", CostantiControlStation.PARAMETRO_ID_TAB);
  4995.                         }
  4996.                     }
  4997.                    
  4998.                     this.pd.setLabelBottoneFiltra(CostantiControlStation.LABEL_BOTTONE_INDIVIDUA_GRUPPO);
  4999.                 }
  5000.             }
  5001.             else {
  5002.                 lista = this.impostaFiltroAzioneMappingFruizione(filtroAzione, listaParam,ricerca, idLista);
  5003.             }
  5004.            
  5005.             boolean allActionRedefined = false;
  5006.             List<String> actionNonRidefinite = null;
  5007.             if(listaSenzaFiltro!=null && listaSenzaFiltro.size()>1) {
  5008.                 List<String> azioniL = new ArrayList<>();
  5009.                 if(azioni != null && azioni.size() > 0)
  5010.                     azioniL.addAll(azioni.keySet());
  5011.                 allActionRedefined = this.allActionsRedefinedMappingFruizione(azioniL, listaSenzaFiltro);
  5012.                 if(!allActionRedefined) {
  5013.                     actionNonRidefinite = this.getAllActionsNotRedefinedMappingFruizione(azioniL, listaSenzaFiltro);
  5014.                 }
  5015.             }
  5016.            
  5017.             if(!gestioneGruppi && listaParam.size()<=1) {
  5018.                 ServletUtils.disabledPageDataSearch(this.pd);
  5019.             }
  5020.             else {
  5021.                 this.addFilterAzione(azioni, filtroAzione, serviceBindingMessage);
  5022.             }
  5023.            
  5024.             boolean visualizzaAllarmi = this.confCore.isVisualizzaConfigurazioneAllarmiEnabled();  // configurazione allarmi (solo se sono stati caricati dei plugin di tipo allarme)
  5025.            
  5026.             boolean visualizzaMTOM = true;
  5027.             boolean visualizzaSicurezza = true;
  5028.             boolean visualizzaCorrelazione = true;
  5029.            
  5030.             switch (serviceBinding) {
  5031.             case REST:
  5032.                 visualizzaMTOM = false;
  5033.                 visualizzaSicurezza = true;
  5034.                 visualizzaCorrelazione = true;
  5035.                 break;
  5036.             case SOAP:
  5037.             default:
  5038.                 visualizzaMTOM = true;
  5039.                 visualizzaSicurezza = true;
  5040.                 visualizzaCorrelazione = true;
  5041.                 break;
  5042.             }
  5043.            

  5044.             // Prendo il nome e il tipo del soggetto fruitore
  5045.             Soggetto soggFruitore = this.soggettiCore.getSoggettoRegistro(Integer.parseInt(idSoggFruitoreDelServizio));
  5046.        
  5047.             String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(soggFruitore.getTipo());
  5048.            
  5049.             String servizioTmpTile = this.getLabelIdServizio(asps);
  5050.             if(gestioneFruitori) {
  5051.                 servizioTmpTile = this.getLabelServizioFruizione(protocollo, idSoggettoFruitore, asps);
  5052.             }
  5053.             Parameter pIdServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, idServizio+ "");
  5054.             Parameter pIdAsps = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS, idServizio);
  5055.             Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, asps.getIdSoggetto()+"");
  5056.            
  5057.             String fruitoreTmpTile = this.getLabelNomeSoggetto(protocollo, soggFruitore.getTipo(), soggFruitore.getNome());
  5058.        
  5059.             Fruitore fru = null;
  5060.             if(gestioneFruitori) {
  5061.                 for (Fruitore fruCheck : asps.getFruitoreList()) {
  5062.                     if(fruCheck.getTipo().equals(idSoggettoFruitore.getTipo()) &&
  5063.                             fruCheck.getNome().equals(idSoggettoFruitore.getNome())) {
  5064.                         fru = fruCheck;
  5065.                         break;
  5066.                     }
  5067.                 }
  5068.             }
  5069.             else {
  5070.                 for (Fruitore fruCheck : asps.getFruitoreList()) {
  5071.                     if(fruCheck.getTipo().equals(soggFruitore.getTipo()) &&
  5072.                             fruCheck.getNome().equals(soggFruitore.getNome())) {
  5073.                         fru = fruCheck;
  5074.                         break;
  5075.                     }
  5076.                 }
  5077.             }
  5078.            
  5079.             Parameter pIdFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, idFruzione+ "");
  5080.            
  5081.            
  5082.             boolean showConnettoreLink = true;
  5083.             if(gestioneConfigurazioni && this.isModalitaStandard()) {
  5084.                 showConnettoreLink = false;
  5085.                
  5086.                 Iterator<MappingFruizionePortaDelegata> it = lista.iterator();
  5087.                 MappingFruizionePortaDelegata mapping = null;
  5088.                 while (it.hasNext()) {
  5089.                     mapping = it.next();
  5090.                    
  5091.                     if(!mapping.isDefault()) {
  5092.                         PortaDelegata pdAssociata = this.porteDelegateCore.getPortaDelegata(mapping.getIdPortaDelegata());

  5093.                         List<String> listaAzioniPDAssociataMappingNonDefault = pdAssociata.getAzione().getAzioneDelegataList();
  5094.                        
  5095.                         String azioneConnettore =  null;
  5096.                         if(listaAzioniPDAssociataMappingNonDefault!=null && !listaAzioniPDAssociataMappingNonDefault.isEmpty()) {
  5097.                             azioneConnettore = listaAzioniPDAssociataMappingNonDefault.get(0);
  5098.                         }
  5099.                        
  5100.                         boolean ridefinito = false;
  5101.                         if(azioneConnettore!=null && !"".equals(azioneConnettore)) {
  5102.                             for (ConfigurazioneServizioAzione check : fru.getConfigurazioneAzioneList()) {
  5103.                                 if(check.getAzioneList().contains(azioneConnettore)) {
  5104.                                     ridefinito = true;
  5105.                                     break;
  5106.                                 }
  5107.                             }
  5108.                         }
  5109.                         if(ridefinito) {
  5110.                             showConnettoreLink = true;
  5111.                             break;
  5112.                         }
  5113.                     }
  5114.                 }

  5115.             }
  5116.             else {
  5117.                 // se e' standard lo faccio vedere solo se ho più di un gruppo.
  5118.                 showConnettoreLink = lista!=null && lista.size()>1;
  5119.             }
  5120.            
  5121.            
  5122.             // setto la barra del titolo
  5123.             List<Parameter> lstParam = new ArrayList<>();
  5124.             Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  5125.             Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  5126.            
  5127.             Boolean vistaErogazioni = ServletUtils.getBooleanAttributeFromSession(ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI, this.session, this.request).getValue();
  5128.             String labelAzioni = this.getLabelAzioni(serviceBindingMessage);
  5129.             if(gestioneFruitori) {
  5130.                 if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  5131.                    
  5132.                     lstParam.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_FRUIZIONI, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST));
  5133.                     lstParam.add(new Parameter(servizioTmpTile, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_CHANGE, pIdServizio,pNomeServizio, pTipoServizio,
  5134.                             parametroTipoSoggettoFruitore, parametroNomeSoggettoFruitore));
  5135.                     String labelConfigurazione = gestioneConfigurazioni ? ErogazioniCostanti.LABEL_ASPS_GESTIONE_CONFIGURAZIONI :
  5136.                         (gestioneGruppi ? MessageFormat.format(ErogazioniCostanti.LABEL_ASPS_GESTIONE_GRUPPI_CON_PARAMETRO, labelAzioni) : AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_APPLICATIVE);
  5137.                    
  5138.                     lstParam.add(new Parameter(labelConfigurazione, null));
  5139.                    
  5140.                 }else {
  5141.                     lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  5142.                     lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_CONFIGURAZIONI_DI + servizioTmpTile, null));
  5143.                 }
  5144.             }
  5145.             else {
  5146.                 lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  5147.                 lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FUITORI_DI  + servizioTmpTile, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_LIST , pIdServizio,pIdSoggettoErogatore));
  5148.                 lstParam.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_CONFIGURAZIONI_DI + fruitoreTmpTile, null));
  5149.             }
  5150.            
  5151.            
  5152.            
  5153.             this.pd.setSearchLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  5154.             this.pd.setSearchDescription("");
  5155.                        
  5156.             // Controllo se richiedere il connettore
  5157.             boolean connettoreStatic = false;
  5158.             if(gestioneFruitori) {
  5159.                 connettoreStatic = this.apsCore.isConnettoreStatic(protocollo);
  5160.             }
  5161.            
  5162.             // setto la barra del titolo
  5163.             ServletUtils.setPageDataTitle(this.pd, lstParam );

  5164.             List<String> listaLabel = new ArrayList<>();
  5165.             if(visualizzazioneTabs && (gestioneGruppi || listaParam.size()>1)) {
  5166.                 listaLabel.add(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_NOME_GRUPPO);
  5167.             }
  5168.             if(gestioneConfigurazioni) {
  5169.                 /**listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ABILITATO);*/
  5170.                 listaLabel.add("");
  5171.             }
  5172.             if(!visualizzazioneTabs && (gestioneGruppi || listaParam.size()>1)) {
  5173.                 listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME_GRUPPO);
  5174.             }
  5175.             if(gestioneGruppi || visualizzazioneTabs) {
  5176.                 /**listaLabel.add(this.getLabelAzioni(serviceBindingMessage));*/
  5177.                 if(this.isModalitaCompleta()) {
  5178.                     listaLabel.add(labelAzioni);
  5179.                 }
  5180.                 else {
  5181.                     listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELENCO_AZIONI_GRUPPI_PREFIX+labelAzioni);
  5182.                 }
  5183.             }
  5184.             if(gestioneConfigurazioni) {
  5185.                 if(showConnettoreLink && !connettoreStatic) {
  5186.                     listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE);
  5187.                     listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VERIFICA_CONNETTORE);
  5188.                 }
  5189.                 listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI);
  5190.                 listaLabel.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING);
  5191.                 listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_CONTENUTI);
  5192.                 listaLabel.add(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RESPONSE_CACHING);
  5193.                 if(visualizzaSicurezza) {
  5194.                     listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY);
  5195.                 }
  5196.                 if(visualizzaMTOM) {
  5197.                     listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM);
  5198.                 }
  5199.                 listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI);
  5200.                 if(visualizzaCorrelazione) {
  5201.                     listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRACCIAMENTO);
  5202.                 }
  5203.                
  5204.                 listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_DUMP_CONFIGURAZIONE);
  5205.                
  5206.                 if((this.isModalitaAvanzata() || this.porteDelegateCore.isProprietaFruizioniShowModalitaStandard())) {
  5207.                     listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PROTOCOL_PROPERTIES);
  5208.                 }
  5209.                 if(this.isModalitaAvanzata()) {
  5210.                     listaLabel.add(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_OPZIONI_AVANZATE);
  5211.                 }
  5212.                
  5213.                 if(extendedServletList!=null && extendedServletList.showExtendedInfo(this,protocollo)){
  5214.                     listaLabel.add(extendedServletList.getListTitle(this));
  5215.                 }
  5216.             }
  5217.            
  5218.             String[] labels = listaLabel.toArray(new String[listaLabel.size()]);
  5219.             this.pd.setLabels(labels);

  5220.             PropertiesSourceConfiguration propertiesSourceConfiguration = null;
  5221.             ConfigManager configManager = null;
  5222.             Configurazione configurazioneGenerale = null;
  5223.             if(visualizzazioneTabs) {
  5224.                 propertiesSourceConfiguration = this.apsCore.getMessageSecurityPropertiesSourceConfiguration();
  5225.                 configManager = ConfigManager.getinstance(ControlStationCore.getLog());
  5226.                 configManager.leggiConfigurazioni(propertiesSourceConfiguration, true);
  5227.                 configurazioneGenerale = this.confCore.getConfigurazioneGenerale();
  5228.             }
  5229.            
  5230.             impostaComandiMenuContestualePD(idSoggFruitoreDelServizio, parametroTipoSoggettoFruitore,
  5231.                     parametroNomeSoggettoFruitore, asps, protocollo, pIdSoggettoErogatore, fru,
  5232.                     pIdFruitore, pNomeServizio, pTipoServizio);
  5233.            
  5234.             // preparo i dati
  5235.             List<List<DataElement>> dati = new ArrayList<>();

  5236.             if(lista!=null) {
  5237.                 Iterator<MappingFruizionePortaDelegata> it = lista.iterator();
  5238.                 MappingFruizionePortaDelegata mapping = null;
  5239.                 int idTab = 0;
  5240.                 while (it.hasNext()) {
  5241.                     mapping = it.next();
  5242.                     PortaDelegata pdAssociata = this.porteDelegateCore.getPortaDelegata(mapping.getIdPortaDelegata());
  5243.                     List<DataElement> e = new ArrayList<>();
  5244.    
  5245.                     Parameter pIdPD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + pdAssociata.getId());
  5246.                     Parameter pNomePD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA, pdAssociata.getNome());
  5247.                     Parameter pIdSoggPD = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, pdAssociata.getIdSoggetto() + "");
  5248.                     Parameter pIdTAb = new Parameter(CostantiControlStation.PARAMETRO_ID_TAB, ""+idTab);
  5249.                    
  5250.                     @SuppressWarnings("unused")
  5251.                     Parameter pConfigurazioneDati = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_DATI_INVOCAZIONE, Costanti.CHECK_BOX_ENABLED_TRUE);
  5252.                     Parameter pConfigurazioneAltroPorta = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_ALTRO_PORTA, Costanti.CHECK_BOX_ENABLED_TRUE);
  5253.                    
  5254.                     Parameter pConfigurazioneDescrizione = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONFIGURAZIONE_DESCRIZIONE, Costanti.CHECK_BOX_ENABLED_TRUE);
  5255.                    
  5256.                     List<String> listaAzioniPDAssociataMappingNonDefault = null;
  5257.                     if(!mapping.isDefault()) {
  5258.                         listaAzioniPDAssociataMappingNonDefault = pdAssociata.getAzione().getAzioneDelegataList();
  5259.                     }
  5260.                    
  5261.                     // spostata direttamente nell'elenco delle fruizioni
  5262.     /**             // nome con link al PortaDeletagataChange
  5263.     //              DataElement de = new DataElement();
  5264.     //              if(mapping.isDefault()) {
  5265.     //                  de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneDati);
  5266.     //              }
  5267.     //              de.setValue(mapping.isDefault() ? PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MAPPING_FRUIZIONE_PD_NOME_DEFAULT : mapping.getNome());
  5268.     //              de.setIdToRemove(pdAssociata.getNome());
  5269.     //              //de.setToolTip(StringUtils.isNotEmpty(pdAssociata.getDescrizione()) ? pdAssociata.getDescrizione() : pdAssociata.getNome());
  5270.     //              e.add(de);*/
  5271.                    
  5272.                     if(gestioneConfigurazioni && mapping.isDefault() && allActionRedefined && (!showConnettoreLink)) {
  5273.                         int numEntries = ricerca.getNumEntries(idLista);
  5274.                         ricerca.setNumEntries(idLista, numEntries -1);
  5275.                         this.pd.setNumEntries(numEntries -1);
  5276.                         continue; // non faccio vedere la riga "disconnessa"
  5277.                     }
  5278.                    
  5279.                     boolean statoPD = pdAssociata.getStato().equals(StatoFunzionalita.ABILITATO);
  5280.                     String statoPDallRedefined = null;
  5281.                     String statoMapping = statoPD ? CostantiControlStation.LABEL_PARAMETRO_PORTA_ABILITATO_TOOLTIP : CostantiControlStation.LABEL_PARAMETRO_PORTA_DISABILITATO_TOOLTIP;
  5282.                     boolean urlCambiaStato = true;
  5283.                     if(mapping.isDefault() && allActionRedefined) {
  5284.                         statoPD = false;
  5285.                         statoPDallRedefined = "off";
  5286.                         statoMapping = this.getLabelAllAzioniRidefiniteTooltip(serviceBindingMessage);
  5287.                         urlCambiaStato = false;
  5288.                     }
  5289.                    
  5290.                     boolean descrizioneEmpty = pdAssociata.getDescrizione()==null || StringUtils.isEmpty(pdAssociata.getDescrizione()) ||
  5291.                             SubscriptionConfiguration.isDescriptionDefault(pdAssociata.getDescrizione());
  5292.                    
  5293.                     // Nome Gruppo
  5294.                     if(visualizzazioneTabs && (gestioneGruppi || listaParam.size()>1)) {
  5295.                         DataElement de = new DataElement();
  5296.                        
  5297.                         de.setWidthPx(10);
  5298.                         de.setType(DataElementType.CHECKBOX);
  5299.                        
  5300.                         de.setStatusToolTip(statoPD ? CostantiControlStation.LABEL_PARAMETRO_PORTA_ABILITATO_TOOLTIP_NO_ACTION : CostantiControlStation.LABEL_PARAMETRO_PORTA_DISABILITATO_TOOLTIP_NO_ACTION);
  5301.                         if(statoPDallRedefined!=null) {
  5302.                             de.setStatusType(statoPDallRedefined);
  5303.                         }
  5304.                         else {
  5305.                             de.setStatusType(statoPD ? CheckboxStatusType.ABILITATO : CheckboxStatusType.DISABILITATO);
  5306.                         }
  5307.                        
  5308.                         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME_GRUPPO);
  5309.                         de.setValue(mapping.getDescrizione());
  5310.                         de.setStatusValue(mapping.getDescrizione());
  5311.                        
  5312.                         if(!mapping.isDefault()) {
  5313.                                DataElementImage image = new DataElementImage();
  5314.                                
  5315.                                image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONFIGURAZIONE_CHANGE,pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5316.                                image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME_GRUPPO));
  5317.                                image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5318.                                
  5319.                                de.addImage(image );
  5320.                         }
  5321.                         if(!mapping.isDefault())
  5322.                                de.setIdToRemove(pdAssociata.getNome());
  5323.                        
  5324.                         if(descrizioneEmpty) {
  5325.                            
  5326.                             DataElementImage image = new DataElementImage();
  5327.                             image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneDescrizione,pIdTAb);
  5328.                             image.setToolTip(MessageFormat.format(CostantiControlStation.AGGIUNGI_DESCRIZIONE_TOOLTIP_CON_PARAMETRO, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_DESCRIZIONE));
  5329.                             image.setImage(CostantiControlStation.ICONA_AGGIUNGI_DESCRIZIONE);
  5330.                            
  5331.                             de.addImage(image);
  5332.                         }
  5333.                        
  5334.                         if(urlCambiaStato) {
  5335.                             Parameter pAbilita = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ABILITA,  (statoPD ? Costanti.CHECK_BOX_DISABLED : Costanti.CHECK_BOX_ENABLED_TRUE));
  5336.                             de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_ABILITAZIONE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pAbilita);
  5337.                            
  5338.                             DataElementImage image = new DataElementImage();
  5339.                             image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_ABILITAZIONE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pAbilita,pIdTAb);
  5340.                             image.setToolTip(statoMapping);
  5341.                             image.setImage(statoPD ? CostantiControlStation.ICONA_MODIFICA_TOGGLE_ON : CostantiControlStation.ICONA_MODIFICA_TOGGLE_OFF);
  5342.                              
  5343.                             de.addImage(image);
  5344.                         }
  5345.                        
  5346.                         e.add(de);
  5347.                     }
  5348.                    
  5349.                     if(gestioneConfigurazioni && !visualizzazioneTabs) {
  5350.                        
  5351.                         // Abilitato
  5352.                         DataElement de = new DataElement();
  5353.                         /**if(visualizzazioneTabs)
  5354.                         //   de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_STATO);*/
  5355.                        
  5356.                         de.setWidthPx(10);
  5357.                         de.setType(DataElementType.CHECKBOX);
  5358.                         /**if(visualizzazioneTabs) {
  5359.                         //  de.setStatusValue(statoPD ? this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_ABILITATO) : this.getUpperFirstChar(CostantiControlStation.DEFAULT_VALUE_DISABILITATO));
  5360.                         //  de.setStatusToolTip(statoPD ? CostantiControlStation.LABEL_PARAMETRO_PORTA_ABILITATO_TOOLTIP_NO_ACTION : CostantiControlStation.LABEL_PARAMETRO_PORTA_DISABILITATO_TOOLTIP_NO_ACTION);
  5361.                         //  if(statoPDallRedefined!=null) {
  5362.                         //      de.setStatusType(statoPDallRedefined);
  5363.                         //  }
  5364.                         //  else {
  5365.                         //      de.setStatusType(statoPD ? CheckboxStatusType.ABILITATO : CheckboxStatusType.DISABILITATO);
  5366.                         //  }
  5367.                         //}
  5368.                         //else {*/
  5369.                         de.setToolTip(statoMapping);

  5370.                         if(statoPDallRedefined!=null) {
  5371.                             de.setSelected(statoPDallRedefined);
  5372.                         }
  5373.                         else {
  5374.                             de.setSelected(statoPD);
  5375.                         }
  5376.                         if(urlCambiaStato) {
  5377.                             Parameter pAbilita = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ABILITA,  (statoPD ? Costanti.CHECK_BOX_DISABLED : Costanti.CHECK_BOX_ENABLED_TRUE));
  5378.                             de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_ABILITAZIONE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pAbilita);
  5379.                            
  5380.                             DataElementImage image = new DataElementImage();
  5381.                             image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_ABILITAZIONE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pAbilita,pIdTAb);
  5382.                             image.setToolTip(statoMapping);
  5383.                             image.setImage(statoPD ? CostantiControlStation.ICONA_MODIFICA_TOGGLE_ON : CostantiControlStation.ICONA_MODIFICA_TOGGLE_OFF);
  5384.                              
  5385.                             de.setImage(image);
  5386.                         }
  5387.                         e.add(de);
  5388.    
  5389.                     }
  5390.                    
  5391.                    
  5392.                     // NomeGruppo
  5393.                     if(!visualizzazioneTabs && (gestioneGruppi || listaParam.size()>1)) {
  5394.                        
  5395.                         DataElement de = new DataElement();
  5396.                         de.setValue(mapping.getDescrizione());
  5397.                         if(gestioneGruppi && !mapping.isDefault()) {
  5398.                             de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONFIGURAZIONE_CHANGE,pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore);
  5399.                         }
  5400.                         e.add(de);
  5401.                     }
  5402.                        
  5403.                     // lista delle azioni
  5404.                     if(gestioneGruppi || (visualizzazioneTabs && (listaParam.size()>1 || !mapping.isDefault()))) {
  5405.                        
  5406.                         List<String> listaAzioni = null;
  5407.                         String nomiAzioni = null;
  5408.                         long countAzioni = 0;
  5409.                         if(!mapping.isDefault()) {
  5410.                             listaAzioni = listaAzioniPDAssociataMappingNonDefault!= null ? listaAzioniPDAssociataMappingNonDefault : new ArrayList<>();
  5411.                            
  5412.                             if(!listaAzioni.isEmpty() && azioni.size()>0) {
  5413.                                
  5414.                                 StringBuilder sb = new StringBuilder();
  5415.                                 Iterator<String> itAz = azioni.keySet().iterator();
  5416.                                 while (itAz.hasNext()) {
  5417.                                     String idAzione = itAz.next();
  5418.                                     if(listaAzioni.contains(idAzione)) {
  5419.                                         if(sb.length() >0)
  5420.                                             sb.append(", ");
  5421.                                        
  5422.                                         sb.append(azioni.get(idAzione));
  5423.                                         countAzioni++;
  5424.                                     }
  5425.                                 }
  5426.                                 nomiAzioni = sb.toString();
  5427.                                
  5428.                             }
  5429.                         }
  5430.                        
  5431.                         DataElement de = new DataElement();
  5432.                         de.setSize(200);
  5433.                         de.setIdToRemove(pdAssociata.getNome());
  5434.                        
  5435.                         if(visualizzazioneTabs) {
  5436.                             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELENCO_AZIONI_GRUPPI_PREFIX+labelAzioni);
  5437.                         }
  5438.    
  5439.                         if(listaSenzaFiltro.size()>1) {
  5440.                             DataElementImage image = new DataElementImage();
  5441.                            
  5442.                             if(!mapping.isDefault()) {
  5443.                                 de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_AZIONE_LIST,pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore);
  5444.                                 if(this.isModalitaCompleta()) {
  5445.                                     ServletUtils.setDataElementVisualizzaLabel(de, countAzioni);
  5446.                                 }
  5447.                                 else {
  5448.                                     de.setValue(nomiAzioni);
  5449.                                 }
  5450.                                 de.setToolTip(nomiAzioni);
  5451.                                 image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_AZIONE_LIST,pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5452.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELENCO_AZIONI_GRUPPI_PREFIX+labelAzioni));
  5453.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5454.                                
  5455.                                 de.setImage(image);
  5456.                             }
  5457.                             else {
  5458.                                 if(actionNonRidefinite!=null && !actionNonRidefinite.isEmpty() && azioni.size()>0) {
  5459.                                    
  5460.                                     long countAzioniRidefinite = 0;
  5461.                                     StringBuilder sb = new StringBuilder();
  5462.                                     Iterator<String> itAz = azioni.keySet().iterator();
  5463.                                     while (itAz.hasNext()) {
  5464.                                         String idAzione = itAz.next();
  5465.                                         if(actionNonRidefinite.contains(idAzione)) {
  5466.                                             if(sb.length() >0)
  5467.                                                 sb.append(", ");
  5468.                                            
  5469.                                             sb.append(azioni.get(idAzione));
  5470.                                             countAzioniRidefinite++;
  5471.                                         }
  5472.                                     }
  5473.                                     String nomiAzioniNonRidefinite = sb.toString();
  5474.                                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_AZIONE_LIST,pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore);
  5475.                                     if(this.isModalitaCompleta()) {
  5476.                                         ServletUtils.setDataElementVisualizzaLabel(de, countAzioniRidefinite);
  5477.                                     }
  5478.                                     else {
  5479.                                         de.setValue(nomiAzioniNonRidefinite);
  5480.                                     }
  5481.                                     de.setToolTip(nomiAzioniNonRidefinite);
  5482.                                    
  5483.                                     image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_AZIONE_LIST,pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5484.                                     image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_ELENCO_AZIONI_GRUPPI_PREFIX+labelAzioni));
  5485.                                     image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5486.                                    
  5487.                                     de.setImage(image);
  5488.                                 }
  5489.                                 else {
  5490.                                     if(allActionRedefined) {
  5491.                                         de.setValue(this.getLabelAllAzioniRidefiniteTooltip(serviceBindingMessage));
  5492.                                     }
  5493.                                     else {
  5494.                                         de.setValue("-"); // ??
  5495.                                     }
  5496.                                 }
  5497.                             }
  5498.                         }
  5499.                         else {
  5500.                             if(org.openspcoop2.core.registry.constants.ServiceBinding.SOAP.equals(serviceBinding)) {
  5501.                                 de.setValue(CostantiControlStation.LABEL_TUTTE_AZIONI_DEFAULT);
  5502.                             }
  5503.                             else {
  5504.                                 de.setValue(CostantiControlStation.LABEL_TUTTE_RISORSE_DEFAULT);    
  5505.                             }
  5506.                         }
  5507.                         e.add(de);
  5508.                        
  5509.                     }
  5510.    
  5511.                     // Descrizione
  5512.                     if(!descrizioneEmpty) {
  5513.                         DataElement de = new DataElement();
  5514.                         if(visualizzazioneTabs)
  5515.                             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_DESCRIZIONE);
  5516.                         de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneDescrizione,pIdTAb);
  5517.                        
  5518.                         int length = 150;
  5519.                         String descrizione = pdAssociata.getDescrizione();
  5520.                         if(descrizione!=null && descrizione.length()>length) {
  5521.                             descrizione = descrizione.substring(0, (length-4)) + " ...";
  5522.                         }
  5523.                         de.setValue(descrizione!=null ? StringEscapeUtils.escapeHtml(descrizione) : null);
  5524.                         de.setToolTip(pdAssociata.getDescrizione());
  5525.                         de.setCopyToClipboard(pdAssociata.getDescrizione());    
  5526.                        
  5527.                         if(visualizzazioneTabs) {
  5528.                             DataElementImage image = new DataElementImage();
  5529.                            
  5530.                             image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneDescrizione,pIdTAb);
  5531.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,   PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_DESCRIZIONE));
  5532.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5533.                            
  5534.                             de.setImage(image);
  5535.                         }
  5536.                         e.add(de);
  5537.                     }
  5538.                    
  5539.                     if(gestioneConfigurazioni) {
  5540.                    
  5541.                         // connettore  
  5542.                         if(showConnettoreLink && !connettoreStatic) {
  5543.                             DataElement de = new DataElement();
  5544.                             if(visualizzazioneTabs)
  5545.                                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE);
  5546.                            
  5547.                             boolean ridefinito = false;
  5548.                            
  5549.                             Connettore connettore = null;
  5550.                             if(!gestioneFruitori && mapping.isDefault()) {
  5551.                                 de.setValue("-");
  5552.                             }
  5553.                             else {
  5554.                                 Long idSoggettoLong = fru.getIdSoggetto();
  5555.                                 if(idSoggettoLong==null) {
  5556.                                     idSoggettoLong = this.soggettiCore.getIdSoggetto(fru.getNome(), fru.getTipo());
  5557.                                 }
  5558.                                 List<Parameter> listParameter = new ArrayList<>();
  5559.                                
  5560.                                 String azioneConnettore =  null;
  5561.                                 if(listaAzioniPDAssociataMappingNonDefault!=null && !listaAzioniPDAssociataMappingNonDefault.isEmpty()) {
  5562.                                     azioneConnettore = listaAzioniPDAssociataMappingNonDefault.get(0);
  5563.                                 }
  5564.                                
  5565.                                 String servletConnettore = AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE;
  5566.                                 String labelConnettore = this.getLabelConnettore(fru.getConnettore(),true,false);
  5567.                                 String copyConnettore = this.getClipBoardUrlConnettore(fru.getConnettore());
  5568.                                 if(mapping.isDefault()) {
  5569.                                     if(visualizzazioneTabs) {
  5570.                                         de.setValue(labelConnettore);
  5571.                                         de.setToolTip(this.getLabelConnettore(fru.getConnettore(),true,true)); // NEW
  5572.                                         de.setCopyToClipboard(copyConnettore); // valore da copiare
  5573.                                     }
  5574.                                     else {
  5575.                                         ServletUtils.setDataElementVisualizzaLabel(de);
  5576.                                     }
  5577.                                     Parameter pId = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId()+"");
  5578.                                     Parameter pMyId = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, fru.getId() + "");              
  5579.                                     Parameter actionIdPorta = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE_ID_PORTA,pdAssociata.getId()+"");
  5580.                                     listParameter.add(actionIdPorta);
  5581.                                     listParameter.add(pId);
  5582.                                     listParameter.add(pMyId);
  5583.                                     listParameter.add(pIdSoggettoErogatore);
  5584.                                     listParameter.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE, idSoggettoLong + ""));
  5585.                                     listParameter.add(pIdTAb);
  5586.                                     if(azioneConnettore!=null && !"".equals(azioneConnettore)) {
  5587.                                         listParameter.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE,azioneConnettore));
  5588.                                     }
  5589.                                     de.setUrl(servletConnettore, listParameter.toArray(new Parameter[1]));
  5590.                                    
  5591.                                     if(visualizzazioneTabs) {
  5592.                                         DataElementImage image = new DataElementImage();
  5593.                                         image.setUrl(servletConnettore, listParameter.toArray(new Parameter[1]));
  5594.                                         image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE));
  5595.                                         image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5596.                                         de.setImage(image);
  5597.                                     }
  5598.                                    
  5599.                                     connettore = fru.getConnettore();
  5600.                                 } else {
  5601.                                     if(azioneConnettore!=null && !"".equals(azioneConnettore)) {
  5602.                                         for (ConfigurazioneServizioAzione check : fru.getConfigurazioneAzioneList()) {
  5603.                                             if(check.getAzioneList().contains(azioneConnettore)) {
  5604.                                                 ridefinito = true;
  5605.                                                 connettore = check.getConnettore();
  5606.                                                 break;
  5607.                                             }
  5608.                                         }
  5609.                                     }
  5610.                                     if(ridefinito) {
  5611.                                         servletConnettore = PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONNETTORE_RIDEFINITO;
  5612.                                         if(visualizzazioneTabs) {
  5613.                                             de.setValue(this.getLabelConnettore(connettore,true,false));
  5614.                                             de.setCopyToClipboard(this.getClipBoardUrlConnettore(connettore));
  5615.                                         }
  5616.                                         else {
  5617.                                             de.setValue(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODALITA_CONNETTORE_RIDEFINITO);
  5618.                                         }
  5619.                                         de.setUrl(servletConnettore, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore);
  5620.                                         String tooltipConnettore = this.getLabelConnettore(connettore,true,true);
  5621.                                         de.setToolTip(ConnettoriCostanti.LABEL_PARAMETRO_MODALITA_CONNETTORE_RIDEFINITO+CostantiControlStation.TOOLTIP_BREAK_LINE+tooltipConnettore);
  5622.                                     } else {
  5623.                                         servletConnettore = PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONNETTORE_DEFAULT;
  5624.                                         if(visualizzazioneTabs) {
  5625.                                             de.setValue("["+org.openspcoop2.core.constants.Costanti.MAPPING_FRUIZIONE_PD_DESCRIZIONE_DEFAULT+"] "+labelConnettore);
  5626.                                             de.setCopyToClipboard(copyConnettore);
  5627.                                         }
  5628.                                         else {
  5629.                                             de.setValue(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODALITA_CONNETTORE_DEFAULT);
  5630.                                         }
  5631.                                         de.setUrl(servletConnettore, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore);
  5632.                                         String tooltipConnettore = this.getLabelConnettore(fru.getConnettore(),true,true);
  5633.                                         de.setToolTip(ConnettoriCostanti.LABEL_PARAMETRO_MODALITA_CONNETTORE_DEFAULT+CostantiControlStation.TOOLTIP_BREAK_LINE+tooltipConnettore);
  5634.                                        
  5635.                                         connettore = fru.getConnettore();
  5636.                                     }
  5637.                                    
  5638.                                     if(visualizzazioneTabs) {
  5639.                                         DataElementImage image = new DataElementImage();
  5640.                                         image.setUrl(servletConnettore, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5641.                                         image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE));
  5642.                                         image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5643.                                         de.setImage(image);
  5644.                                     }
  5645.                                 }
  5646.                                
  5647.                             }
  5648.                             de.allineaTdAlCentro();
  5649.                             e.add(de);
  5650.                            
  5651.                             if(connettore!=null) {
  5652.                                
  5653.                                 long idConnettore = connettore.getId();
  5654.                                 boolean checkConnettore = org.openspcoop2.pdd.core.connettori.ConnettoreCheck.checkSupported(connettore);
  5655.                                 if(checkConnettore &&
  5656.                                     (!mapping.isDefault() && !ridefinito)
  5657.                                     ){
  5658.                                     checkConnettore = false;
  5659.                                 }
  5660.                                
  5661.                                 if(visualizzazioneTabs) {
  5662.                                     if(checkConnettore) {  
  5663.                                         DataElementImage image = new DataElementImage();
  5664.                                         image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_VERIFICA_CONNETTORE, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb,
  5665.                                                 new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ID, idConnettore+""),
  5666.                                                 new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_GRUPPI, "true"),
  5667.                                                 new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_REGISTRO, "true"));
  5668.                                         image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_VERIFICA_TOOLTIP_CON_PARAMETRO, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE));
  5669.                                         image.setImage(CostantiControlStation.ICONA_VERIFICA);
  5670.                                         de.addImage(image);
  5671.                                     }
  5672.                                 } else {
  5673.                                     DataElement deVerificaConnettore = new DataElement();
  5674.                                     if(checkConnettore) {                              
  5675.                                         deVerificaConnettore.setValue(CostantiControlStation.LABEL_VERIFICA_CONNETTORE_VALORE_LINK);
  5676.                                         deVerificaConnettore.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_VERIFICA_CONNETTORE, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore,
  5677.                                                 new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ID, idConnettore+""),
  5678.                                                 new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_GRUPPI, "true"),
  5679.                                                 new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_REGISTRO, "true"));
  5680.                                     }
  5681.                                     else {
  5682.                                         deVerificaConnettore.setValue("-");
  5683.                                     }
  5684.                                     deVerificaConnettore.allineaTdAlCentro();
  5685.                                     e.add(deVerificaConnettore);
  5686.                                 }
  5687.                             }
  5688.                         }

  5689.    
  5690.                         // Controllo Accessi
  5691.                         DataElement de = new DataElement();
  5692.                         if(visualizzazioneTabs)
  5693.                             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI);
  5694.                         de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONTROLLO_ACCESSI, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore);
  5695.                         if(visualizzazioneTabs) {
  5696.                             this.setStatoControlloAccessiPortaDelegata(protocollo, pdAssociata, de);
  5697.                         }
  5698.                         else {
  5699.                             String statoControlloAccessi = this.getStatoControlloAccessiPortaDelegata(protocollo, pdAssociata);                
  5700.                             de.setValue(statoControlloAccessi);
  5701.                         }
  5702.                         de.allineaTdAlCentro();
  5703.                         if(visualizzazioneTabs) {
  5704.                             DataElementImage image = new DataElementImage();
  5705.                             image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CONTROLLO_ACCESSI, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5706.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONTROLLO_ACCESSI));
  5707.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5708.                             de.setImage(image);
  5709.                         }
  5710.                         e.add(de);
  5711.                                                            
  5712.                         // RateLimiting
  5713.                         de = new DataElement();
  5714.                         if(visualizzazioneTabs)
  5715.                             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING);
  5716.                         de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_LIST+"?"+
  5717.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_RUOLO_PORTA+"="+RuoloPolicy.DELEGATA.getValue()+"&"+
  5718.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_NOME_PORTA+"="+pdAssociata.getNome()+"&"+
  5719.                                 ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_SERVICE_BINDING+"="+serviceBindingMessage.name()
  5720.                                 );
  5721.                         List<AttivazionePolicy> listaPolicy = null;
  5722.                         if(contaListe || visualizzazioneTabs) {
  5723.                             ConsoleSearch searchPolicy = new ConsoleSearch(true);
  5724.                             listaPolicy = this.confCore.attivazionePolicyList(searchPolicy, RuoloPolicy.DELEGATA, pdAssociata.getNome());
  5725.                         }
  5726.                         if(visualizzazioneTabs) {
  5727.                             this.setStatoRateLimiting(de, listaPolicy);
  5728.                         }
  5729.                         else {
  5730.                             if(contaListe) {
  5731.                                 ServletUtils.setDataElementVisualizzaLabel(de, (long) listaPolicy.size() );
  5732.                             }
  5733.                             else {
  5734.                                 ServletUtils.setDataElementVisualizzaLabel(de);
  5735.                             }
  5736.                         }
  5737.                         de.allineaTdAlCentro();
  5738.                         if(visualizzazioneTabs) {
  5739.                             DataElementImage image = new DataElementImage();
  5740.                             image.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_CONTROLLO_TRAFFICO_ATTIVAZIONE_POLICY_LIST,
  5741.                                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_RUOLO_PORTA,RuoloPolicy.DELEGATA.getValue()),
  5742.                                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_NOME_PORTA,pdAssociata.getNome()),
  5743.                                     new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_CONTROLLO_TRAFFICO_RATE_LIMITING_POLICY_GLOBALI_LINK_SERVICE_BINDING,serviceBindingMessage.name()),
  5744.                                     pIdTAb
  5745.                                     );
  5746.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RATE_LIMITING));
  5747.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5748.                             de.setImage(image);
  5749.                         }
  5750.                         e.add(de);
  5751.                        
  5752.                         // validazione contenuti
  5753.                         de = new DataElement();
  5754.                         if(visualizzazioneTabs)
  5755.                             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_CONTENUTI);
  5756.                         de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_VALIDAZIONE_CONTENUTI, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore);
  5757.                         if(visualizzazioneTabs) {
  5758.                             setStatoValidazioneContenuti(de, pdAssociata.getValidazioneContenutiApplicativi(), apc.getFormatoSpecifica());
  5759.                         }
  5760.                         else {
  5761.                             String statoValidazione = this.getStatoValidazionePortaDelegata(pdAssociata);
  5762.                             de.setValue(statoValidazione);
  5763.                         }
  5764.                         de.allineaTdAlCentro();
  5765.                         if(visualizzazioneTabs) {
  5766.                             DataElementImage image = new DataElementImage();
  5767.                             image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_VALIDAZIONE_CONTENUTI, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5768.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_VALIDAZIONE_CONTENUTI));
  5769.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5770.                             de.setImage(image);
  5771.                         }
  5772.                         e.add(de);
  5773.                        
  5774.                         // Response Caching
  5775.                         de = new DataElement();
  5776.                         if(visualizzazioneTabs)
  5777.                             de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RESPONSE_CACHING);
  5778.                         //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  5779.                         de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_RESPONSE_CACHING, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore);
  5780.                         if(visualizzazioneTabs) {
  5781.                             setStatoCachingRisposta(de, pdAssociata.getResponseCaching(), configurazioneGenerale);
  5782.                         }
  5783.                         else {
  5784.                             String statoResponseCaching = getStatoResponseCachingPortaDelegata(pdAssociata, false);
  5785.                             de.setValue(statoResponseCaching);
  5786.                         }
  5787.                         de.allineaTdAlCentro();
  5788.                         if(visualizzazioneTabs) {
  5789.                             DataElementImage image = new DataElementImage();
  5790.                             image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_RESPONSE_CACHING, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5791.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_RESPONSE_CACHING));
  5792.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5793.                             de.setImage(image);
  5794.                         }
  5795.                         e.add(de);
  5796.                        
  5797.                         // Message Security
  5798.                         if(visualizzaSicurezza) {
  5799.                             de = new DataElement();
  5800.                             if(visualizzazioneTabs)
  5801.                                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY);
  5802.                             de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY, pIdPD, pIdSoggPD, pIdAsps, pIdFruitore);
  5803.                             if(visualizzazioneTabs) {
  5804.                                 setStatoSicurezzaMessaggio(de, pdAssociata.getMessageSecurity(), configManager, propertiesSourceConfiguration);
  5805.                             }
  5806.                             else {
  5807.                                 String statoMessageSecurity = getStatoMessageSecurityPortaDelegata(pdAssociata);
  5808.                                 de.setValue(statoMessageSecurity);
  5809.                             }
  5810.                             if(visualizzazioneTabs) {
  5811.                                 DataElementImage image = new DataElementImage();
  5812.                                 image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MESSAGE_SECURITY, pIdPD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5813.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MESSAGE_SECURITY));
  5814.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5815.                                 de.setImage(image);
  5816.                             }
  5817.                             e.add(de);
  5818.                         }
  5819.        
  5820.                         // MTOM (solo per servizi SOAP)
  5821.                         if(visualizzaMTOM) {
  5822.                             de = new DataElement();
  5823.                             if(visualizzazioneTabs)
  5824.                                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM);
  5825.                             de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM, pIdPD, pIdSoggPD, pIdAsps, pIdFruitore);
  5826.                             if(visualizzazioneTabs) {
  5827.                                 setStatoMTOM(de, pdAssociata.getMtomProcessor());
  5828.                             }
  5829.                             else {
  5830.                                 String statoMTOM = getStatoMTOMPortaDelegata(pdAssociata);
  5831.                                 de.setValue(statoMTOM);
  5832.                             }
  5833.                             de.allineaTdAlCentro();
  5834.                             if(visualizzazioneTabs) {
  5835.                                 DataElementImage image = new DataElementImage();
  5836.                                 image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_MTOM, pIdPD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5837.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MTOM));
  5838.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5839.                                 de.setImage(image);
  5840.                             }
  5841.                             e.add(de);
  5842.                         }
  5843.                        
  5844.                         // trasformazioni
  5845.                         de = new DataElement();
  5846.                         if(visualizzazioneTabs)
  5847.                             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI);
  5848.                         de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_LIST, pIdPD, pIdSoggPD, pIdAsps, pIdFruitore);
  5849.                         if(visualizzazioneTabs) {
  5850.                             setStatoTrasformazioni(de, pdAssociata.getTrasformazioni(), serviceBindingMessage);
  5851.                         }
  5852.                         else {
  5853.                             if(contaListe) {
  5854.                                 long size = 0;
  5855.                                 if(pdAssociata.getTrasformazioni()!=null) {
  5856.                                     size = pdAssociata.getTrasformazioni().sizeRegolaList();
  5857.                                 }
  5858.                                 ServletUtils.setDataElementVisualizzaLabel(de, size);
  5859.                             }
  5860.                             else {
  5861.                                 ServletUtils.setDataElementVisualizzaLabel(de);
  5862.                             }  
  5863.                         }
  5864.                         de.allineaTdAlCentro();
  5865.                         if(visualizzazioneTabs) {
  5866.                             DataElementImage image = new DataElementImage();
  5867.                             image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_TRASFORMAZIONI_LIST, pIdPD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5868.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRASFORMAZIONI));
  5869.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5870.                             de.setImage(image);
  5871.                         }
  5872.                         e.add(de);
  5873.        
  5874.                         // Correlazione applicativa
  5875.                         if(visualizzaCorrelazione) {
  5876.                             de = new DataElement();
  5877.                             if(visualizzazioneTabs)
  5878.                                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRACCIAMENTO);
  5879.                             de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA, pIdPD, pIdSoggPD, pIdAsps, pIdFruitore);
  5880.                             if(visualizzazioneTabs) {
  5881.                                 setStatoTracciamento(de, pdAssociata.getCorrelazioneApplicativa(),
  5882.                                         pdAssociata.getCorrelazioneApplicativaRisposta(), pdAssociata.getTracciamento(),
  5883.                                         (configurazioneGenerale!=null && configurazioneGenerale.getTracciamento()!=null) ? configurazioneGenerale.getTracciamento().getPortaDelegata() : null,
  5884.                                         pdAssociata.getProprieta(),
  5885.                                         configurazioneGenerale);    
  5886.                             }
  5887.                             else {
  5888.                                 String statoTracciamento = getStatoTracciamentoPortaDelegata(pdAssociata);
  5889.                                 de.setValue(statoTracciamento);
  5890.                             }
  5891.                             de.allineaTdAlCentro();
  5892.                             if(visualizzazioneTabs) {
  5893.                                 DataElementImage image = new DataElementImage();
  5894.                                 image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CORRELAZIONE_APPLICATIVA, pIdPD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5895.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_TRACCIAMENTO));
  5896.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5897.                                 de.setImage(image);
  5898.                             }
  5899.                             e.add(de);
  5900.                         }
  5901.                        
  5902.                         // dump
  5903.                         de = new DataElement();
  5904.                         if(visualizzazioneTabs)
  5905.                             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_DUMP_CONFIGURAZIONE);
  5906.                         de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_DUMP_CONFIGURAZIONE, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore);
  5907.                         if(visualizzazioneTabs) {
  5908.                             setStatoDump(de, pdAssociata.getDump(), configurazioneGenerale, false);
  5909.                         }
  5910.                         else {
  5911.                             String statoDump = getStatoDumpPortaDelegata(pdAssociata, false);
  5912.                             de.setValue(statoDump);
  5913.                         }
  5914.                         de.allineaTdAlCentro();
  5915.                         if(visualizzazioneTabs) {
  5916.                             DataElementImage image = new DataElementImage();
  5917.                             image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_DUMP_CONFIGURAZIONE, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore,pIdTAb);
  5918.                             image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_DUMP_CONFIGURAZIONE));
  5919.                             image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5920.                             de.setImage(image);
  5921.                         }
  5922.                         e.add(de);
  5923.                        
  5924.                         // Allarmi
  5925.                         if(visualizzaAllarmi) {
  5926.                             de = new DataElement();
  5927.                             if(visualizzazioneTabs)
  5928.                                 de.setLabel(ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI);
  5929.                             de.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_LIST+"?"+
  5930.                                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA+"="+RuoloPorta.DELEGATA.getValue()+"&"+
  5931.                                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA+"="+pdAssociata.getNome()+"&"+
  5932.                                     ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING+"="+serviceBindingMessage.name()
  5933.                                     );
  5934.    
  5935.                             List<ConfigurazioneAllarmeBean> listaAllarmi = null;
  5936.                             if(contaListe || visualizzazioneTabs) {
  5937.                                 ConsoleSearch searchPolicy = new ConsoleSearch(true);
  5938.                                 listaAllarmi = this.confCore.allarmiList(searchPolicy, RuoloPorta.DELEGATA, pdAssociata.getNome());
  5939.                             }
  5940.                             if(visualizzazioneTabs) {
  5941.                                 this.setStatoAllarmi(de, listaAllarmi);
  5942.                             }
  5943.                             else {
  5944.                                 if(contaListe) {
  5945.                                     ServletUtils.setDataElementVisualizzaLabel(de, (long) listaAllarmi.size() );
  5946.                                 }
  5947.                                 else {
  5948.                                     ServletUtils.setDataElementVisualizzaLabel(de);
  5949.                                 }
  5950.                             }
  5951.                             de.allineaTdAlCentro();
  5952.                             if(visualizzazioneTabs) {
  5953.                                 DataElementImage image = new DataElementImage();
  5954.                                 image.setUrl(ConfigurazioneCostanti.SERVLET_NAME_CONFIGURAZIONE_ALLARMI_LIST,
  5955.                                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA,RuoloPorta.DELEGATA.getValue()),
  5956.                                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA,pdAssociata.getNome()),
  5957.                                         new Parameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING,serviceBindingMessage.name()),
  5958.                                         pIdTAb
  5959.                                         );
  5960.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,ConfigurazioneCostanti.LABEL_CONFIGURAZIONE_ALLARMI));
  5961.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5962.                                 de.setImage(image);
  5963.                             }
  5964.                             e.add(de);
  5965.                         }
  5966.                        
  5967.                         // Protocol Properties
  5968.                         if((this.isModalitaAvanzata() || this.porteDelegateCore.isProprietaFruizioniShowModalitaStandard())){
  5969.                             de = new DataElement();
  5970.                             if(visualizzazioneTabs)
  5971.                                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PROTOCOL_PROPERTIES);
  5972.                             //fix: idsogg e' il soggetto proprietario della porta applicativa, e nn il soggetto virtuale
  5973.                             de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_PROPRIETA_PROTOCOLLO_LIST, pIdSoggPD, pIdPD,pIdAsps,pIdFruitore);
  5974.                             if(visualizzazioneTabs) {
  5975.                                 setStatoProprieta(de, pdAssociata.sizeProprietaList());
  5976.                             }
  5977.                             else {
  5978.                                 if (contaListe) {
  5979.                                     int numProp = pdAssociata.sizeProprietaList();
  5980.                                     ServletUtils.setDataElementVisualizzaLabel(de, (long) numProp );
  5981.                                 } else
  5982.                                     ServletUtils.setDataElementVisualizzaLabel(de);
  5983.                             }
  5984.                             de.allineaTdAlCentro();
  5985.                             if(visualizzazioneTabs) {
  5986.                                 DataElementImage image = new DataElementImage();
  5987.                                 image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_PROPRIETA_PROTOCOLLO_LIST, pIdSoggPD, pIdPD,pIdAsps,pIdFruitore,pIdTAb);
  5988.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_PROTOCOL_PROPERTIES));
  5989.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  5990.                                 de.setImage(image);
  5991.                             }
  5992.                             e.add(de);
  5993.                         }
  5994.                    
  5995.                         // Altro
  5996.                         if(this.isModalitaAvanzata()){
  5997.                             de = new DataElement();
  5998.                             if(visualizzazioneTabs)
  5999.                                 de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_OPZIONI_AVANZATE);
  6000.                             de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneAltroPorta);
  6001.                             if(visualizzazioneTabs) {
  6002.                                 setStatoOpzioniAvanzate(de,
  6003.                                         protocollo, serviceBindingMessage,
  6004.                                         pdAssociata.getAllegaBody(), pdAssociata.getScartaBody(),
  6005.                                         pdAssociata.getIntegrazione(), null,
  6006.                                         pdAssociata.getProprietaRateLimitingList(),
  6007.                                         pdAssociata.getStateless(), pdAssociata.getLocalForward(),
  6008.                                         pdAssociata.getRicevutaAsincronaSimmetrica(), pdAssociata.getRicevutaAsincronaAsimmetrica(),
  6009.                                         pdAssociata.getGestioneManifest(), pdAssociata.getConfigurazioneHandler());
  6010.                             }
  6011.                             else {
  6012.                                 ServletUtils.setDataElementVisualizzaLabel(de);
  6013.                             }
  6014.                             if(visualizzazioneTabs) {
  6015.                                 DataElementImage image = new DataElementImage();
  6016.                                 image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,pIdPD,pNomePD,pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneAltroPorta,pIdTAb);
  6017.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_OPZIONI_AVANZATE));
  6018.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  6019.                                 de.setImage(image);
  6020.                             }
  6021.                             e.add(de);
  6022.                         }
  6023.                        
  6024.                         // pd exdended list
  6025.                         if(extendedServletList!=null && extendedServletList.showExtendedInfo(this,protocollo)){
  6026.                             de = new DataElement();
  6027.                             if(visualizzazioneTabs)
  6028.                                 de.setLabel(extendedServletList.getListTitle(this));
  6029.                             de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_EXTENDED_LIST, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneAltroPorta);
  6030.                             if(visualizzazioneTabs) {
  6031.                                 int numExtended = extendedServletList.sizeList(pdAssociata);
  6032.                                 String stato = extendedServletList.getStatoTab(this,pdAssociata,mapping.isDefault());
  6033.                                 String statoTooltip = extendedServletList.getStatoTab(this,pdAssociata,mapping.isDefault());
  6034.                                 setStatoExtendedList(de, numExtended, stato, statoTooltip);
  6035.                             }
  6036.                             else {
  6037.                                 if (contaListe) {
  6038.                                     int numExtended = extendedServletList.sizeList(pdAssociata);
  6039.                                     ServletUtils.setDataElementVisualizzaLabel(de,Long.valueOf(numExtended));
  6040.                                 } else
  6041.                                     ServletUtils.setDataElementVisualizzaLabel(de);
  6042.                             }
  6043.                             de.allineaTdAlCentro();
  6044.                             if(visualizzazioneTabs) {
  6045.                                 DataElementImage image = new DataElementImage();
  6046.                                 image.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_EXTENDED_LIST, pIdPD, pNomePD, pIdSoggPD, pIdAsps, pIdFruitore, pConfigurazioneAltroPorta,pIdTAb);
  6047.                                 image.setToolTip(MessageFormat.format(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE_TOOLTIP_CON_PARAMETRO,extendedServletList.getListTitle(this)));
  6048.                                 image.setImage(CostantiControlStation.ICONA_MODIFICA_CONFIGURAZIONE);
  6049.                                 de.setImage(image);
  6050.                             }
  6051.                             e.add(de);
  6052.                         }
  6053.                        
  6054.                         if(visualizzazioneTabs) {
  6055.                             // Proprieta Oggetto
  6056.                             this.addProprietaOggetto(e, pdAssociata.getProprietaOggetto());
  6057.                         }
  6058.                     }
  6059.                    
  6060.                     dati.add(e);
  6061.                     idTab ++;
  6062.                 }
  6063.             }

  6064.             this.pd.setDati(dati);
  6065.             if(visualizzazioneTabs) {
  6066.                 this.pd.setSelect(true);
  6067.                 if(showBottoneAggiungiNuovaConfigurazione) {
  6068.                     this.pd.setAddButton(true);
  6069.                 }
  6070.                 else {
  6071.                     this.pd.setAddButton(false);
  6072.                 }
  6073.                 if(lista.size() > 1)
  6074.                         this.pd.setRemoveButton(true);
  6075.                 else
  6076.                         this.pd.setRemoveButton(false);
  6077.             } else {
  6078.                 if(gestioneGruppi) {
  6079.                     if(listaSenzaFiltro!=null && listaSenzaFiltro.size()>1) {
  6080.                         this.pd.setRemoveButton(true);
  6081.                         this.pd.setSelect(true);
  6082.                     }
  6083.                     else {
  6084.                         this.pd.setRemoveButton(false);
  6085.                         this.pd.setSelect(false);
  6086.                     }
  6087.                     this.pd.setAddButton(true);
  6088.                 }
  6089.                 else {
  6090.                     this.pd.setAddButton(false);
  6091.                     this.pd.setRemoveButton(false);
  6092.                     this.pd.setSelect(false);
  6093.                 }
  6094.             }

  6095.         } catch (Exception e) {
  6096.             this.logError("Exception: " + e.getMessage(), e);
  6097.             throw new Exception(e);
  6098.         }
  6099.     }

  6100.     private boolean addInfoCorrelata(TipoOperazione tipoOp, String portType, boolean modificaAbilitata, String servcorr, String oldStato,
  6101.             String tipoProtocollo, ServiceBinding serviceBinding, List<DataElement> dati) throws DriverRegistroServiziNotFound, DriverRegistroServiziException {
  6102.         boolean isModalitaAvanzata = this.isModalitaAvanzata();
  6103.        
  6104.         boolean infoCorrelataShow = false;
  6105.        
  6106.         DataElement de = new DataElement();
  6107.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_SERVIZIO_CORRELATO);
  6108.         if( this.core.isShowCorrelazioneAsincronaInAccordi() &&
  6109.                 ( !isModalitaAvanzata || (portType!=null && !"".equals(portType) && !"-".equals(portType)) ) ){
  6110.             de.setType(DataElementType.HIDDEN);
  6111.         }
  6112.         else if( tipoOp.equals(TipoOperazione.ADD) || modificaAbilitata ){
  6113.             if(this.core.isProfiloDiCollaborazioneAsincronoSupportatoDalProtocollo(tipoProtocollo,serviceBinding)) {
  6114.                 de.setType(DataElementType.CHECKBOX);
  6115.                 infoCorrelataShow = true;
  6116.             }
  6117.             else {
  6118.                 de.setType(DataElementType.HIDDEN);
  6119.                 de.setValue(Costanti.CHECK_BOX_DISABLED);
  6120.             }
  6121.         }else{
  6122.             de.setType(DataElementType.HIDDEN);
  6123.         }
  6124.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_SERVIZIO_CORRELATO);
  6125.         if( this.core.isShowCorrelazioneAsincronaInAccordi() && ( !isModalitaAvanzata || (portType!=null && !"".equals(portType) && !"-".equals(portType)) ) ){
  6126.             if (  (servcorr != null) && ((servcorr.equals(Costanti.CHECK_BOX_ENABLED)) || servcorr.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_ABILITATO)) ) {
  6127.                 de.setValue(Costanti.CHECK_BOX_ENABLED);
  6128.             }
  6129.             else{
  6130.                 de.setValue(Costanti.CHECK_BOX_DISABLED);
  6131.             }
  6132.         }
  6133.         else if (  (servcorr != null) && ((servcorr.equals(Costanti.CHECK_BOX_ENABLED)) || servcorr.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_ABILITATO)) ) {
  6134.             if(tipoOp.equals(TipoOperazione.ADD) || modificaAbilitata){
  6135.                 de.setSelected(Costanti.CHECK_BOX_ENABLED);
  6136.             }else{
  6137.                 de.setValue(Costanti.CHECK_BOX_ENABLED);
  6138.             }
  6139.         }else{
  6140.             if(tipoOp.equals(TipoOperazione.CHANGE) && (this.isShowGestioneWorkflowStatoDocumenti()
  6141.                     &&  StatiAccordo.finale.toString().equals(oldStato) )){
  6142.                 de.setValue(Costanti.CHECK_BOX_DISABLED);
  6143.             }
  6144.         }
  6145.         dati.add(de);
  6146.        
  6147.         if( (tipoOp.equals(TipoOperazione.CHANGE) &&
  6148.                 (this.isShowGestioneWorkflowStatoDocumenti() &&  StatiAccordo.finale.toString().equals(oldStato) ))
  6149.                 ||
  6150.                 (this.core.isShowCorrelazioneAsincronaInAccordi() &&
  6151.                         ( !isModalitaAvanzata ||
  6152.                                 (portType!=null && !"".equals(portType) && !"-".equals(portType)) )) ){
  6153.             DataElement deLabel = new DataElement();
  6154.             deLabel.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPOLOGIA_SERVIZIO);
  6155.             deLabel.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_SERVIZIO_CORRELATO_LABEL);
  6156.             if (  (servcorr != null) && ((servcorr.equals(Costanti.CHECK_BOX_ENABLED)) || servcorr.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_ABILITATO)) ) {
  6157.                 deLabel.setValue(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_CORRELATO);
  6158.             }else{
  6159.                 deLabel.setValue(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_NORMALE);
  6160.             }
  6161.             if(this.core.isProfiloDiCollaborazioneAsincronoSupportatoDalProtocollo(tipoProtocollo,serviceBinding)){
  6162.                 deLabel.setType(DataElementType.TEXT);
  6163.                 infoCorrelataShow = true;
  6164.             } else {
  6165.                 deLabel.setType(DataElementType.HIDDEN);
  6166.             }
  6167.             dati.add(deLabel);
  6168.         }
  6169.        
  6170.         return infoCorrelataShow;
  6171.     }

  6172.     public List<DataElement> addServiziToDati(List<DataElement> dati, String nomeServizio, String tipoServizio, String oldNomeServizio, String oldTipoServizio,
  6173.             String provider, String tipoSoggetto, String nomeSoggetto, String[] soggettiList, String[] soggettiListLabel,
  6174.             String accordo, ServiceBinding serviceBinding, org.openspcoop2.protocol.manifest.constants.InterfaceType interfaceType, String[] accordiList, String[] accordiListLabel, String servcorr, BinaryParameter wsdlimpler,
  6175.             BinaryParameter wsdlimplfru, TipoOperazione tipoOp, String id, List<String> tipi, String profilo, String portType,
  6176.             String[] ptList, boolean privato, String uriAccordo,
  6177.             String descrizione, // porta sempre la descrizione dell'aps per l'hidden
  6178.             String descrizioneModificata, // porta la descrizione in corso di modifica
  6179.             long idSoggettoErogatore,
  6180.             String statoPackage,String oldStato,String versione,
  6181.             List<String> versioni,boolean validazioneDocumenti,
  6182.             String [] saSoggetti, String nomeSA, boolean generaPACheckSoggetto,
  6183.             List<AccordoServizioParteComune> asCompatibili,
  6184.             String controlloAccessiStato,
  6185.             String erogazioneRuolo,String erogazioneAutenticazione,String erogazioneAutenticazioneOpzionale, TipoAutenticazionePrincipal erogazioneAutenticazionePrincipal, List<String> erogazioneAutenticazioneParametroList, String erogazioneAutorizzazione, boolean erogazioneIsSupportatoAutenticazioneSoggetti,
  6186.             String erogazioneAutorizzazioneAutenticati, String erogazioneAutorizzazioneRuoli, String erogazioneAutorizzazioneRuoliTipologia, String erogazioneAutorizzazioneRuoliMatch,
  6187.             List<String> soggettiAutenticati, List<String> soggettiAutenticatiLabel, String soggettoAutenticato,
  6188.             String tipoProtocollo, List<String> listaTipiProtocollo,
  6189.             String[] soggettiFruitoriList, String[] soggettiFruitoriListLabel, String providerSoggettoFruitore, String tipoSoggettoFruitore, String nomeSoggettoFruitore,
  6190.             String fruizioneServizioApplicativo,String fruizioneRuolo,String fruizioneAutenticazione,String fruizioneAutenticazioneOpzionale, TipoAutenticazionePrincipal fruizioneAutenticazionePrincipal, List<String> fruizioneAutenticazioneParametroList, String fruizioneAutorizzazione,
  6191.             String fruizioneAutorizzazioneAutenticati,String fruizioneAutorizzazioneRuoli, String fruizioneAutorizzazioneRuoliTipologia, String fruizioneAutorizzazioneRuoliMatch,
  6192.             List<String> saList,String gestioneToken, String[] gestioneTokenPolicyLabels, String[] gestioneTokenPolicyValues,
  6193.             String gestioneTokenPolicy, String gestioneTokenOpzionale,
  6194.             String gestioneTokenValidazioneInput, String gestioneTokenIntrospection, String gestioneTokenUserInfo, String gestioneTokenForward,
  6195.             String autenticazioneTokenIssuer,String autenticazioneTokenClientId,String autenticazioneTokenSubject,String autenticazioneTokenUsername,String autenticazioneTokenEMail,
  6196.             String autorizzazioneToken, String autorizzazioneTokenOptions,
  6197.             String autorizzazioneScope,  String scope, String autorizzazioneScopeMatch,BinaryParameter allegatoXacmlPolicy,
  6198.             boolean moreThenOneImplementation, String canaleStato, String canaleAPI, String canale, List<CanaleConfigurazione> canaleList, boolean gestioneCanaliEnabled,
  6199.             String identificazioneAttributiStato, String[] attributeAuthorityLabels, String[] attributeAuthorityValues, String [] attributeAuthoritySelezionate, String attributeAuthorityAttributi,
  6200.             String autorizzazioneAutenticatiToken,
  6201.             String autorizzazioneRuoliToken,  String autorizzazioneRuoliTipologiaToken, String autorizzazioneRuoliMatchToken) throws Exception{

  6202.         String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  6203.         boolean gestioneFruitori = false;
  6204.         boolean gestioneErogatori = false;
  6205.         if(tipologia!=null) {
  6206.             if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  6207.                 gestioneFruitori = true;
  6208.             }
  6209.             else if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE.equals(tipologia)) {
  6210.                 gestioneErogatori = true;
  6211.             }
  6212.         }
  6213.        
  6214.         boolean confirmInProgress = false;
  6215.         if(moreThenOneImplementation) {
  6216.             DataElement de = new DataElement();
  6217.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_CONFERMA_MODIFICA_DATI_SERVIZIO);
  6218.             de.setValue("true");
  6219.             de.setType(DataElementType.HIDDEN);
  6220.             dati.add(de);
  6221.            
  6222.             if(this.getPostBackElementName()==null || "".equals(this.getPostBackElementName())) {
  6223.                 String tmp = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_CONFERMA_MODIFICA_DATI_SERVIZIO);
  6224.                 if(tmp!=null && !"".equals(tmp)) {
  6225.                     confirmInProgress = true;
  6226.                 }
  6227.             }
  6228.         }
  6229.        
  6230.         if(gestioneFruitori) {
  6231.            
  6232.             DataElement de = new DataElement();
  6233.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE);
  6234.             de.setValue(tipoSoggettoFruitore);
  6235.             de.setType(DataElementType.HIDDEN);
  6236.             dati.add(de);
  6237.            
  6238.             de = new DataElement();
  6239.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE);
  6240.             de.setValue(nomeSoggettoFruitore);
  6241.             de.setType(DataElementType.HIDDEN);
  6242.             dati.add(de);
  6243.         }
  6244.        
  6245.         String tmpModificaAPI = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_API);
  6246.         Boolean showModificaAPIErogazioniFruizioniView = null;
  6247.         if(tmpModificaAPI!=null) {
  6248.             showModificaAPIErogazioniFruizioniView = "true".equals(tmpModificaAPI);
  6249.        
  6250.             DataElement de = new DataElement();
  6251.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_API);
  6252.             de.setValue(tmpModificaAPI);
  6253.             de.setType(DataElementType.HIDDEN);
  6254.             dati.add(de);
  6255.         }
  6256.        
  6257.         String tmpCambiaAPI = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_CAMBIA_API);
  6258.         boolean cambiaAPI = false;
  6259.         if(tmpCambiaAPI!=null) {
  6260.             cambiaAPI = "true".equals(tmpCambiaAPI);
  6261.            
  6262.             DataElement de = new DataElement();
  6263.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_CAMBIA_API);
  6264.             de.setValue(tmpCambiaAPI);
  6265.             de.setType(DataElementType.HIDDEN);
  6266.             dati.add(de);
  6267.         }
  6268.        
  6269.         String tmpModificaDescrizione = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_DESCRIZIONE);
  6270.         boolean modificaDescrizione = false;
  6271.         if(tmpModificaDescrizione!=null) {
  6272.             modificaDescrizione = "true".equals(tmpModificaDescrizione);

  6273.             DataElement de = new DataElement();
  6274.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_DESCRIZIONE);
  6275.             de.setValue(tmpModificaDescrizione);
  6276.             de.setType(DataElementType.HIDDEN);
  6277.             dati.add(de);
  6278.         }
  6279.        
  6280.         String tmpCambiaErogatore = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_CAMBIA_SOGGETTO_EROGATORE);
  6281.         boolean cambiaErogatore = false;
  6282.         if(tmpCambiaErogatore!=null) {
  6283.             cambiaErogatore = "true".equals(tmpCambiaErogatore);
  6284.            
  6285.             DataElement de = new DataElement();
  6286.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_CAMBIA_SOGGETTO_EROGATORE);
  6287.             de.setValue(tmpCambiaErogatore);
  6288.             de.setType(DataElementType.HIDDEN);
  6289.             dati.add(de);
  6290.         }
  6291.        
  6292.         String tmpModificaProfilo = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_PROFILO);
  6293.         boolean modificaProfilo = false;
  6294.         if(tmpModificaProfilo!=null) {
  6295.             modificaProfilo = "true".equals(tmpModificaProfilo);
  6296.            
  6297.             DataElement de = new DataElement();
  6298.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_PROFILO);
  6299.             de.setValue(tmpModificaProfilo);
  6300.             de.setType(DataElementType.HIDDEN);
  6301.             dati.add(de);
  6302.         }
  6303.        
  6304.         Boolean showInformazioniGeneraliErogazioniFruizioniView = null;
  6305.         if(gestioneFruitori || gestioneErogatori) {
  6306.             if(showModificaAPIErogazioniFruizioniView!=null && showModificaAPIErogazioniFruizioniView) {
  6307.                 showInformazioniGeneraliErogazioniFruizioniView = false;
  6308.             }
  6309.             else if(modificaProfilo || cambiaAPI || cambiaErogatore || modificaDescrizione) {
  6310.                 showInformazioniGeneraliErogazioniFruizioniView = false;
  6311.                 showModificaAPIErogazioniFruizioniView = false; // forzo il false
  6312.             }
  6313.             else {
  6314.                 showInformazioniGeneraliErogazioniFruizioniView = true;
  6315.             }
  6316.         }
  6317.        
  6318.        
  6319.         String tipoServizioEffettivo = oldTipoServizio!=null ? oldTipoServizio : tipoServizio;
  6320.         String nomeServizioEffettivo = oldTipoServizio!=null ? oldNomeServizio : nomeServizio;
  6321.        
  6322.         String[] tipiLabel = new String[tipi.size()];
  6323.         for (int i = 0; i < tipi.size(); i++) {
  6324.             String nomeTipo = tipi.get(i);
  6325.             tipiLabel[i] = nomeTipo;
  6326.         }

  6327.         String[] versioniValues = new String[versioni.size()+1];
  6328.         String[] versioniLabel = new String[versioni.size()+1];
  6329.         versioniLabel[0] = AccordiServizioParteSpecificaCostanti.LABEL_APS_USA_VERSIONE_EROGATORE;
  6330.         versioniValues[0] = "-";
  6331.         for (int i = 0; i < versioni.size(); i++) {
  6332.             String tmp = versioni.get(i);
  6333.             versioniLabel[i+1] = tmp;
  6334.             versioniValues[i+1] = tmp;
  6335.         }

  6336.         User user = ServletUtils.getUserFromSession(this.request, this.session);

  6337.         boolean creaDataElementVersione = this.apsCore.isSupportatoVersionamentoAccordiServizioParteSpecifica(tipoProtocollo);
  6338.         boolean visualizzaSceltaVersioneServizio = creaDataElementVersione;
  6339.         if(this.isModalitaStandard() && TipoOperazione.ADD.equals(tipoOp)) {
  6340.             visualizzaSceltaVersioneServizio = false;
  6341.         }

  6342.         boolean modificaAbilitata = ( (!this.isShowGestioneWorkflowStatoDocumenti()) || (!StatiAccordo.finale.toString().equals(oldStato)) );

  6343.         boolean isModalitaAvanzata = this.isModalitaAvanzata();

  6344.         boolean ripristinoStatoOperativo = this.core.isGestioneWorkflowStatoDocumentiRipristinoStatoOperativoDaFinale();

  6345.         Boolean contaListeObject = ServletUtils.getContaListeFromSession(this.session);
  6346.         boolean contaListe = contaListeObject!=null && contaListeObject.booleanValue();


  6347.         // accordo di servizio parte comune

  6348.         boolean isAccordiCooperazione = user.getPermessi().isAccordiCooperazione();
  6349.         boolean isServizi = user.getPermessi().isServizi();

  6350.         String asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO;

  6351.         if(isServizi && !isAccordiCooperazione){
  6352.             asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO_SOLO_PARTE_COMUNE;
  6353.         }

  6354.         if(!isServizi  && isAccordiCooperazione){
  6355.             asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO_SOLO_COMPOSTO;
  6356.         }

  6357.         if(isServizi  && isAccordiCooperazione){
  6358.             asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO;
  6359.         }

  6360.         boolean showReferente = this.apcCore.isSupportatoSoggettoReferente(tipoProtocollo);
  6361.        
  6362.         boolean showPortiAccesso = false;
  6363.         if(serviceBinding!=null) {
  6364.             showPortiAccesso = this.apcCore.showPortiAccesso(tipoProtocollo, serviceBinding, interfaceType);
  6365.         }
  6366.        
  6367.         DataElement de = new DataElement();
  6368.         if(gestioneFruitori || gestioneErogatori) {
  6369.             if((showModificaAPIErogazioniFruizioniView!=null && showModificaAPIErogazioniFruizioniView) || cambiaAPI) {
  6370.                 de.setLabel(asLabel);
  6371.             }
  6372.             else if(modificaDescrizione){
  6373.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_DESCRIZIONE);
  6374.             }
  6375.             else {
  6376.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_INFO_GENERALI);
  6377.             }
  6378.         }
  6379.         else {
  6380.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_INFO_GENERALI);
  6381.         }
  6382.         if(modificaProfilo || cambiaErogatore) {
  6383.             de.setType(DataElementType.HIDDEN);
  6384.         }
  6385.         else {
  6386.             de.setType(DataElementType.TITLE);
  6387.         }
  6388.         dati.add(de);

  6389.         // Gestione del tipo protocollo per la maschera add
  6390.         de = new DataElement();
  6391.         if( TipoOperazione.ADD.equals(tipoOp) && (listaTipiProtocollo != null && listaTipiProtocollo.size() > 1)){
  6392.             de.setLabel(AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_PROTOCOLLO);
  6393.             de.setValues(listaTipiProtocollo);
  6394.             de.setLabels(this.getLabelsProtocolli(listaTipiProtocollo));
  6395.             de.setSelected(tipoProtocollo);
  6396.             de.setType(DataElementType.SELECT);
  6397.             de.setName(AccordiServizioParteComuneCostanti.PARAMETRO_APC_PROTOCOLLO);
  6398.             de.setPostBack_viaPOST(true);
  6399.         }else {
  6400.             de.setValue(tipoProtocollo);
  6401.             de.setType(DataElementType.HIDDEN);
  6402.             de.setName(AccordiServizioParteComuneCostanti.PARAMETRO_APC_PROTOCOLLO);
  6403.         }
  6404.         de.setSize(this.getSize());
  6405.         dati.add(de);
  6406.        
  6407.        
  6408.         // Selezione Soggetto Operativo
  6409.         if(gestioneFruitori) {
  6410.            
  6411.             boolean showSoggettoFruitoreInFruizioni = this.core.isMultitenant() &&
  6412.                     !this.isSoggettoMultitenantSelezionato();
  6413.            
  6414.             de = new DataElement();
  6415.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO_FRUITORE);
  6416.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE);
  6417.             if (tipoOp.equals(TipoOperazione.ADD) && showSoggettoFruitoreInFruizioni) {
  6418.                 de.setType(DataElementType.SELECT);
  6419.                 de.setValues(soggettiFruitoriList);
  6420.                 de.setLabels(soggettiFruitoriListLabel);
  6421.                 de.setPostBack_viaPOST(true);
  6422.                 de.setSelected(providerSoggettoFruitore);
  6423.                 dati.add(de);
  6424.             } else {
  6425.                 de.setValue(providerSoggettoFruitore);
  6426.                 de.setType(DataElementType.HIDDEN);
  6427.                 dati.add(de);
  6428.    
  6429.                 boolean showSoggettoInChange = false; // viene fatto vedere nella maschera riassuntiva
  6430.                 if(showSoggettoFruitoreInFruizioni && showSoggettoInChange) {
  6431.                     de = new DataElement();
  6432.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO_FRUITORE);
  6433.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE_AS_TEXT);
  6434.                     de.setType(DataElementType.TEXT);
  6435.                     de.setValue(this.getLabelNomeSoggetto(tipoProtocollo, tipoSoggettoFruitore, nomeSoggettoFruitore));
  6436.                     dati.add(de);
  6437.                 }
  6438.             }
  6439.         }
  6440.         else {
  6441.             // anche in modalità completa
  6442.            
  6443.             boolean showSoggettoErogatoreInErogazioni = this.core.isMultitenant() &&
  6444.                     !this.isSoggettoMultitenantSelezionato();
  6445.            
  6446.             de = new DataElement();
  6447.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO_EROGATORE);
  6448.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_EROGATORE);
  6449.             if (tipoOp.equals(TipoOperazione.ADD) && (showSoggettoErogatoreInErogazioni)) {
  6450.                 de.setType(DataElementType.SELECT);
  6451.                 de.setValues(soggettiList);
  6452.                 de.setLabels(soggettiListLabel);
  6453.                 de.setPostBack_viaPOST(true);
  6454.                 de.setSelected(provider);
  6455.                 dati.add(de);
  6456.             } else {
  6457.                 de.setValue(provider);
  6458.                 de.setType(DataElementType.HIDDEN);
  6459.                 dati.add(de);

  6460.                 boolean showSoggettoInChange = false; // viene fatto vedere nella maschera riassuntiva
  6461.                 if(!gestioneErogatori || (showSoggettoErogatoreInErogazioni && showSoggettoInChange)) {
  6462.                     de = new DataElement();
  6463.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_EROGATORE);
  6464.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_TEXT);
  6465.                     de.setType(DataElementType.TEXT);
  6466.                     de.setValue(this.getLabelNomeSoggetto(tipoProtocollo, tipoSoggetto, nomeSoggetto));
  6467.                     dati.add(de);
  6468.                 }
  6469.             }
  6470.         }
  6471.        
  6472.         if(this.isModalitaCompleta() || tipoOp.equals(TipoOperazione.ADD) || cambiaAPI) {
  6473.             de = new DataElement();
  6474.             de.setLabel(asLabel);
  6475.             de.setType(DataElementType.SUBTITLE);
  6476.             dati.add(de);
  6477.         }
  6478.        
  6479.         // Accordo
  6480.         IDAccordo idAccordoParteComune = null;
  6481.         boolean apiChanged = false;
  6482.         if(tipoOp.equals(TipoOperazione.ADD)){
  6483.             de = new DataElement();
  6484.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_NOME);
  6485.             de.setType(DataElementType.SELECT);
  6486.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ACCORDO);
  6487.             de.setValues(accordiList);
  6488.             de.setLabels(accordiListLabel);
  6489.             de.setPostBack_viaPOST(true);
  6490.             if (accordo != null)
  6491.                 de.setSelected(accordo);
  6492.            
  6493.             if(accordiListLabel.length>1) {
  6494.                 de.setRequired(true);
  6495.             }
  6496.             dati.add(de);
  6497.         }
  6498.         else if(cambiaAPI && accordiListLabel!=null && accordiListLabel.length>0) {
  6499.            
  6500.             de = new DataElement();
  6501.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_NOME_ATTUALE);
  6502.             de.setType(DataElementType.TEXT);
  6503.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ACCORDO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  6504.             de.setValue(accordiListLabel[0]);
  6505.             dati.add(de);
  6506.            
  6507.             if(accordiListLabel.length>1) {
  6508.                 String [] newAccordi = new String[accordiListLabel.length];
  6509.                 String [] newAccordiLabel = new String[accordiListLabel.length];
  6510.                 for (int i = 0; i < accordiListLabel.length; i++) {
  6511.                     newAccordi[i] = accordiList[i];
  6512.                     if(i>0) {
  6513.                         newAccordiLabel[i] = accordiListLabel[i];
  6514.                     }
  6515.                     else {
  6516.                         newAccordiLabel[i] = "-";
  6517.                     }
  6518.                 }
  6519.                
  6520.                 de = new DataElement();
  6521.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_NOME_NUOVO);
  6522.                 de.setType(DataElementType.SELECT);
  6523.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ACCORDO);
  6524.                 de.setValues(newAccordi);
  6525.                 de.setLabels(newAccordiLabel);
  6526.                 de.setPostBack(true);
  6527.                 if (accordo != null)
  6528.                     de.setSelected(accordo);
  6529.                 dati.add(de);
  6530.             }
  6531.             else {
  6532.                 de = new DataElement();
  6533.                 de.setType(DataElementType.HIDDEN);
  6534.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ACCORDO);
  6535.                 de.setValue(accordo);
  6536.                 dati.add(de);
  6537.             }
  6538.            
  6539.             if(accordo!=null) {
  6540.                 for (int i = 0; i < accordiList.length; i++) {
  6541.                     if(accordo.equals(accordiList[i])) {
  6542.                         apiChanged = i>0;
  6543.                         break;
  6544.                     }
  6545.                 }
  6546.             }
  6547.         }
  6548.         else{
  6549.             if(!modificaAbilitata ||
  6550.                     (asCompatibili==null || asCompatibili.size()<=1) ||
  6551.                     (showModificaAPIErogazioniFruizioniView!=null && !showModificaAPIErogazioniFruizioniView)){
  6552.                 de = new DataElement();
  6553.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO);
  6554.                 de.setType(DataElementType.HIDDEN);
  6555.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ACCORDO);
  6556.                 de.setValue(accordo);
  6557.                 dati.add(de);
  6558.             }
  6559.                
  6560.             idAccordoParteComune = this.idAccordoFactory.getIDAccordoFromUri(uriAccordo);
  6561.            
  6562.             de = new DataElement();
  6563.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_REFERENTE);
  6564.             if(showReferente && (showModificaAPIErogazioniFruizioniView==null || showModificaAPIErogazioniFruizioniView)) {
  6565.                 de.setType(DataElementType.TEXT);
  6566.             }
  6567.             else {
  6568.                 de.setType(DataElementType.HIDDEN);
  6569.             }
  6570.             de.setName(CostantiControlStation.PARAMETRO_PREFIX+AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_REFERENTE );
  6571.             de.setValue(idAccordoParteComune.getSoggettoReferente().toString());
  6572.             dati.add(de);
  6573.            
  6574.             de = new DataElement();
  6575.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_NOME);
  6576.             if(showModificaAPIErogazioniFruizioniView==null || showModificaAPIErogazioniFruizioniView) {
  6577.                 de.setType(DataElementType.TEXT);
  6578.             }
  6579.             else {
  6580.                 de.setType(DataElementType.HIDDEN);
  6581.             }
  6582.             de.setName(CostantiControlStation.PARAMETRO_PREFIX+AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_NOME );
  6583.             de.setValue(idAccordoParteComune.getNome());
  6584.             dati.add(de);
  6585.            
  6586.             de = new DataElement();
  6587.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_VERSIONE);
  6588.             if(!modificaAbilitata ||
  6589.                     (asCompatibili==null || asCompatibili.size()<=1) ||
  6590.                     (showModificaAPIErogazioniFruizioniView!=null && !showModificaAPIErogazioniFruizioniView)){
  6591.                 if((showModificaAPIErogazioniFruizioniView!=null && !showModificaAPIErogazioniFruizioniView)) {
  6592.                     de.setType(DataElementType.HIDDEN);
  6593.                 }
  6594.                 else {
  6595.                     de.setType(DataElementType.TEXT);
  6596.                 }
  6597.                 de.setName(CostantiControlStation.PARAMETRO_PREFIX+AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_VERSIONE );
  6598.                 if(idAccordoParteComune.getVersione()!=null)
  6599.                     de.setValue(idAccordoParteComune.getVersione().intValue()+"");
  6600.             }
  6601.             else{
  6602.                 String [] accordiCompatibiliList = new String[asCompatibili.size()];
  6603.                 String [] accordiCompatibiliLabelList = new String[asCompatibili.size()];
  6604.                 for (int i = 0; i < asCompatibili.size(); i++) {
  6605.                     accordiCompatibiliList[i] = asCompatibili.get(i).getId() + "";
  6606.                     if(asCompatibili.get(i).getVersione()!=null){
  6607.                         accordiCompatibiliLabelList[i] = asCompatibili.get(i).getVersione().intValue()+"";
  6608.                     }
  6609.                 }
  6610.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ACCORDO);
  6611.                 if(showModificaAPIErogazioniFruizioniView==null || showModificaAPIErogazioniFruizioniView) {
  6612.                     if(confirmInProgress) {
  6613.                         de.setType(DataElementType.HIDDEN);
  6614.                        
  6615.                         DataElement deLabel = new DataElement();
  6616.                         deLabel.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_VERSIONE);
  6617.                         deLabel.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ACCORDO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  6618.                         deLabel.setType(DataElementType.TEXT);
  6619.                         for (int i = 0; i < accordiCompatibiliList.length; i++) {
  6620.                             if(accordo.equals(accordiCompatibiliList[i])) {
  6621.                                 deLabel.setValue(accordiCompatibiliLabelList[i]);
  6622.                                 break;
  6623.                             }
  6624.                         }
  6625.                         dati.add(deLabel);
  6626.                     }
  6627.                     else {
  6628.                         de.setType(DataElementType.SELECT);
  6629.                         de.setValues(accordiCompatibiliList);
  6630.                         de.setLabels(accordiCompatibiliLabelList);
  6631.                         // Lasciare il postback, l'evento serve ad allineare la versione dell'API con la versione del servizio in automatico
  6632.                         de.setPostBack(true);
  6633.                         de.setSelected(accordo);
  6634.                     }
  6635.                 }
  6636.                 else {
  6637.                     de.setType(DataElementType.HIDDEN);
  6638.                 }
  6639.                 de.setValue(accordo);
  6640.             }
  6641.             dati.add(de);
  6642.            
  6643.         }

  6644.         if(serviceBinding != null) {
  6645.             switch(serviceBinding) {
  6646.             case REST:
  6647.                
  6648.                 if(showModificaAPIErogazioniFruizioniView==null || showModificaAPIErogazioniFruizioniView) {
  6649.                     de = new DataElement();
  6650.                     de.setType(DataElementType.TEXT);
  6651.                     de.setLabel(AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_SERVICE_BINDING);
  6652.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PORT_TYPE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  6653.                     de.setValue(CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_REST);
  6654.                     dati.add(de);
  6655.                 }
  6656.                
  6657.                 //Servizio (portType)  nascosto nel caso REST
  6658.                 de = new DataElement();
  6659.                 de.setType(DataElementType.HIDDEN);
  6660.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PORT_TYPE);
  6661.                 de.setValue(portType);
  6662.                 dati.add(de);
  6663.                 break;
  6664.             case SOAP:
  6665.             default:
  6666.                
  6667.                 if(showModificaAPIErogazioniFruizioniView==null || showModificaAPIErogazioniFruizioniView) {
  6668.                     de = new DataElement();
  6669.                     de.setType(DataElementType.TEXT);
  6670.                     de.setLabel(AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_SERVICE_BINDING);
  6671.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PORT_TYPE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  6672.                     de.setValue(CostantiControlStation.LABEL_PARAMETRO_SERVICE_BINDING_SOAP);
  6673.                     dati.add(de);
  6674.                 }
  6675.                
  6676.                 //Servizio (portType)  visibile nel caso SOAP
  6677.                 if (ptList != null) {
  6678.                     if(tipoOp.equals(TipoOperazione.ADD) || modificaAbilitata || apiChanged){
  6679.                         de = new DataElement();
  6680.                         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SERVIZIO);
  6681.                         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PORT_TYPE);
  6682.                         if(showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView || apiChanged) {
  6683.                             if(showInformazioniGeneraliErogazioniFruizioniView!=null) {
  6684.                                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SERVIZIO_SOAP);            
  6685.                             }
  6686.                             de.setType(DataElementType.SELECT);
  6687.                             de.setValues(ptList);
  6688.                             de.setLabels(ptList);
  6689.                             de.setSelected(portType);
  6690.                             if(tipoOp.equals(TipoOperazione.ADD)) {
  6691.                                 de.setPostBack_viaPOST(true);
  6692.                             }
  6693.                             else {
  6694.                                 de.setPostBack(true);
  6695.                             }
  6696.                             if (!isModalitaAvanzata || this.apsCore.isPortTypeObbligatorioImplementazioniSOAP()) {
  6697.                                 de.setRequired(true);
  6698.                             }
  6699.                         }
  6700.                         else {
  6701.                             if(showModificaAPIErogazioniFruizioniView!=null && showModificaAPIErogazioniFruizioniView) {
  6702.                                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SERVIZIO_SOAP);            
  6703.                                 de.setType(DataElementType.TEXT);
  6704.                             }
  6705.                             else {
  6706.                                 de.setType(DataElementType.HIDDEN);
  6707.                             }
  6708.                             de.setValue(portType);
  6709.                         }
  6710.                         dati.add(de);
  6711.                     }else{
  6712.                         de = new DataElement();
  6713.                         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SERVIZIO);
  6714.                         de.setType(DataElementType.HIDDEN);
  6715.                         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PORT_TYPE);
  6716.                         de.setValue(portType);
  6717.                         dati.add(de);
  6718.    
  6719.                         de = new DataElement();
  6720.                         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SERVIZIO);
  6721.                         if(showModificaAPIErogazioniFruizioniView==null || showModificaAPIErogazioniFruizioniView) {
  6722.                             de.setType(DataElementType.TEXT);
  6723.                         }
  6724.                         else {
  6725.                             de.setType(DataElementType.HIDDEN);
  6726.                         }
  6727.                         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PORT_TYPE_LABEL);
  6728.                         de.setValue(portType);
  6729.                         dati.add(de);
  6730.                     }
  6731.                 }else{
  6732.                     de = new DataElement();
  6733.                     de.setType(DataElementType.HIDDEN );
  6734.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PORT_TYPE);
  6735.                     dati.add(de);
  6736.                 }
  6737.                
  6738.                 break;
  6739.             }
  6740.         }

  6741.        

  6742.         //Sezione Servizio

  6743.         List<DataElement> datiCorrelati = new ArrayList<>();
  6744.         boolean showInfoCorrelata = false;
  6745.         if(serviceBinding != null) {
  6746.             showInfoCorrelata = this.addInfoCorrelata(tipoOp, portType, modificaAbilitata, servcorr, oldStato, tipoProtocollo, serviceBinding, datiCorrelati);
  6747.         }
  6748.        
  6749.         boolean modificaAbilitataOrOperazioneAdd = tipoOp.equals(TipoOperazione.ADD) || modificaAbilitata;
  6750.        
  6751.         boolean showSceltaNomeServizioDisabilitata =false;
  6752.         if(TipoOperazione.ADD.equals(tipoOp)) {
  6753.             if(!isModalitaAvanzata) {
  6754.                 showSceltaNomeServizioDisabilitata = true;
  6755.             }
  6756.         }
  6757.         else {
  6758.             // change
  6759.             if(gestioneErogatori || gestioneFruitori) {
  6760.                 showSceltaNomeServizioDisabilitata = false; // lo vogliamo poter modificare sempre
  6761.             }
  6762.             else {
  6763.                 if( (!isModalitaAvanzata)
  6764.                         &&
  6765.                     (
  6766.                         (ServiceBinding.SOAP.equals(serviceBinding) && nomeServizio!=null && nomeServizio.equals(portType))
  6767.                         ||
  6768.                         (ServiceBinding.REST.equals(serviceBinding) && nomeServizio!=null && nomeServizio.equals(idAccordoParteComune.getNome())))
  6769.                     ){
  6770.                     showSceltaNomeServizioDisabilitata = true;
  6771.                 }
  6772.             }
  6773.         }
  6774.        
  6775.        
  6776.         boolean showFlagPrivato = this.core.isShowFlagPrivato() &&  (tipoOp.equals(TipoOperazione.ADD) ||
  6777.                 modificaAbilitata) && isModalitaAvanzata;
  6778.        
  6779.         boolean showFlagPrivatoLabel = this.core.isShowFlagPrivato() && tipoOp.equals(TipoOperazione.CHANGE ) &&
  6780.             (this.isShowGestioneWorkflowStatoDocumenti() &&
  6781.                     StatiAccordo.finale.toString().equals(oldStato) ) &&
  6782.                     isModalitaAvanzata;
  6783.        
  6784.         boolean showTipoServizio = (this.apsCore.getTipiServiziGestitiProtocollo(tipoProtocollo,serviceBinding).size()>1);
  6785.        
  6786.         boolean showVersioneProtocollo = modificaAbilitataOrOperazioneAdd && (this.apsCore.getVersioniProtocollo(tipoProtocollo).size()>1);
  6787.        
  6788.        
  6789.         boolean showLabelServizio = this.isModalitaAvanzata() ||
  6790.                 showTipoServizio ||
  6791.                 (!showSceltaNomeServizioDisabilitata) ||
  6792.                 visualizzaSceltaVersioneServizio ||
  6793.                 showInfoCorrelata ||
  6794.                 showFlagPrivato ||
  6795.                 showFlagPrivatoLabel ||
  6796.                 showVersioneProtocollo ||
  6797.                 (this.isShowGestioneWorkflowStatoDocumenti() && (TipoOperazione.CHANGE.equals(tipoOp) || this.isModalitaAvanzata()));
  6798.        
  6799.         if(showLabelServizio &&
  6800.                 showInformazioniGeneraliErogazioniFruizioniView==null){
  6801.             de = new DataElement();
  6802.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SERVIZIO);
  6803.             de.setType(DataElementType.SUBTITLE);
  6804.             dati.add(de);
  6805.         }

  6806.         if(isModalitaCompleta()) {
  6807.            
  6808.             de = new DataElement();
  6809.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_DESCRIZIONE);
  6810.             de.setType(DataElementType.TEXT_AREA);
  6811.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_DESCRIZIONE);
  6812.             de.setSize(getSize());
  6813.             de.setValue(descrizione!=null ? StringEscapeUtils.escapeHtml(descrizione) : "");
  6814.             if( !modificaAbilitata && StringUtils.isBlank(descrizione))
  6815.                 de.setValue("");
  6816.            
  6817.             dati.add(de);
  6818.            
  6819.         }
  6820.         else{
  6821.            
  6822.             de = new DataElement();
  6823.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_DESCRIZIONE);
  6824.             de.setType(DataElementType.HIDDEN);
  6825.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_DESCRIZIONE);
  6826.             de.setSize(getSize());
  6827.             de.setValue(descrizione!=null ? StringEscapeUtils.escapeHtml(descrizione) : "");
  6828.             if( !modificaAbilitata && (descrizione==null || "".equals(descrizione)) )
  6829.                 de.setValue(" ");
  6830.             dati.add(de);
  6831.            
  6832.         }
  6833.        
  6834.        
  6835.         if(!isModalitaCompleta() && modificaDescrizione) {
  6836.            
  6837.             de = new DataElement();
  6838.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_DESCRIZIONE);
  6839.             if(modificaAbilitata) {
  6840.                 de.setType(DataElementType.TEXT_AREA);
  6841.                 de.setRows(CostantiControlStation.TEXT_AREA_DESCRIZIONE_ROWS);
  6842.                 de.setLabel(CostantiControlStation.LABEL_PROPRIETA_DESCRIZIONE_EMPTY);
  6843.             }
  6844.             else {
  6845.                 de.setType(DataElementType.TEXT_EDIT);
  6846.             }
  6847.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_DESCRIZIONE_MODIFICA);
  6848.             de.setSize(getSize());
  6849.             de.setValue(descrizioneModificata!=null ? StringEscapeUtils.escapeHtml(descrizioneModificata) : "");
  6850.             if( !modificaAbilitata && StringUtils.isBlank(descrizioneModificata))
  6851.                 de.setValue("");
  6852.            
  6853.             dati.add(de);
  6854.            
  6855.         }
  6856.        


  6857.         if(showTipoServizio) {
  6858.             if(modificaAbilitataOrOperazioneAdd){
  6859.                 de = new DataElement();
  6860.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPO  );
  6861.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO);
  6862.                 if((showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView)) {
  6863.                     de.setValues(tipiLabel);
  6864.                     de.setSelected(tipoServizio);
  6865.                     de.setType(DataElementType.SELECT);
  6866.                     de.setSize(this.getSize());
  6867.                     if(tipoOp.equals(TipoOperazione.ADD)) {
  6868.                         de.setPostBack_viaPOST(true);
  6869.                     }
  6870.                 }
  6871.                 else {
  6872.                     de.setType(DataElementType.HIDDEN);
  6873.                     de.setValue(tipoServizio);
  6874.                 }
  6875.                 dati.add(de);
  6876.             }else{
  6877.                 de = new DataElement();
  6878.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPO);
  6879.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO);
  6880.                 de.setValue(tipoServizio);
  6881.                 if((showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView)) {
  6882.                     de.setType(DataElementType.TEXT);
  6883.                 }
  6884.                 else {
  6885.                     de.setType(DataElementType.HIDDEN);
  6886.                 }
  6887.                 dati.add(de);
  6888.             }
  6889.         }else{
  6890.             de = new DataElement();
  6891.             de.setValue(tipoServizio);
  6892.             de.setType(DataElementType.HIDDEN);
  6893.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPO);
  6894.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO);
  6895.             dati.add(de);
  6896.         }


  6897.         if(!showSceltaNomeServizioDisabilitata && cambiaAPI) {
  6898.             de = new DataElement();
  6899.             if(gestioneErogatori) {
  6900.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SINGOLO);
  6901.             }
  6902.             if(gestioneFruitori) {
  6903.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORE);
  6904.             }
  6905.             de.setType(DataElementType.SUBTITLE);
  6906.             dati.add(de);
  6907.         }
  6908.        
  6909.         if (showSceltaNomeServizioDisabilitata ) {
  6910.             de = new DataElement();
  6911.             if (nomeServizio == null) {
  6912.                 de.setValue("");
  6913.             } else {
  6914.                 de.setValue(nomeServizio);
  6915.             }
  6916.             de.setType(DataElementType.HIDDEN);
  6917.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO  );
  6918.             dati.add(de);
  6919.         } else {
  6920.             de = new DataElement();
  6921.             if(tipoOp.equals(TipoOperazione.ADD) && isModalitaAvanzata() && (gestioneFruitori || gestioneErogatori)){
  6922.                 if(gestioneErogatori) {
  6923.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_NOME_EROGAZIONE);
  6924.                 }
  6925.                 else {
  6926.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_NOME_FRUIZIONE);
  6927.                 }
  6928.             }
  6929.             else {
  6930.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_NOME_FILE);
  6931.             }
  6932.             if (nomeServizio == null) {
  6933.                 de.setValue("");
  6934.             } else {
  6935.                 de.setValue(nomeServizio);
  6936.             }
  6937.             if((showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView) || cambiaAPI ) {
  6938.                 if(cambiaAPI && !apiChanged) { // else rientrano in modificaAbilitata
  6939.                     de.setType(DataElementType.TEXT);
  6940.                 }
  6941.                 else if(tipoOp.equals(TipoOperazione.ADD) || modificaAbilitata){
  6942.                     de.setType(DataElementType.TEXT_EDIT);
  6943.                     de.setRequired(true);
  6944.                    
  6945.                     // se non ho selezionato l'accordo non faccio vedere la textedit non ha senso
  6946.                     if (accordo == null || accordo.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PARAMETRO_ACCORDO_NON_SELEZIONATO)) {
  6947.                         de.setType(DataElementType.HIDDEN);
  6948.                         de.setRequired(false);
  6949.                     }
  6950.                 }else{
  6951.                     de.setType(DataElementType.TEXT);
  6952.                 }
  6953.             }
  6954.             else {
  6955.                 de.setType(DataElementType.HIDDEN);
  6956.             }
  6957.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO  );
  6958.             de.setSize(this.getSize());
  6959.             dati.add(de);
  6960.         }
  6961.        
  6962.         if(uriAccordo != null && creaDataElementVersione){

  6963.             de = new DataElement();
  6964.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VERSIONE);
  6965.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VERSIONE);
  6966.             String versioneSelezionata = ((versione==null || "".equals(versione)) ? "1" : versione);
  6967.             if(idAccordoParteComune==null) {
  6968.                 idAccordoParteComune = this.idAccordoFactory.getIDAccordoFromUri(uriAccordo);
  6969.             }
  6970.             if( TipoOperazione.ADD.equals(tipoOp) && this.isModalitaStandard() ) {
  6971.                 versioneSelezionata = idAccordoParteComune.getVersione().intValue()+"";
  6972.             }
  6973.             boolean versioneAllineataAccordoParteComune = false;
  6974.             if(TipoOperazione.CHANGE.equals(tipoOp) && !cambiaAPI) {
  6975.                 versioneAllineataAccordoParteComune = (idAccordoParteComune.getVersione().intValue()+"").equals(versioneSelezionata); // modifica gestita in servlet chage, vedi postback PARAMETRO_APS_ACCORDO
  6976.             }
  6977.            
  6978.             de.setValue(versioneSelezionata);
  6979.             if(visualizzaSceltaVersioneServizio){
  6980.                 if((showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView) || cambiaAPI ) {
  6981.                     if(cambiaAPI && !apiChanged) { // else rientrano in modificaAbilitata
  6982.                         de.setType(DataElementType.TEXT);
  6983.                     }
  6984.                     else if( modificaAbilitata ){
  6985.                         if(this.isModalitaStandard() && versioneAllineataAccordoParteComune) {
  6986.                             de.setType(DataElementType.HIDDEN);
  6987.                         }
  6988.                         else {
  6989.                             de = this.getVersionDataElement(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VERSIONE,
  6990.                                     AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VERSIONE,
  6991.                                     versioneSelezionata, false);
  6992.                         }
  6993.                     }else{
  6994.                         de.setType(DataElementType.TEXT);
  6995.                     }
  6996.                 }
  6997.                 else{
  6998.                     de.setType(DataElementType.HIDDEN);
  6999.                 }
  7000.             }else{
  7001.                 de.setType(DataElementType.HIDDEN);
  7002.             }
  7003.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VERSIONE);
  7004.             dati.add(de);
  7005.            
  7006.         }
  7007.        
  7008.         if((showInformazioniGeneraliErogazioniFruizioniView!=null && !showInformazioniGeneraliErogazioniFruizioniView)) {
  7009.             for (DataElement dataElement : datiCorrelati) {
  7010.                 dataElement.setType(DataElementType.HIDDEN);
  7011.             }
  7012.         }
  7013.         dati.addAll(datiCorrelati);

  7014.         de = new DataElement();
  7015.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PRIVATO);
  7016.         if (showFlagPrivato && (showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView)) {
  7017.             de.setType(DataElementType.CHECKBOX);
  7018.             de.setSelected(privato ? Costanti.CHECK_BOX_ENABLED : "");
  7019.         } else {
  7020.             de.setType(DataElementType.HIDDEN);
  7021.             de.setValue(privato ? Costanti.CHECK_BOX_ENABLED : "");
  7022.         }
  7023.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PRIVATO);
  7024.         dati.add(de);

  7025.         if(showFlagPrivatoLabel && (showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView)){
  7026.             de = new DataElement();
  7027.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VISIBILITA_SERVIZIO);
  7028.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PRIVATO_LABEL);
  7029.             if(privato){
  7030.                 de.setValue(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PRIVATA);
  7031.             }else{
  7032.                 de.setValue(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PUBBLICA);
  7033.             }
  7034.             dati.add(de);
  7035.         }

  7036.        
  7037.         de = new DataElement();
  7038.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VERSIONE_PROTOCOLLO);
  7039.         if(showVersioneProtocollo && (showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView)){
  7040.             if(tipoOp.equals(TipoOperazione.ADD) || modificaAbilitata){
  7041.                 de.setValues(versioniValues);
  7042.                 de.setLabels(versioniLabel);
  7043.                 if(profilo==null){
  7044.                     profilo="-";
  7045.                 }
  7046.                 de.setSelected(profilo);
  7047.                 de.setType(DataElementType.SELECT);
  7048.             }else{
  7049.                 de.setType(DataElementType.TEXT);
  7050.                 de.setValue(profilo);
  7051.                 if( profilo==null || "".equals(profilo) )
  7052.                     de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_APS_USA_VERSIONE_EROGATORE);
  7053.             }
  7054.         }else {
  7055.             de.setType(DataElementType.HIDDEN);
  7056.             if(profilo==null){
  7057.                 profilo="-";
  7058.             }
  7059.             de.setValue(profilo);
  7060.         }
  7061.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROFILO);
  7062.         de.setSize(this.getSize());
  7063.         dati.add(de);
  7064.        
  7065.        
  7066.         // Gestione canali
  7067.         if(gestioneCanaliEnabled) {
  7068.             if( tipoOp.equals(TipoOperazione.ADD)) {
  7069.                 DataElement dataElement = new DataElement();
  7070.                 dataElement.setLabel(CostantiControlStation.LABEL_CONFIGURAZIONE_CANALE);
  7071.                 dataElement.setType(DataElementType.SUBTITLE);
  7072.                 dati.add(dataElement);
  7073.                
  7074.                 this.addCanaleToDati(dati, tipoOp, canaleStato, canale, canaleAPI, canaleList, gestioneCanaliEnabled, false);
  7075.             } else {
  7076.                 // sono dati delle porte applicative/delegate inserisco hidden i valori che mi vengono passati
  7077.                 this.addCanaleToDatiAsHidden(dati, tipoOp, canaleStato, canale, gestioneCanaliEnabled);
  7078.             }
  7079.         }

  7080.        
  7081.         // Modalita' standard faccio vedere lo stato
  7082.         // stato
  7083.         if(isModalitaAvanzata){

  7084.             de = new DataElement();
  7085.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  7086.             if(this.isShowGestioneWorkflowStatoDocumenti()){
  7087.                 if( tipoOp.equals(TipoOperazione.ADD) ||
  7088.                         (!StatiAccordo.finale.toString().equals(oldStato) &&
  7089.                                 (showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView)) ){
  7090.                     de.setType(DataElementType.SELECT);
  7091.                     de.setValues(StatiAccordo.toArray());
  7092.                     de.setLabels(StatiAccordo.toLabel());
  7093.                     de.setSelected(statoPackage);
  7094.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO_PACKAGE);
  7095.                 }else{
  7096.                    
  7097.                     if(showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView) {
  7098.                         DataElement deLabel = new DataElement();
  7099.                         deLabel.setType(DataElementType.TEXT);
  7100.                         deLabel.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  7101.                         deLabel.setValue(StatiAccordo.upper(StatiAccordo.finale.toString()));
  7102.                         deLabel.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO_PACKAGE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  7103.                         dati.add(deLabel);
  7104.                     }
  7105.                    
  7106.                     de.setType(DataElementType.HIDDEN);
  7107.                     de.setValue(StatiAccordo.finale.toString());
  7108.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO_PACKAGE);

  7109.                     if(ripristinoStatoOperativo){
  7110.                         dati.add(de);

  7111.                         if(showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView) {
  7112.                             de = new DataElement();
  7113.                             de.setType(DataElementType.LINK);
  7114.    
  7115.                             Parameter pIdsoggErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, idSoggettoErogatore + "");
  7116.                             Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, nomeServizioEffettivo);
  7117.                             Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, tipoServizioEffettivo);
  7118.    
  7119.                             de.setUrl(
  7120.                                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE,
  7121.                                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id),
  7122.                                     pNomeServizio, pTipoServizio, pIdsoggErogatore,new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_RIPRISTINA_STATO, StatiAccordo.operativo.toString()),
  7123.                                     new Parameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME, Costanti.DATA_ELEMENT_EDIT_MODE_VALUE_EDIT_IN_PROGRESS));
  7124.                             de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_RIPRISTINA_STATO_OPERATIVO);
  7125.                         }
  7126.                     }
  7127.                 }
  7128.             }else{
  7129.                 de.setType(DataElementType.HIDDEN);
  7130.                 de.setValue(StatiAccordo.finale.toString());
  7131.                 de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO_PACKAGE);
  7132.             }

  7133.             dati.add(de);

  7134.         }
  7135.        
  7136.         else{
  7137.            
  7138.             de = new DataElement();
  7139.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  7140.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO_PACKAGE);
  7141.             if(this.isShowGestioneWorkflowStatoDocumenti()){
  7142.                 if(tipoOp.equals(TipoOperazione.ADD)){
  7143.                     de.setType(DataElementType.HIDDEN);
  7144.                     de.setValue(statoPackage);
  7145.                 }else if(
  7146.                         (!StatiAccordo.finale.toString().equals(oldStato)) &&
  7147.                         (showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView) ){
  7148.                     de.setType(DataElementType.SELECT);
  7149.                     de.setValues(StatiAccordo.toArray());
  7150.                     de.setLabels(StatiAccordo.toLabel());
  7151.                     de.setSelected(statoPackage);
  7152.                 }else{
  7153.                    
  7154.                     if(showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView) {
  7155.                         DataElement deLabel = new DataElement();
  7156.                         deLabel.setType(DataElementType.TEXT);
  7157.                         deLabel.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  7158.                         deLabel.setValue(StatiAccordo.upper(StatiAccordo.finale.toString()));
  7159.                         deLabel.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO_PACKAGE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  7160.                         dati.add(deLabel);
  7161.                     }
  7162.                    
  7163.                     de.setType(DataElementType.HIDDEN);
  7164.                     de.setValue(StatiAccordo.finale.toString());

  7165.                     if(ripristinoStatoOperativo){
  7166.                         dati.add(de);

  7167.                         if(showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView) {
  7168.                             de = new DataElement();
  7169.                             de.setType(DataElementType.LINK);
  7170.    
  7171.                             Parameter pIdsoggErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, idSoggettoErogatore + "");
  7172.                             Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, nomeServizioEffettivo);
  7173.                             Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, tipoServizioEffettivo);
  7174.    
  7175.                             de.setUrl(
  7176.                                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE,
  7177.                                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id),
  7178.                                     pNomeServizio, pTipoServizio, pIdsoggErogatore,new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_RIPRISTINA_STATO, StatiAccordo.operativo.toString()),
  7179.                                     new Parameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME, Costanti.DATA_ELEMENT_EDIT_MODE_VALUE_EDIT_IN_PROGRESS));
  7180.                             de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_RIPRISTINA_STATO_OPERATIVO);
  7181.                         }
  7182.                     }
  7183.                 }              
  7184.             }else{
  7185.                 de.setType(DataElementType.HIDDEN);
  7186.                 de.setValue(StatiAccordo.finale.toString());
  7187.             }

  7188.             dati.add(de);
  7189.         }
  7190.        
  7191.        
  7192.        
  7193.         //Sezione Soggetto Erogatore (provider)

  7194.         if(gestioneFruitori) {
  7195.            
  7196.             boolean showSoggettoInChange = false; // viene fatto vedere nella maschera riassuntiva
  7197.            
  7198.             if (tipoOp.equals(TipoOperazione.ADD) || showSoggettoInChange) {
  7199.                 de = new DataElement();
  7200.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO_EROGATORE);
  7201.                 de.setType(DataElementType.SUBTITLE);
  7202.                 dati.add(de);
  7203.             }

  7204.             de = new DataElement();
  7205.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_EROGATORE);
  7206.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_EROGATORE);
  7207.             if (tipoOp.equals(TipoOperazione.ADD)) {
  7208.                 de.setType(DataElementType.SELECT);
  7209.                 de.setValues(soggettiList);
  7210.                 de.setLabels(soggettiListLabel);
  7211.                 de.setPostBack_viaPOST(true);
  7212.                 de.setSelected(provider);
  7213.                 dati.add(de);
  7214.             } else {
  7215.                 de.setValue(provider);
  7216.                 de.setType(DataElementType.HIDDEN);
  7217.                 dati.add(de);
  7218.    
  7219.                 if(showSoggettoInChange) {
  7220.                     de = new DataElement();
  7221.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_EROGATORE);
  7222.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_TEXT);
  7223.                     de.setType(DataElementType.TEXT);
  7224.                     de.setValue(this.getLabelNomeSoggetto(tipoProtocollo, tipoSoggetto, nomeSoggetto));
  7225.                     dati.add(de);
  7226.                 }
  7227.             }
  7228.         }
  7229.        
  7230.         if(cambiaErogatore) {
  7231.            
  7232.             de = new DataElement();
  7233.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO_EROGATORE);
  7234.             de.setType(DataElementType.TITLE);
  7235.             dati.add(de);
  7236.            
  7237.             de = new DataElement();
  7238.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_EROGATORE);
  7239.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_CAMBIO_EROGATORE);
  7240.             if(confirmInProgress) {
  7241.                 de.setType(DataElementType.HIDDEN);
  7242.                 de.setValue(provider);
  7243.             }
  7244.             else {
  7245.                 de.setType(DataElementType.SELECT);
  7246.                 de.setValues(soggettiList);
  7247.                 de.setLabels(soggettiListLabel);
  7248.                 de.setSelected(provider);
  7249.                 de.setRequired(true);
  7250.             }
  7251.             dati.add(de);
  7252.            
  7253.             if(confirmInProgress) {
  7254.                 de = new DataElement();
  7255.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_EROGATORE);
  7256.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_CAMBIO_EROGATORE+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  7257.                 de.setType(DataElementType.TEXT);
  7258.                 de.setValue("-");
  7259.                 if(soggettiList!=null && soggettiList.length>0) {
  7260.                     for (int i = 0; i < soggettiList.length; i++) {
  7261.                         String prov = soggettiList[i];
  7262.                         if(prov.equals(provider)) {
  7263.                             de.setValue(soggettiListLabel[i]);
  7264.                             break;
  7265.                         }
  7266.                     }
  7267.                 }
  7268.                 dati.add(de);
  7269.             }
  7270.         }
  7271.        
  7272.        
  7273.        
  7274.         // allegati
  7275.        
  7276.         if(!tipoOp.equals(TipoOperazione.ADD) && !this.isModalitaCompleta() &&
  7277.                 (showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView)) {
  7278.             de = new DataElement();
  7279.             de.setType(DataElementType.LINK);
  7280.             List<Parameter> listParametersAllegati = new ArrayList<>();
  7281.             listParametersAllegati.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id));
  7282.             if(tmpModificaAPI!=null) {
  7283.                 listParametersAllegati.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_API, tmpModificaAPI));
  7284.             }
  7285.             if(gestioneFruitori) {
  7286.                 listParametersAllegati.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE, tipoSoggettoFruitore));
  7287.                 listParametersAllegati.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE, nomeSoggettoFruitore));
  7288.             }
  7289.             de.setUrl(
  7290.                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ALLEGATI_LIST,
  7291.                     listParametersAllegati.toArray(new Parameter[1]));
  7292.             if(contaListe){
  7293.                 try{
  7294.                     // BugFix OP-674
  7295.                     /**int num = this.apsCore.serviziAllegatiList(Integer.parseInt(id), new Search(true)).size();*/
  7296.                     ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  7297.                     this.apsCore.serviziAllegatiList(Integer.parseInt(id), searchForCount);
  7298.                     int num = searchForCount.getNumEntries(Liste.SERVIZI_ALLEGATI);
  7299.                     ServletUtils.setDataElementCustomLabel(de, AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI, (long) num);
  7300.                 }catch(Exception e){
  7301.                     this.logError("Calcolo numero Allegati non riuscito",e);
  7302.                     ServletUtils.setDataElementCustomLabel(de, AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI, AccordiServizioParteSpecificaCostanti.LABEL_N_D);
  7303.                 }
  7304.             }else{
  7305.                 de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI  );
  7306.             }
  7307.             dati.add(de);
  7308.         }
  7309.        
  7310.        
  7311.        
  7312.         // specifica porti di accesso
  7313.        
  7314.         if(serviceBinding != null && (serviceBinding.equals(ServiceBinding.SOAP) && interfaceType.equals(org.openspcoop2.protocol.manifest.constants.InterfaceType.WSDL_11) && showPortiAccesso &&
  7315.                 (showInformazioniGeneraliErogazioniFruizioniView==null || showInformazioniGeneraliErogazioniFruizioniView))){

  7316.             if(isModalitaAvanzata){
  7317.                 de = new DataElement();
  7318.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SPECIFICA_PORTI_ACCESSO);
  7319.                 de.setType(DataElementType.SUBTITLE);
  7320.                 dati.add(de);
  7321.    
  7322.                 de = new DataElement();
  7323.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VALIDAZIONE_DOCUMENTI_ESTESA);
  7324.                 de.setValue(""+validazioneDocumenti);
  7325.                 /**     if (tipoOp.equals(TipoOperazione.ADD) && InterfaceType.AVANZATA.equals(user.getInterfaceType())) { */
  7326.                 if (tipoOp.equals(TipoOperazione.ADD) ) {
  7327.                     de.setType(DataElementType.CHECKBOX);
  7328.                     if(validazioneDocumenti){
  7329.                         de.setSelected(Costanti.CHECK_BOX_ENABLED);
  7330.                     }else{
  7331.                         de.setSelected(Costanti.CHECK_BOX_DISABLED);
  7332.                     }
  7333.                 }else{
  7334.                     de.setType(DataElementType.HIDDEN);
  7335.                 }
  7336.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  7337.                 de.setSize(this.getSize());
  7338.                 dati.add(de);
  7339.    
  7340.                 boolean isSupportoAsincrono = this.core.isProfiloDiCollaborazioneAsincronoSupportatoDalProtocollo(tipoProtocollo,serviceBinding);
  7341.                 boolean isRuoloNormale =  !( (servcorr != null) && ((servcorr.equals(Costanti.CHECK_BOX_ENABLED)) || servcorr.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_ABILITATO)) ) ;
  7342.    
  7343.                 if (tipoOp.equals(TipoOperazione.ADD)) {
  7344.                     if(isSupportoAsincrono){
  7345.                         if(isRuoloNormale){
  7346.                             dati.add(wsdlimpler.getFileDataElement(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_EROGATORE_COMPATTO, "", getSize()));
  7347.                             dati.addAll(wsdlimpler.getFileNameDataElement());
  7348.                             dati.add(wsdlimpler.getFileIdDataElement());
  7349.                            
  7350.     /**                     de = new DataElement();
  7351.     //                      de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_EROGATORE);
  7352.     //                      de.setValue(wsdlimpler);
  7353.     //                      de.setType(DataElementType.FILE);
  7354.     //                      de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE);
  7355.     //                      de.setSize(this.getSize());
  7356.     //                      dati.add(de);*/
  7357.                         } else {
  7358.                             dati.add(wsdlimplfru.getFileDataElement(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_FRUITORE_COMPATTO, "", getSize()));
  7359.                             dati.addAll(wsdlimplfru.getFileNameDataElement());
  7360.                             dati.add(wsdlimplfru.getFileIdDataElement());
  7361.                            
  7362.     /**                     de = new DataElement();
  7363.     //                      de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_FRUITORE);
  7364.     //                      de.setValue(wsdlimplfru);
  7365.     //                      de.setType(DataElementType.FILE);
  7366.     //                      de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE);
  7367.     //                      de.setSize(this.getSize());
  7368.     //                      dati.add(de);*/
  7369.                         }
  7370.                     }else {
  7371.                         dati.add(wsdlimpler.getFileDataElement(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO, "", getSize()));
  7372.                         dati.addAll(wsdlimpler.getFileNameDataElement());
  7373.                         dati.add(wsdlimpler.getFileIdDataElement());
  7374.                        
  7375.     /**                 de = new DataElement();
  7376.     //                  de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO);
  7377.     //                  de.setValue(wsdlimpler);
  7378.     //                  de.setType(DataElementType.FILE);
  7379.     //                  de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE);
  7380.     //                  de.setSize(this.getSize());
  7381.     //                  dati.add(de);*/
  7382.                     }
  7383.                 } else {
  7384.                    
  7385.                     List<Parameter> listParametersWSDLChange = new ArrayList<>();
  7386.                     listParametersWSDLChange.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id));
  7387.                     if(gestioneFruitori) {
  7388.                         listParametersWSDLChange.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE, tipoSoggettoFruitore));
  7389.                         listParametersWSDLChange.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE, nomeSoggettoFruitore));
  7390.                     }
  7391.                    
  7392.                     if(isSupportoAsincrono){
  7393.                         if(isRuoloNormale){
  7394.                             de = new DataElement();
  7395.                             de.setType(DataElementType.LINK);
  7396.                             listParametersWSDLChange.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE));
  7397.                             de.setUrl(
  7398.                                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_WSDL_CHANGE,
  7399.                                     listParametersWSDLChange.toArray(new Parameter[1]));
  7400.                             de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_EROGATORE_ESTESO);
  7401.                             dati.add(de);
  7402.                         }else{
  7403.                             de = new DataElement();
  7404.                             de.setType(DataElementType.LINK);
  7405.                             listParametersWSDLChange.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE));
  7406.                             de.setUrl(
  7407.                                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_WSDL_CHANGE,
  7408.                                     listParametersWSDLChange.toArray(new Parameter[1]));
  7409.                             de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_FRUITORE_ESTESO);
  7410.                             dati.add(de);
  7411.                         }
  7412.                     }else {
  7413.                         de = new DataElement();
  7414.                         de.setType(DataElementType.LINK);
  7415.                         listParametersWSDLChange.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE));
  7416.                         de.setUrl(
  7417.                                 AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_WSDL_CHANGE,
  7418.                                 listParametersWSDLChange.toArray(new Parameter[1]));
  7419.    
  7420.                         de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO);
  7421.                         dati.add(de);
  7422.                     }
  7423.                 }
  7424.    
  7425.             } else {
  7426.                 if (tipoOp.equals(TipoOperazione.ADD)) {
  7427.                     de = new DataElement();
  7428.                     String wsdlimplerS =  wsdlimpler.getValue() != null ? new String(wsdlimpler.getValue()) : "";
  7429.                     de.setValue(wsdlimplerS);
  7430.                     de.setType(DataElementType.HIDDEN);
  7431.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE);
  7432.                     dati.add(de);
  7433.    
  7434.                     de = new DataElement();
  7435.                     String wsdlimplfruS =  wsdlimpler.getValue() != null ? new String(wsdlimpler.getValue()) : "";
  7436.                     de.setValue(wsdlimplfruS);
  7437.                     de.setType(DataElementType.HIDDEN);
  7438.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE);
  7439.                     dati.add(de);
  7440.                 }
  7441.             }
  7442.         }
  7443.        
  7444.         if (tipoOp.equals(TipoOperazione.ADD) &&
  7445.                 (accordo == null || accordo.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PARAMETRO_ACCORDO_NON_SELEZIONATO))) {
  7446.             return dati;
  7447.         }
  7448.        
  7449.         // Porta Applicativa e Servizio Applicativo Erogatore
  7450.         if (tipoOp.equals(TipoOperazione.ADD) && !ServletUtils.isCheckBoxEnabled(servcorr) && generaPACheckSoggetto) {

  7451.             if(this.isModalitaCompleta()) {
  7452.            
  7453.                 de = new DataElement();
  7454.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SERVIZIO_APPLICATIVO_EROGATORE );
  7455.                 de.setType(DataElementType.TITLE);
  7456.                 dati.add(de);
  7457.    
  7458.                 de = new DataElement();
  7459.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_NOME_SERVIZIO_APPLICATIVO_EROGATORE);
  7460.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SA);
  7461.                 de.setSelected(nomeSA);
  7462.                 de.setValues(saSoggetti);
  7463.                 de.setType(DataElementType.SELECT);
  7464.                 dati.add(de);
  7465.                
  7466.             }
  7467.            
  7468.             // Controllo Accesso
  7469.            
  7470.             // Creo un oggetto vuoto tanto per passare l'informazione sul tipo protocollo
  7471.             PortaApplicativa pa = new PortaApplicativa();
  7472.             pa.setServizio(new PortaApplicativaServizio());
  7473.             pa.getServizio().setTipo(tipoServizio);
  7474.            
  7475.             boolean forceAutenticato = false;
  7476.             boolean forceHttps = false;
  7477.             boolean forceDisableOptional = false;
  7478.             boolean forceGestioneToken = false;
  7479.             boolean forceMostraSezioneToken = false;
  7480.            
  7481.             if(this.isProfiloModIPA(tipoProtocollo)) {
  7482.                 if(idAccordoParteComune==null) {
  7483.                     idAccordoParteComune = this.idAccordoFactory.getIDAccordoFromUri(uriAccordo);
  7484.                 }
  7485.                 forceAutenticato = true; // in modI ci vuole sempre autenticazione https sull'erogazione (cambia l'opzionalita' o meno)
  7486.                 forceHttps = forceAutenticato;
  7487.                
  7488.                 boolean forcePDND = false;
  7489.                 boolean forceOAuth = false;
  7490.                                
  7491.                 BooleanNullable forceHttpsClientWrapper = BooleanNullable.NULL();
  7492.                 BooleanNullable forcePDNDWrapper = BooleanNullable.NULL();
  7493.                 BooleanNullable forceOAuthWrapper = BooleanNullable.NULL();
  7494.                
  7495.                 this.readModIConfiguration(forceHttpsClientWrapper, forcePDNDWrapper, forceOAuthWrapper,
  7496.                         idAccordoParteComune, portType,
  7497.                         null);
  7498.                
  7499.                 if(forceHttpsClientWrapper.getValue()!=null) {
  7500.                     forceDisableOptional = forceHttpsClientWrapper.getValue().booleanValue();
  7501.                 }
  7502.                 if(forcePDNDWrapper.getValue()!=null) {
  7503.                     forcePDND = forcePDNDWrapper.getValue().booleanValue();
  7504.                 }
  7505.                 if(forceOAuthWrapper.getValue()!=null) {
  7506.                     forceOAuth = forceOAuthWrapper.getValue().booleanValue();
  7507.                 }
  7508.                
  7509.                 if (forcePDND || forceOAuth) {
  7510.                    
  7511.                     forceGestioneToken = true;
  7512.                     forceMostraSezioneToken = true;
  7513.                    
  7514.                     gestioneToken = StatoFunzionalita.ABILITATO.getValue();
  7515.                    
  7516.                     if(forcePDND) {
  7517.                         List<String> tokenPolicies = this.getTokenPolicyGestione(true, false,
  7518.                                 false, // alla posizione 0 NON viene aggiunto -
  7519.                                 gestioneTokenPolicy, tipoOp);
  7520.                         if(tokenPolicies!=null && !tokenPolicies.isEmpty()) {
  7521.                             if(gestioneTokenPolicy==null || StringUtils.isEmpty(gestioneTokenPolicy) || CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(gestioneTokenPolicy)) {
  7522.                                 gestioneTokenPolicy = tokenPolicies.get(0);
  7523.                             }
  7524.                             gestioneTokenPolicyLabels = tokenPolicies.toArray(new String[1]);
  7525.                             gestioneTokenPolicyValues = tokenPolicies.toArray(new String[1]);
  7526.                         }
  7527.                     }
  7528.                     else {
  7529.                         List<String> tokenPolicies = this.getTokenPolicyGestione(false, true,
  7530.                                 false, // alla posizione 0 NON viene aggiunto -
  7531.                                 gestioneTokenPolicy, tipoOp);
  7532.                         if(tokenPolicies!=null && !tokenPolicies.isEmpty()) {
  7533.                             if(gestioneTokenPolicy==null || StringUtils.isEmpty(gestioneTokenPolicy) || CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(gestioneTokenPolicy)) {
  7534.                                 gestioneTokenPolicy = tokenPolicies.get(0);
  7535.                             }
  7536.                             gestioneTokenPolicyLabels = tokenPolicies.toArray(new String[1]);
  7537.                             gestioneTokenPolicyValues = tokenPolicies.toArray(new String[1]);
  7538.                         }
  7539.                     }
  7540.                    
  7541.                     gestioneTokenOpzionale = StatoFunzionalita.DISABILITATO.getValue();
  7542.                    
  7543.                     if(gestioneTokenPolicy!=null && StringUtils.isNotEmpty(gestioneTokenPolicy) &&
  7544.                             !CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(gestioneTokenPolicy)) {
  7545.                         GenericProperties gp = this.confCore.getGenericProperties(gestioneTokenPolicy, CostantiConfigurazione.GENERIC_PROPERTIES_TOKEN_TIPOLOGIA_VALIDATION, false);
  7546.                         if(gp!=null && gp.sizePropertyList()>0) {
  7547.                             for (Property p : gp.getPropertyList()) {
  7548.                                 if(org.openspcoop2.pdd.core.token.Costanti.POLICY_VALIDAZIONE_STATO.equals(p.getNome())) {
  7549.                                     if("true".equalsIgnoreCase(p.getValore())) {
  7550.                                         gestioneTokenValidazioneInput = StatoFunzionalita.ABILITATO.getValue();
  7551.                                     }
  7552.                                     else {
  7553.                                         gestioneTokenValidazioneInput = StatoFunzionalita.DISABILITATO.getValue();
  7554.                                     }
  7555.                                 }
  7556.                                 else if(org.openspcoop2.pdd.core.token.Costanti.POLICY_INTROSPECTION_STATO.equals(p.getNome())) {
  7557.                                     if("true".equalsIgnoreCase(p.getValore())) {
  7558.                                         gestioneTokenIntrospection = StatoFunzionalita.ABILITATO.getValue();
  7559.                                     }
  7560.                                     else {
  7561.                                         gestioneTokenIntrospection = StatoFunzionalita.DISABILITATO.getValue();
  7562.                                     }
  7563.                                 }
  7564.                                 else if(org.openspcoop2.pdd.core.token.Costanti.POLICY_USER_INFO_STATO.equals(p.getNome())) {
  7565.                                     if("true".equalsIgnoreCase(p.getValore())) {
  7566.                                         gestioneTokenUserInfo = StatoFunzionalita.ABILITATO.getValue();
  7567.                                     }
  7568.                                     else {
  7569.                                         gestioneTokenUserInfo = StatoFunzionalita.DISABILITATO.getValue();
  7570.                                     }
  7571.                                 }
  7572.                                 else if(org.openspcoop2.pdd.core.token.Costanti.POLICY_TOKEN_FORWARD_STATO.equals(p.getNome())) {
  7573.                                     if("true".equalsIgnoreCase(p.getValore())) {
  7574.                                         gestioneTokenForward = StatoFunzionalita.ABILITATO.getValue();
  7575.                                     }
  7576.                                     else {
  7577.                                         gestioneTokenForward = StatoFunzionalita.DISABILITATO.getValue();
  7578.                                     }
  7579.                                 }
  7580.                             }
  7581.                         }
  7582.                     }
  7583.                 }
  7584.             }
  7585.            
  7586.             this.controlloAccessiAdd(dati, tipoOp, controlloAccessiStato, forceAutenticato);
  7587.            
  7588.             this.controlloAccessiGestioneToken(dati, tipoOp, gestioneToken, gestioneTokenPolicyLabels, gestioneTokenPolicyValues,
  7589.                     gestioneTokenPolicy, gestioneTokenOpzionale,
  7590.                     gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenForward, null,tipoProtocollo, false,
  7591.                     forceGestioneToken, forceMostraSezioneToken);
  7592.            
  7593.             this.controlloAccessiAutenticazione(dati, tipoOp, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD, pa, tipoProtocollo,
  7594.                     erogazioneAutenticazione, null, erogazioneAutenticazioneOpzionale, erogazioneAutenticazionePrincipal, erogazioneAutenticazioneParametroList, false, erogazioneIsSupportatoAutenticazioneSoggetti,false,
  7595.                     gestioneToken, gestioneTokenPolicy, autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  7596.                     false, null, 0,
  7597.                     forceHttps, forceDisableOptional);
  7598.                        
  7599.             this.controlloAccessiAutorizzazione(dati, tipoOp, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD, pa, tipoProtocollo,
  7600.                     erogazioneAutenticazione, null,
  7601.                     erogazioneAutorizzazione, null,
  7602.                     erogazioneAutorizzazioneAutenticati, null, 0, soggettiAutenticati, soggettiAutenticatiLabel, soggettoAutenticato,
  7603.                     erogazioneAutorizzazioneRuoli, null, 0, erogazioneRuolo,
  7604.                     erogazioneAutorizzazioneRuoliTipologia, erogazioneAutorizzazioneRuoliMatch,
  7605.                     false, erogazioneIsSupportatoAutenticazioneSoggetti, contaListe, false, false,autorizzazioneScope,null,0,scope,autorizzazioneScopeMatch,
  7606.                     gestioneToken, gestioneTokenPolicy,
  7607.                     autorizzazioneToken, autorizzazioneTokenOptions,allegatoXacmlPolicy,
  7608.                     null, 0, null, 0,
  7609.                     identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  7610.                     autorizzazioneAutenticatiToken, null, 0,
  7611.                     autorizzazioneRuoliToken,  null, 0, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);
  7612.            
  7613.         }
  7614.        
  7615.         if(tipoOp.equals(TipoOperazione.ADD) && gestioneFruitori) {
  7616.            
  7617.             // Controllo Accesso Fruizione
  7618.            
  7619.             // Creo un oggetto vuoto tanto per passare l'informazione sul tipo protocollo
  7620.             PortaDelegata pd = new PortaDelegata();
  7621.             pd.setServizio(new PortaDelegataServizio());
  7622.             pd.getServizio().setTipo(tipoServizio);
  7623.            
  7624.             this.controlloAccessiAdd(dati, tipoOp, controlloAccessiStato, false);
  7625.            
  7626.             this.controlloAccessiGestioneToken(dati, tipoOp, gestioneToken, gestioneTokenPolicyLabels, gestioneTokenPolicyValues,
  7627.                     gestioneTokenPolicy, gestioneTokenOpzionale,
  7628.                     gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenForward, null,tipoProtocollo, true,
  7629.                     false);

  7630.             this.controlloAccessiAutenticazione(dati, tipoOp, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD,pd, tipoProtocollo,
  7631.                     fruizioneAutenticazione, null, fruizioneAutenticazioneOpzionale, fruizioneAutenticazionePrincipal, fruizioneAutenticazioneParametroList, false, true,true,
  7632.                     gestioneToken, gestioneTokenPolicy, autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  7633.                     false, null, 0,
  7634.                     false, false);
  7635.        
  7636.             this.controlloAccessiAutorizzazione(dati, tipoOp, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD,pd, tipoProtocollo,
  7637.                     fruizioneAutenticazione, null,
  7638.                     fruizioneAutorizzazione, null,
  7639.                     fruizioneAutorizzazioneAutenticati, null, 0, saList, fruizioneServizioApplicativo,
  7640.                     fruizioneAutorizzazioneRuoli, null, 0, fruizioneRuolo,
  7641.                     fruizioneAutorizzazioneRuoliTipologia, fruizioneAutorizzazioneRuoliMatch,
  7642.                     false, true, contaListe, true, false,autorizzazioneScope,null,0,scope,autorizzazioneScopeMatch,
  7643.                     gestioneToken, gestioneTokenPolicy,
  7644.                     autorizzazioneToken, autorizzazioneTokenOptions,allegatoXacmlPolicy,
  7645.                     null, 0, null, 0,
  7646.                     identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  7647.                     autorizzazioneAutenticatiToken, null, 0,
  7648.                     autorizzazioneRuoliToken,  null, 0, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);
  7649.            
  7650.         }




  7651.         if (!tipoOp.equals(TipoOperazione.ADD) &&

  7652.             this.isModalitaCompleta()) {
  7653.             de = new DataElement();
  7654.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALTRE_INFORMAZIONI);
  7655.             de.setType(DataElementType.TITLE);
  7656.             dati.add(de);

  7657.             de = new DataElement();
  7658.             de.setType(DataElementType.LINK);
  7659.             de.setUrl(
  7660.                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_LIST,
  7661.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id),
  7662.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, ""+idSoggettoErogatore),
  7663.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, nomeServizioEffettivo),
  7664.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, tipoServizioEffettivo)
  7665.                     );
  7666.             if(contaListe){
  7667.                 try{
  7668.                     // BugFix OP-674
  7669.                     /**int num = this.apsCore.serviziFruitoriList(Integer.parseInt(id), new Search(true)).size();*/
  7670.                     ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  7671.                     this.apsCore.serviziFruitoriList(Integer.parseInt(id), searchForCount);
  7672.                     int num = searchForCount.getNumEntries(Liste.SERVIZI_FRUITORI);
  7673.                     ServletUtils.setDataElementCustomLabel(de, AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI, (long) num);
  7674.                 }catch(Exception e){
  7675.                     this.logError("Calcolo numero fruitori non riuscito",e);
  7676.                     ServletUtils.setDataElementCustomLabel(de, AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI, AccordiServizioParteSpecificaCostanti.LABEL_N_D);
  7677.                 }
  7678.             }else{
  7679.                 de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI);
  7680.             }
  7681.             dati.add(de);

  7682.             de = new DataElement();
  7683.             de.setType(DataElementType.LINK);
  7684.             de.setUrl(
  7685.                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ALLEGATI_LIST,
  7686.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id));
  7687.             if(contaListe){
  7688.                 try{
  7689.                     // BugFix OP-674
  7690.                     /**int num = this.apsCore.serviziAllegatiList(Integer.parseInt(id), new Search(true)).size();*/
  7691.                     ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  7692.                     this.apsCore.serviziAllegatiList(Integer.parseInt(id), searchForCount);
  7693.                     int num = searchForCount.getNumEntries(Liste.SERVIZI_ALLEGATI);
  7694.                     ServletUtils.setDataElementCustomLabel(de, AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI, (long) num);
  7695.                 }catch(Exception e){
  7696.                     this.logError("Calcolo numero Allegati non riuscito",e);
  7697.                     ServletUtils.setDataElementCustomLabel(de, AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI, AccordiServizioParteSpecificaCostanti.LABEL_N_D);
  7698.                 }
  7699.             }else{
  7700.                 de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATI  );
  7701.             }
  7702.             dati.add(de);

  7703.         }

  7704.         if(cambiaAPI && !apiChanged) {
  7705.             this.pd.disableOnlyButton();
  7706.         }
  7707.        
  7708.         return dati;
  7709.     }

  7710.     public List<DataElement> addServiziToDatiAsHidden(List<DataElement> dati, String nomeservizio, String tiposervizio,
  7711.             String provider, String tipoSoggetto, String nomeSoggetto, String[] soggettiList, String[] soggettiListLabel,
  7712.             String accordo, ServiceBinding serviceBinding, String[] accordiList, String[] accordiListLabel, String servcorr, String wsdlimpler,
  7713.             String wsdlimplfru, TipoOperazione tipoOp, String id, List<String> tipi, String profilo, String portType,
  7714.             String[] ptList, boolean privato, String uriAccordo, String descrizione, long idSoggettoErogatore,
  7715.             String statoPackage,String oldStato,String versione,
  7716.             List<String> versioni,boolean validazioneDocumenti,String [] saSoggetti, String nomeSA, String protocollo, boolean generaPACheckSoggetto) throws Exception{

  7717.         String[] tipiLabel = new String[tipi.size()];
  7718.         for (int i = 0; i < tipi.size(); i++) {
  7719.             String nomeTipo = tipi.get(i);
  7720.             tipiLabel[i] = nomeTipo;
  7721.         }

  7722.         String[] versioniValues = new String[versioni.size()+1];
  7723.         String[] versioniLabel = new String[versioni.size()+1];
  7724.         versioniLabel[0] = AccordiServizioParteSpecificaCostanti.LABEL_APS_USA_VERSIONE_EROGATORE;
  7725.         versioniValues[0] = "-";
  7726.         for (int i = 0; i < versioni.size(); i++) {
  7727.             String tmp = versioni.get(i);
  7728.             versioniLabel[i+1] = tmp;
  7729.             versioniValues[i+1] = tmp;
  7730.         }

  7731.         boolean modificaAbilitata = ( (this.isShowGestioneWorkflowStatoDocumenti()==false) || (StatiAccordo.finale.toString().equals(oldStato)==false) );

  7732.         boolean isModalitaAvanzata = this.isModalitaAvanzata();

  7733.         // accordo di servizio parte comune
  7734.         DataElement de = new DataElement();
  7735.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO);
  7736.         de.setType(DataElementType.HIDDEN);
  7737.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ACCORDO);
  7738.         de.setValue(accordo);
  7739.         dati.add(de);

  7740.         //Servizio (portType)
  7741.         de = new DataElement();
  7742.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SERVIZIO);
  7743.         de.setType(DataElementType.HIDDEN);
  7744.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PORT_TYPE);
  7745.         de.setValue(portType);
  7746.         dati.add(de);

  7747.         //Sezione Soggetto Erogatore (provider)

  7748.         de = new DataElement();
  7749.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_EROGATORE);
  7750.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_EROGATORE);
  7751.         de.setValue(provider);
  7752.         de.setType(DataElementType.HIDDEN);
  7753.         dati.add(de);

  7754.         // Sezione Servizio

  7755.         de = new DataElement();
  7756.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_DESCRIZIONE);
  7757.         de.setType(DataElementType.HIDDEN);
  7758.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_DESCRIZIONE);
  7759.         de.setSize(getSize());
  7760.         de.setValue(descrizione!=null ? descrizione : "");
  7761.         if( !modificaAbilitata && (descrizione==null || "".equals(descrizione)) )
  7762.             de.setValue(" ");
  7763.         dati.add(de);

  7764.         de = new DataElement();
  7765.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  7766.         de.setType(DataElementType.HIDDEN);
  7767.         de.setValue(statoPackage);
  7768.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO_PACKAGE);
  7769.         dati.add(de);

  7770.         //Tipo Servizio
  7771.         de = new DataElement();
  7772.         de.setValue(tiposervizio);
  7773.         de.setType(DataElementType.HIDDEN);
  7774.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPO);
  7775.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO);
  7776.         dati.add(de);

  7777.         //Servizio

  7778.         de = new DataElement();
  7779.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_NOME_FILE);
  7780.         de.setType(DataElementType.HIDDEN);
  7781.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO  );
  7782.         de.setValue(nomeservizio);
  7783.         de.setSize(this.getSize());
  7784.         dati.add(de);
  7785.        
  7786.         // Versione Servizio
  7787.         de = new DataElement();
  7788.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VERSIONE);
  7789.         de.setValue(versione);
  7790.         de.setType(DataElementType.HIDDEN);
  7791.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VERSIONE);
  7792.         dati.add(de);

  7793.         // SErvizio Correlato
  7794.         de = new DataElement();
  7795.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_SERVIZIO_CORRELATO);
  7796.         de.setType(DataElementType.HIDDEN);
  7797.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_SERVIZIO_CORRELATO);
  7798.         if( this.core.isShowCorrelazioneAsincronaInAccordi() && ( !isModalitaAvanzata || (portType!=null && !"".equals(portType) && !"-".equals(portType)) ) ){
  7799.             if (  (servcorr != null) && ((servcorr.equals(Costanti.CHECK_BOX_ENABLED)) || servcorr.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_ABILITATO)) ) {
  7800.                 de.setValue(Costanti.CHECK_BOX_ENABLED);
  7801.             }
  7802.             else{
  7803.                 de.setValue(Costanti.CHECK_BOX_DISABLED);
  7804.             }
  7805.         }
  7806.         else if (  (servcorr != null) && ((servcorr.equals(Costanti.CHECK_BOX_ENABLED)) || servcorr.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_ABILITATO)) ) {
  7807.             if(tipoOp.equals(TipoOperazione.ADD) || modificaAbilitata){
  7808.                 de.setSelected(Costanti.CHECK_BOX_ENABLED);
  7809.             }else{
  7810.                 de.setValue(Costanti.CHECK_BOX_ENABLED);
  7811.             }
  7812.         }else{
  7813.             if(tipoOp.equals(TipoOperazione.CHANGE) && (this.isShowGestioneWorkflowStatoDocumenti()
  7814.                     &&  StatiAccordo.finale.toString().equals(oldStato) )){
  7815.                 de.setValue(Costanti.CHECK_BOX_DISABLED);
  7816.             }
  7817.         }
  7818.         dati.add(de);

  7819.         if( (tipoOp.equals(TipoOperazione.CHANGE) &&
  7820.                 (this.isShowGestioneWorkflowStatoDocumenti() &&  StatiAccordo.finale.toString().equals(oldStato) ))
  7821.                 ||
  7822.                 (this.core.isShowCorrelazioneAsincronaInAccordi() &&
  7823.                         ( !isModalitaAvanzata ||
  7824.                                 (portType!=null && !"".equals(portType) && !"-".equals(portType)) )) ){
  7825.             de = new DataElement();
  7826.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPOLOGIA_SERVIZIO);
  7827.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_SERVIZIO_CORRELATO_LABEL);
  7828.             if (  (servcorr != null) && ((servcorr.equals(Costanti.CHECK_BOX_ENABLED)) || servcorr.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_ABILITATO)) ) {
  7829.                 de.setValue(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_CORRELATO);
  7830.             }else{
  7831.                 de.setValue(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_NORMALE);
  7832.             }
  7833.             //          if(this.core.isProfiloDiCollaborazioneAsincronoSupportatoDalProtocollo(protocollo)){    
  7834.             //              de.setType(DataElementType.TEXT);
  7835.             //          } else {
  7836.             de.setType(DataElementType.HIDDEN);
  7837.             //          }
  7838.             dati.add(de);
  7839.         }

  7840.         //Privato
  7841.         de = new DataElement();
  7842.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PRIVATO);
  7843.         //      if (this.core.isShowFlagPrivato() &&  (tipoOp.equals(TipoOperazione.ADD) ||
  7844.         //              modificaAbilitata) && isModalitaAvanzata) {
  7845.         //          de.setType(DataElementType.CHECKBOX);
  7846.         //          de.setSelected(privato ? Costanti.CHECK_BOX_ENABLED : "");
  7847.         //      } else {
  7848.         de.setType(DataElementType.HIDDEN);
  7849.         de.setValue(privato ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  7850.         //      }
  7851.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PRIVATO);
  7852.         dati.add(de);

  7853.         if(this.core.isShowFlagPrivato() && tipoOp.equals(TipoOperazione.CHANGE ) &&
  7854.                 (this.isShowGestioneWorkflowStatoDocumenti() &&
  7855.                         StatiAccordo.finale.toString().equals(oldStato) ) &&
  7856.                         isModalitaAvanzata){
  7857.             de = new DataElement();
  7858.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VISIBILITA_SERVIZIO);
  7859.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PRIVATO_LABEL);
  7860.             if(privato){
  7861.                 de.setValue(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PRIVATA);
  7862.             }else{
  7863.                 de.setValue(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PUBBLICA);
  7864.             }
  7865.             de.setType(DataElementType.HIDDEN);
  7866.             dati.add(de);
  7867.         }

  7868.         de = new DataElement();
  7869.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VERSIONE_PROTOCOLLO);
  7870.         //      if(isModalitaAvanzata){
  7871.         //          if(tipoOp.equals(TipoOperazione.ADD) || modificaAbilitata){
  7872.         //              de.setValues(versioniValues);
  7873.         //              de.setLabels(versioniLabel);
  7874.         //              if(profilo==null){
  7875.         //                  profilo="-";
  7876.         //              }
  7877.         //              de.setSelected(profilo);
  7878.         //              de.setType(DataElementType.SELECT);
  7879.         //          }else{
  7880.         //              de.setType(DataElementType.TEXT);
  7881.         //              de.setValue(profilo);
  7882.         //              if( profilo==null || "".equals(profilo) )
  7883.         //                  de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_APS_USA_VERSIONE_EROGATORE);
  7884.         //          }
  7885.         //      }else {
  7886.         de.setType(DataElementType.HIDDEN);
  7887.         if(profilo==null){
  7888.             profilo="-";
  7889.         }
  7890.         de.setValue(profilo);
  7891.         //      }
  7892.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROFILO);
  7893.         de.setSize(this.getSize());
  7894.         dati.add(de);


  7895.         // Porta Applicativa e Servizio Applicativo Erogatore
  7896.         if (tipoOp.equals(TipoOperazione.ADD) && !ServletUtils.isCheckBoxEnabled(servcorr) && generaPACheckSoggetto) {

  7897.             de = new DataElement();
  7898.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_NOME_SERVIZIO_APPLICATIVO_EROGATORE);
  7899.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SA);
  7900.             de.setType(DataElementType.HIDDEN);
  7901.             de.setValue(nomeSA);
  7902.             //          de.setValues(saSoggetti);
  7903.             //          de.setType(DataElementType.SELECT);
  7904.             dati.add(de);
  7905.         }

  7906.         //Specifica dei porti di accesso

  7907.         de = new DataElement();
  7908.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VALIDAZIONE_DOCUMENTI_ESTESA);
  7909.         de.setValue(""+validazioneDocumenti);
  7910.         //      if (tipoOp.equals(TipoOperazione.ADD) && InterfaceType.AVANZATA.equals(user.getInterfaceType())) {
  7911.         //          if (tipoOp.equals(TipoOperazione.ADD) ) {
  7912.         //              de.setType(DataElementType.CHECKBOX);
  7913.         //              if(validazioneDocumenti){
  7914.         //                  de.setSelected(Costanti.CHECK_BOX_ENABLED);
  7915.         //              }else{
  7916.         //                  de.setSelected(Costanti.CHECK_BOX_DISABLED);
  7917.         //              }
  7918.         //          }else{
  7919.         de.setType(DataElementType.HIDDEN);
  7920.         //          }
  7921.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  7922.         de.setSize(this.getSize());
  7923.         dati.add(de);


  7924.         de = new DataElement();
  7925.         de.setValue(wsdlimpler);
  7926.         de.setType(DataElementType.HIDDEN);
  7927.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE);
  7928.         dati.add(de);

  7929.         de = new DataElement();
  7930.         de.setValue(wsdlimplfru);
  7931.         de.setType(DataElementType.HIDDEN);
  7932.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE);
  7933.         dati.add(de);

  7934.         return dati;
  7935.     }



  7936.     public List<DataElement> addWSDLToDati(TipoOperazione tipoOp,  
  7937.             int size,
  7938.             AccordoServizioParteSpecifica asps, String oldwsdl,
  7939.             String tipo, boolean validazioneDocumenti,
  7940.             List<DataElement> dati,
  7941.             String tipologiaDocumentoScaricare, String label) {

  7942.         boolean isModalitaAvanzata = this.isModalitaAvanzata();

  7943.         DataElement de = new DataElement();
  7944.         if(label.contains(" di ")){
  7945.             de.setLabel(label.split(" di")[0]);
  7946.         }else{
  7947.             de.setLabel(tipologiaDocumentoScaricare.toUpperCase().charAt(0)+tipologiaDocumentoScaricare.substring(1));
  7948.         }
  7949.         de.setType(DataElementType.TITLE);
  7950.         dati.add(de);
  7951.        
  7952.         de = new DataElement();
  7953.         de = new DataElement();
  7954.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPO);
  7955.         de.setValue( tipo);
  7956.         de.setType(DataElementType.HIDDEN);
  7957.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO);
  7958.         dati.add(de);

  7959.         if( this.isShowGestioneWorkflowStatoDocumenti() && StatiAccordo.finale.toString().equals(asps.getStatoPackage())){
  7960.             this.pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);

  7961.             if(this.core.isShowInterfacceAPI()) {
  7962.                 de = new DataElement();
  7963.                 de.setLabel("");
  7964.                 de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  7965.                 de.setValue(oldwsdl);
  7966.                 de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_SIZE);
  7967.                 de.setCols(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_COLUMNS);
  7968.                 dati.add(de);
  7969.             }
  7970.            
  7971.             if(oldwsdl != null && !oldwsdl.isEmpty()){
  7972.                 DataElement saveAs = new DataElement();
  7973.                 saveAs.setValue(AccordiServizioParteComuneCostanti.LABEL_DOWNLOAD);
  7974.                 saveAs.setType(DataElementType.LINK);
  7975.                 saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT,
  7976.                         new Parameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_ALLEGATI_ID_ACCORDO, asps.getId()+""),
  7977.                         new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, tipologiaDocumentoScaricare),
  7978.                         new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ACCORDO_PARTE_SPECIFICA));
  7979.                 saveAs.setDisabilitaAjaxStatus();
  7980.                 dati.add(saveAs);
  7981.             }else {
  7982.                 de = new DataElement();
  7983. //              de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_ATTUALE );
  7984.                 de.setType(DataElementType.TEXT);
  7985.                 de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_NOT_FOUND);
  7986.                 dati.add(de);
  7987.             }
  7988.            
  7989.         }
  7990.         else{

  7991.             if(oldwsdl != null && !oldwsdl.isEmpty()){
  7992.                 if(this.core.isShowInterfacceAPI()) {
  7993.                     de = new DataElement();
  7994.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  7995.                     de.setValue(oldwsdl);
  7996.                     de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_SIZE);
  7997.                     de.setCols(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_COLUMNS);
  7998.                     //de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_ATTUALE);
  7999.                     dati.add(de);
  8000.                 }

  8001.                 DataElement saveAs = new DataElement();
  8002.                 saveAs.setValue(AccordiServizioParteComuneCostanti.LABEL_DOWNLOAD);
  8003.                 saveAs.setType(DataElementType.LINK);
  8004.                 saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT,
  8005.                         new Parameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_ALLEGATI_ID_ACCORDO, asps.getId()+""),
  8006.                         new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, tipologiaDocumentoScaricare),
  8007.                         new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ACCORDO_PARTE_SPECIFICA));
  8008.                 saveAs.setDisabilitaAjaxStatus();
  8009.                 dati.add(saveAs);
  8010.                
  8011.                 de = new DataElement();
  8012.                 de.setType(DataElementType.TITLE);
  8013.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_AGGIORNAMENTO);
  8014.                 de.setValue("");
  8015.                 de.setSize(this.getSize());
  8016.                 dati.add(de);
  8017.             }else {
  8018.                 de = new DataElement();
  8019.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_ATTUALE );
  8020.                 de.setType(DataElementType.TEXT);
  8021.                 de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_NOT_FOUND);
  8022.                 dati.add(de);
  8023.             }

  8024.             de = new DataElement();
  8025.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  8026.             de.setValue("" + validazioneDocumenti);
  8027.             if (isModalitaAvanzata) {
  8028.                 de.setType(DataElementType.CHECKBOX);
  8029.                 if( validazioneDocumenti){
  8030.                     de.setSelected(Costanti.CHECK_BOX_ENABLED);
  8031.                 }else{
  8032.                     de.setSelected(Costanti.CHECK_BOX_DISABLED);
  8033.                 }
  8034.             }else{
  8035.                 de.setType(DataElementType.HIDDEN);
  8036.             }
  8037.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  8038.             de.setSize(size);
  8039.             dati.add(de);

  8040.             de = new DataElement();
  8041.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_NUOVO);
  8042.             de.setValue("");
  8043.             de.setType(DataElementType.FILE);
  8044.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL);
  8045.             de.setSize(size);
  8046.             dati.add(de);
  8047.            
  8048.             if(oldwsdl != null && !oldwsdl.isEmpty()){
  8049.                 de = new DataElement();
  8050.                 de.setBold(true);
  8051.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_CHANGE_CLEAR_WARNING);
  8052.                 de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_CHANGE_CLEAR);
  8053.                 de.setType(DataElementType.NOTE);
  8054.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_WARN);
  8055.                 de.setSize(this.getSize());
  8056.                 dati.add(de);
  8057.             }
  8058.         }

  8059.         return dati;
  8060.     }


  8061.     public List<DataElement> addTipoNomeServizioToDati(TipoOperazione tipoOp,  String myId, String tipoServizio, String nomeServizio, Integer versioneServizio, List<DataElement> dati ){
  8062.         DataElement de = new DataElement();

  8063.         if(nomeServizio !=null){
  8064.             de = new DataElement();
  8065.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO);
  8066.             de.setType(DataElementType.HIDDEN);
  8067.             de.setValue(nomeServizio);
  8068.             dati.add(de);
  8069.         }

  8070.         if(tipoServizio != null){
  8071.             de = new DataElement();
  8072.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO);
  8073.             de.setType(DataElementType.HIDDEN);
  8074.             de.setValue(tipoServizio);
  8075.             dati.add(de);
  8076.         }
  8077.        
  8078.         if(versioneServizio != null){
  8079.             de = new DataElement();
  8080.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VERSIONE);
  8081.             de.setType(DataElementType.HIDDEN);
  8082.             de.setValue(versioneServizio.intValue()+"");
  8083.             dati.add(de);
  8084.         }

  8085.         if(myId != null){
  8086.             de = new DataElement();
  8087.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID);
  8088.             de.setType(DataElementType.HIDDEN);
  8089.             de.setValue(myId);
  8090.             dati.add(de);
  8091.         }

  8092.         return dati;
  8093.     }


  8094.     public List<DataElement> addFruitoreWSDLToDati(TipoOperazione tipoOp,
  8095.             String tipo, String idSoggettoErogatoreDelServizio, String idSoggettoFruitore, String wsdl, Boolean validazioneDocumenti,
  8096.             Fruitore myFru,
  8097.             List<DataElement> dati,
  8098.             String id, String tipologiaDocumentoScaricare,
  8099.             boolean finished, String label) {

  8100.         boolean isModalitaAvanzata = this.isModalitaAvanzata();

  8101.         DataElement de = new DataElement();
  8102.         if(label.contains(" di ")){
  8103.             de.setLabel(label.split(" di")[0]);
  8104.         }else{
  8105.             de.setLabel(tipologiaDocumentoScaricare.toUpperCase().charAt(0)+tipologiaDocumentoScaricare.substring(1));
  8106.         }
  8107.         de.setType(DataElementType.TITLE);
  8108.         dati.add(de);
  8109.        
  8110.         de = new DataElement();
  8111.         de = new DataElement();
  8112.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPO);
  8113.         de.setValue( tipo);
  8114.         de.setType(DataElementType.HIDDEN);
  8115.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO);
  8116.         dati.add(de);

  8117.         de = new DataElement();
  8118.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ID_SOGGETTO_EROGATORE);
  8119.         de.setValue( idSoggettoErogatoreDelServizio);
  8120.         de.setType(DataElementType.HIDDEN);
  8121.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);
  8122.         dati.add(de);
  8123.        
  8124.         de = new DataElement();
  8125.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_FRUITORE);
  8126.         de.setValue( idSoggettoFruitore);
  8127.         de.setType(DataElementType.HIDDEN);
  8128.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE);
  8129.         dati.add(de);



  8130.         if(this.isShowGestioneWorkflowStatoDocumenti() && StatiAccordo.finale.toString().equals(myFru.getStatoPackage())){
  8131.            
  8132.             this.pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  8133.            
  8134.             if(wsdl != null && !wsdl.isEmpty()){
  8135.                 this.pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  8136.                
  8137.                 if(this.core.isShowInterfacceAPI()) {
  8138.                     de = new DataElement();
  8139.                     de.setLabel("");
  8140.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  8141.                     de.setValue( wsdl);
  8142.                     de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_SIZE);
  8143.                     de.setCols(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_COLUMNS);
  8144.                     dati.add(de);
  8145.                 }
  8146.                
  8147.                 if(wsdl != null && !wsdl.isEmpty()){
  8148.                     DataElement saveAs = new DataElement();
  8149.                     saveAs.setValue(AccordiServizioParteComuneCostanti.LABEL_DOWNLOAD);
  8150.                     saveAs.setType(DataElementType.LINK);
  8151.                     saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT,
  8152.                             new Parameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_ALLEGATI_ID_ACCORDO, id),
  8153.                             new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, tipologiaDocumentoScaricare),
  8154.                             new Parameter(ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO_WSDL_IMPLEMENTATIVO_TIPO_SOGGETTO_FRUITORE, myFru.getTipo()),
  8155.                             new Parameter(ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO_WSDL_IMPLEMENTATIVO_NOME_SOGGETTO_FRUITORE, myFru.getNome()),
  8156.                             new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ACCORDO_PARTE_SPECIFICA));
  8157.                     saveAs.setDisabilitaAjaxStatus();
  8158.                     dati.add(saveAs);
  8159.                 }
  8160.             }
  8161.             else{
  8162.                 de = new DataElement();
  8163.                 //de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_ATTUALE );
  8164.                 de.setType(DataElementType.TEXT);
  8165.                 de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_NOT_FOUND);
  8166.                 dati.add(de);
  8167.             }
  8168.         }
  8169.         else{

  8170.             if(wsdl != null && !wsdl.isEmpty()){
  8171.                 if(this.core.isShowInterfacceAPI()) {
  8172.                     de = new DataElement();
  8173.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  8174.                     de.setValue(wsdl);
  8175.                     de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_SIZE);
  8176.                     de.setCols(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_COLUMNS);
  8177.                     //de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_ATTUALE );
  8178.                     dati.add(de);
  8179.                 }

  8180.                 DataElement saveAs = new DataElement();
  8181.                 saveAs.setValue(AccordiServizioParteComuneCostanti.LABEL_DOWNLOAD);
  8182.                 saveAs.setType(DataElementType.LINK);
  8183.                 saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT,
  8184.                         new Parameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_ALLEGATI_ID_ACCORDO, id),
  8185.                         new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, tipologiaDocumentoScaricare),
  8186.                         new Parameter(ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO_WSDL_IMPLEMENTATIVO_TIPO_SOGGETTO_FRUITORE, myFru.getTipo()),
  8187.                         new Parameter(ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO_WSDL_IMPLEMENTATIVO_NOME_SOGGETTO_FRUITORE, myFru.getNome()),
  8188.                         new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ACCORDO_PARTE_SPECIFICA));
  8189.                 saveAs.setDisabilitaAjaxStatus();
  8190.                 dati.add(saveAs);
  8191.                
  8192.                 if(!finished){
  8193.                     de = new DataElement();
  8194.                     de.setType(DataElementType.TITLE);
  8195.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_AGGIORNAMENTO);
  8196.                     de.setValue("");
  8197.                     de.setSize(this.getSize());
  8198.                     dati.add(de);
  8199.                 }
  8200.             }else {
  8201.                 de = new DataElement();
  8202.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_ATTUALE );
  8203.                 de.setType(DataElementType.TEXT);
  8204.                 de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_NOT_FOUND);
  8205.                 dati.add(de);
  8206.             }

  8207.             de = new DataElement();
  8208.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  8209.             de.setValue("" + validazioneDocumenti);
  8210.             if (isModalitaAvanzata && !finished) {
  8211.                 de.setType(DataElementType.CHECKBOX);
  8212.                 if( validazioneDocumenti){
  8213.                     de.setSelected(Costanti.CHECK_BOX_ENABLED);
  8214.                 }else{
  8215.                     de.setSelected(Costanti.CHECK_BOX_DISABLED);
  8216.                 }
  8217.             }else{
  8218.                 de.setType(DataElementType.HIDDEN);
  8219.             }
  8220.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  8221.             de.setSize( getSize());
  8222.             dati.add(de);

  8223.             if(!finished){
  8224.                 de = new DataElement();
  8225.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_NUOVO);
  8226.                 de.setValue("");
  8227.                 de.setType(DataElementType.FILE);
  8228.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL);
  8229.                 de.setSize( getSize());
  8230.                 dati.add(de);
  8231.                
  8232.                 if(wsdl != null && !wsdl.isEmpty()){
  8233.                     de = new DataElement();
  8234.                     de.setBold(true);
  8235.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_CHANGE_CLEAR_WARNING);
  8236.                     de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_WSDL_CHANGE_CLEAR);
  8237.                     de.setType(DataElementType.NOTE);
  8238.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_WARN);
  8239.                     de.setSize(this.getSize());
  8240.                     dati.add(de);
  8241.                 }
  8242.             }
  8243.         }
  8244.         return dati;
  8245.     }


  8246.     public List<DataElement> addServiziFruitoriToDati(List<DataElement> dati, String idSoggettoFruitore, BinaryParameter wsdlimpler,
  8247.             BinaryParameter wsdlimplfru, String[] soggettiList, String[] soggettiListLabel, String idServ, String id,
  8248.             TipoOperazione tipoOp, String idSoggettoErogatoreDelServizio, String nomeprov, String tipoprov,
  8249.             String nomeservizio, String tiposervizio, Integer versioneservizio, String correlato, String stato, String oldStato, String statoServizio,
  8250.             String tipoAccordo, boolean validazioneDocumenti,
  8251.             String controlloAccessiStato,
  8252.             String fruizioneServizioApplicativo,String fruizioneRuolo,String fruizioneAutenticazione,String fruizioneAutenticazioneOpzionale, TipoAutenticazionePrincipal fruizioneAutenticazionePrincipal, List<String> fruizioneAutenticazioneParametroList, String fruizioneAutorizzazione,
  8253.             String fruizioneAutorizzazioneAutenticati,String fruizioneAutorizzazioneRuoli, String fruizioneAutorizzazioneRuoliTipologia, String fruizioneAutorizzazioneRuoliMatch,
  8254.             List<String> saList, ServiceBinding serviceBinding, org.openspcoop2.protocol.manifest.constants.InterfaceType interfaceType,
  8255.             String azioneConnettore, String azioneConnettoreIdPorta, String accessoDaAPSParametro, Integer parentPD,
  8256.             String gestioneToken, String[] gestioneTokenPolicyLabels, String[] gestioneTokenPolicyValues,
  8257.             String gestioneTokenPolicy, String gestioneTokenOpzionale,
  8258.             String gestioneTokenValidazioneInput, String gestioneTokenIntrospection, String gestioneTokenUserInfo, String gestioneTokenForward,
  8259.             String autenticazioneTokenIssuer,String autenticazioneTokenClientId,String autenticazioneTokenSubject,String autenticazioneTokenUsername,String autenticazioneTokenEMail,
  8260.             String autorizzazioneToken, String autorizzazioneTokenOptions,
  8261.             String autorizzazioneScope,  String scope, String autorizzazioneScopeMatch,BinaryParameter allegatoXacmlPolicy,
  8262.             String identificazioneAttributiStato, String[] attributeAuthorityLabels, String[] attributeAuthorityValues, String [] attributeAuthoritySelezionate, String attributeAuthorityAttributi,
  8263.             String autorizzazioneAutenticatiToken,
  8264.             String autorizzazioneRuoliToken,  String autorizzazioneRuoliTipologiaToken, String autorizzazioneRuoliMatchToken) throws Exception {
  8265.        
  8266.         boolean isRuoloNormale = !(correlato != null && correlato.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_CORRELATO));

  8267.         String protocollo = this.apsCore.getProtocolloAssociatoTipoServizio(tiposervizio);

  8268.         boolean isProfiloAsincronoSupportatoDalProtocollo = this.core.isProfiloDiCollaborazioneAsincronoSupportatoDalProtocollo(protocollo,serviceBinding);

  8269.         boolean ripristinoStatoOperativo = this.core.isGestioneWorkflowStatoDocumentiRipristinoStatoOperativoDaFinale();

  8270.         Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  8271.        
  8272.         boolean showPortiAccesso = this.apcCore.showPortiAccesso(protocollo, serviceBinding, interfaceType);
  8273.        
  8274.         String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  8275.         boolean gestioneFruitori = false;
  8276.         if(tipologia!=null) {
  8277.             if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  8278.                 gestioneFruitori = true;
  8279.             }
  8280.         }
  8281.        
  8282.         String tmpModificaProfilo = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_PROFILO);
  8283.         @SuppressWarnings("unused")
  8284.         boolean modificaProfilo = false;
  8285.         if(tmpModificaProfilo!=null) {
  8286.             modificaProfilo = "true".equals(tmpModificaProfilo);
  8287.            
  8288.             DataElement de = new DataElement();
  8289.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_PROFILO);
  8290.             de.setValue(tmpModificaProfilo);
  8291.             de.setType(DataElementType.HIDDEN);
  8292.             dati.add(de);
  8293.         }
  8294.        
  8295.         if(azioneConnettore!=null && !"".equals(azioneConnettore)) {
  8296.             DataElement de = new DataElement();
  8297.             de.setType(DataElementType.HIDDEN);
  8298.             de.setValue(azioneConnettore);
  8299.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE);
  8300.             dati.add(de);
  8301.         }
  8302.        
  8303.         if(azioneConnettoreIdPorta!=null && !"".equals(azioneConnettoreIdPorta)) {
  8304.             DataElement de = new DataElement();
  8305.             de.setType(DataElementType.HIDDEN);
  8306.             de.setValue(azioneConnettoreIdPorta);
  8307.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE_ID_PORTA);
  8308.             dati.add(de);
  8309.         }
  8310.        
  8311.         if(accessoDaAPSParametro!=null && !"".equals(accessoDaAPSParametro)) {
  8312.             DataElement de = new DataElement();
  8313.             de.setType(DataElementType.HIDDEN);
  8314.             de.setValue(accessoDaAPSParametro);
  8315.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONNETTORE_DA_LISTA_APS);
  8316.             dati.add(de);
  8317.         }
  8318.        
  8319.         if (tipoOp.equals(TipoOperazione.ADD)) {

  8320.             DataElement de = new DataElement();
  8321.             de.setType(DataElementType.TITLE);
  8322.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORE);
  8323.             dati.add(de);
  8324.            
  8325.             // in caso di add allora visualizzo la lista dei soggetti
  8326.             de = new DataElement();
  8327.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_FRUITORE);
  8328.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE);
  8329.             de.setType(DataElementType.SELECT);
  8330.             de.setValues(soggettiList);
  8331.             de.setLabels(soggettiListLabel);
  8332.             de.setSelected(idSoggettoFruitore);
  8333.             de.setPostBack(true);
  8334.             dati.add(de);

  8335.            
  8336.             if(this.isShowGestioneWorkflowStatoDocumenti()){
  8337.                 de = new DataElement();
  8338.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  8339.                 if (this.isModalitaStandard()) {
  8340.                     de.setType(DataElementType.HIDDEN);
  8341.                     de.setValue(statoServizio);
  8342.                 }else{
  8343.                     de.setType(DataElementType.SELECT);
  8344.                     de.setValues(StatiAccordo.toArray());
  8345.                     de.setLabels(StatiAccordo.toLabel());
  8346.                     de.setSelected(stato);
  8347.                 }
  8348.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO);
  8349.                 dati.add(de);
  8350.             }else{
  8351.                 de = new DataElement();
  8352.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  8353.                 de.setType(DataElementType.HIDDEN);
  8354.                 de.setValue(StatiAccordo.finale.toString());
  8355.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO);
  8356.                 dati.add(de);
  8357.             }

  8358.             boolean isSoggettoGestitoPorta = false;
  8359.             String protocolloSoggettoGestitoPorta = null;
  8360.             if(soggettiList!=null && soggettiList.length>0){
  8361.                 String soggettoId = idSoggettoFruitore;
  8362.                 if(soggettoId==null || "".equals(soggettoId)){
  8363.                     soggettoId = soggettiList[0];
  8364.                 }
  8365.                 Soggetto sogg = this.soggettiCore.getSoggettoRegistro(Long.parseLong(soggettoId));
  8366.                 if(!this.pddCore.isPddEsterna(sogg.getPortaDominio())){
  8367.                     isSoggettoGestitoPorta = true;  
  8368.                     protocolloSoggettoGestitoPorta = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(sogg.getTipo());
  8369.                 }
  8370.             }




  8371.             if(isSoggettoGestitoPorta){
  8372.                
  8373.                 this.controlloAccessiAdd(dati, tipoOp, controlloAccessiStato, false);
  8374.                
  8375.                 this.controlloAccessiGestioneToken(dati, tipoOp, gestioneToken, gestioneTokenPolicyLabels, gestioneTokenPolicyValues,
  8376.                         gestioneTokenPolicy, gestioneTokenOpzionale,
  8377.                         gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenForward, null,protocolloSoggettoGestitoPorta,true,
  8378.                         false);

  8379.                 this.controlloAccessiAutenticazione(dati, tipoOp, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD,null,protocolloSoggettoGestitoPorta,
  8380.                         fruizioneAutenticazione, null, fruizioneAutenticazioneOpzionale, fruizioneAutenticazionePrincipal, fruizioneAutenticazioneParametroList, false, true,true,
  8381.                         gestioneToken, gestioneTokenPolicy, autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  8382.                         false, null, 0,
  8383.                         false, false);
  8384.                
  8385.                 this.controlloAccessiAutorizzazione(dati, tipoOp, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD,null,protocolloSoggettoGestitoPorta,
  8386.                         fruizioneAutenticazione, null,
  8387.                         fruizioneAutorizzazione, null,
  8388.                         fruizioneAutorizzazioneAutenticati, null, 0, saList, fruizioneServizioApplicativo,
  8389.                         fruizioneAutorizzazioneRuoli, null, 0, fruizioneRuolo,
  8390.                         fruizioneAutorizzazioneRuoliTipologia, fruizioneAutorizzazioneRuoliMatch,
  8391.                         false, true, contaListe, true, false,autorizzazioneScope,null,0,scope,autorizzazioneScopeMatch,
  8392.                         gestioneToken, gestioneTokenPolicy,
  8393.                         autorizzazioneToken, autorizzazioneTokenOptions,allegatoXacmlPolicy,
  8394.                         null, 0, null, 0,
  8395.                         identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  8396.                         autorizzazioneAutenticatiToken, null, 0,
  8397.                         autorizzazioneRuoliToken, null, 0, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);
  8398.    
  8399.             }

  8400.             if(serviceBinding.equals(ServiceBinding.SOAP) && interfaceType.equals(org.openspcoop2.protocol.manifest.constants.InterfaceType.WSDL_11) && showPortiAccesso){
  8401.            
  8402.                 if (this.isModalitaAvanzata()) {
  8403.                     de = new DataElement();
  8404.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SPECIFICA_PORTI_ACCESSO );
  8405.                     de.setType(DataElementType.TITLE);
  8406.                     dati.add(de);
  8407.                 }
  8408.    
  8409.                 de = new DataElement();
  8410.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VALIDAZIONE_DOCUMENTI_ESTESA);
  8411.                 de.setValue(""+validazioneDocumenti);
  8412.                 if (tipoOp.equals(TipoOperazione.ADD) && this.isModalitaAvanzata()) {
  8413.                     de.setType(DataElementType.CHECKBOX);
  8414.                     if(validazioneDocumenti){
  8415.                         de.setSelected(Costanti.CHECK_BOX_ENABLED);
  8416.                     }else{
  8417.                         de.setSelected(Costanti.CHECK_BOX_DISABLED);
  8418.                     }
  8419.                 }else{
  8420.                     de.setType(DataElementType.HIDDEN);
  8421.                 }
  8422.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  8423.                 de.setSize(this.getSize());
  8424.                 dati.add(de);
  8425.    
  8426.                 if(this.isModalitaAvanzata()){
  8427.                     if(isProfiloAsincronoSupportatoDalProtocollo){
  8428.                         if(isRuoloNormale){
  8429.                             dati.add(wsdlimpler.getFileDataElement(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_EROGATORE_COMPATTO, "", getSize()));
  8430.                             dati.addAll(wsdlimpler.getFileNameDataElement());
  8431.                             dati.add(wsdlimpler.getFileIdDataElement());
  8432.                            
  8433.     //                      de = new DataElement();
  8434.     //                      de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_EROGATORE);
  8435.     //                      de.setValue("");
  8436.     //                      de.setType(DataElementType.FILE);
  8437.     //                      de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE);
  8438.     //                      de.setSize(this.getSize());
  8439.     //                      dati.add(de);
  8440.                         }else {
  8441.                             dati.add(wsdlimplfru.getFileDataElement(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_FRUITORE_COMPATTO, "", getSize()));
  8442.                             dati.addAll(wsdlimplfru.getFileNameDataElement());
  8443.                             dati.add(wsdlimplfru.getFileIdDataElement());
  8444.                            
  8445.     //                      de = new DataElement();
  8446.     //                      de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_FRUITORE);
  8447.     //                      de.setValue("");
  8448.     //                      de.setType(DataElementType.FILE);
  8449.     //                      de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE);
  8450.     //                      de.setSize(this.getSize());
  8451.     //                      dati.add(de);
  8452.                         }
  8453.                     } else {
  8454.                         dati.add(wsdlimpler.getFileDataElement(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO, "", getSize()));
  8455.                         dati.addAll(wsdlimpler.getFileNameDataElement());
  8456.                         dati.add(wsdlimpler.getFileIdDataElement());
  8457.                        
  8458.     //                  de = new DataElement();
  8459.     //                  de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO);
  8460.     //                  de.setValue("");
  8461.     //                  de.setType(DataElementType.FILE);
  8462.     //                  de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE);
  8463.     //                  de.setSize(this.getSize());
  8464.     //                  dati.add(de);
  8465.                     }
  8466.                 } else {
  8467.                     de = new DataElement();
  8468.                     de.setValue("");
  8469.                     de.setType(DataElementType.HIDDEN);
  8470.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE);
  8471.                     dati.add(de);
  8472.    
  8473.    
  8474.                     de = new DataElement();
  8475.                     de.setValue("");
  8476.                     de.setType(DataElementType.HIDDEN);
  8477.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE);
  8478.                     dati.add(de);
  8479.                 }
  8480.                
  8481.             }
  8482.                
  8483.         } else {
  8484.                    
  8485.             boolean viewOnlyConnettore = gestioneFruitori || (PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE==parentPD);
  8486.            
  8487.             if(!viewOnlyConnettore) {
  8488.                 DataElement de = new DataElement();
  8489.                 de.setType(DataElementType.TITLE);
  8490.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORE);
  8491.                 dati.add(de);
  8492.             }
  8493.            
  8494.             DataElement de = new DataElement();
  8495.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE);
  8496.             de.setValue(idSoggettoFruitore);
  8497.             de.setType(DataElementType.HIDDEN);
  8498.             dati.add(de);
  8499.                        
  8500.             // in caso di change non visualizzo la select list ma il tipo e il
  8501.             // nome del soggetto
  8502.             String nomeSoggetto = "";
  8503.             for (int i = 0; i < soggettiList.length; i++) {
  8504.                 if (soggettiList[i].equals(idSoggettoFruitore)) {
  8505.                     nomeSoggetto = soggettiListLabel[i];
  8506.                     break;
  8507.                 }
  8508.             }
  8509.            
  8510.             if(this.apsCore.isRegistroServiziLocale()){
  8511.                 de = new DataElement();
  8512.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_FRUITORE);
  8513.                 String [] split = nomeSoggetto.split("/");
  8514.                 IDSoggetto idSoggetto = new IDSoggetto(split[0], split[1]);
  8515.                 de.setValue(this.getLabelNomeSoggetto(protocollo, idSoggetto.getTipo(), idSoggetto.getNome()));
  8516.                 if(!viewOnlyConnettore) {
  8517.                     de.setType(DataElementType.TEXT);
  8518.                 }
  8519.                 else {
  8520.                     de.setType(DataElementType.HIDDEN);
  8521.                 }
  8522.                 dati.add(de);
  8523.             }
  8524.            
  8525.             if(this.isModalitaCompleta() && !viewOnlyConnettore) {
  8526.                 de = new DataElement();
  8527.                 if(this.apsCore.isRegistroServiziLocale()){
  8528.                     de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_VISUALIZZA_DATI_FRUITORE);
  8529.                     //de.setValue(nomeSoggetto);
  8530.                     String [] split = nomeSoggetto.split("/");
  8531.                     IDSoggetto idSoggetto = new IDSoggetto(split[0], split[1]);
  8532.                     long idSoggettoLong = this.soggettiCore.getIdSoggetto(idSoggetto.getNome(), idSoggetto.getTipo());
  8533.                     de.setType(DataElementType.LINK);
  8534.                     de.setUrl(SoggettiCostanti.SERVLET_NAME_SOGGETTI_CHANGE,
  8535.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_ID,idSoggettoLong+""),
  8536.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_NOME,idSoggetto.getNome()),
  8537.                             new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_TIPO,idSoggetto.getTipo()));
  8538.                 }
  8539.                 else{
  8540.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE_AS_TEXT);
  8541.                     de.setValue(nomeSoggetto);
  8542.                     de.setType(DataElementType.TEXT);
  8543.                 }
  8544.                 dati.add(de);
  8545.             }

  8546.                        
  8547.             if(this.isShowGestioneWorkflowStatoDocumenti() && this.isModalitaCompleta() && !viewOnlyConnettore) {
  8548.                 de = new DataElement();
  8549.                 de.setType(DataElementType.TITLE);
  8550.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  8551.                 dati.add(de);
  8552.             }

  8553.             de = new DataElement();
  8554.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  8555.             if(this.isShowGestioneWorkflowStatoDocumenti()){
  8556.                 if(viewOnlyConnettore) {
  8557.                     de.setType(DataElementType.HIDDEN);
  8558.                     de.setValue(stato);
  8559.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO);
  8560.                 }
  8561.                 else if(StatiAccordo.finale.toString().equals(oldStato)==false ){
  8562.                     de.setType(DataElementType.SELECT);
  8563.                     de.setValues(StatiAccordo.toArray());
  8564.                     de.setLabels(StatiAccordo.toLabel());
  8565.                     de.setSelected(stato);
  8566.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO);
  8567.                 }else{
  8568. //                  if (!isModalitaAvanzata) {
  8569. //                      de.setType(DataElementType.HIDDEN);
  8570. //                      de.setValue(StatiAccordo.finale.toString());
  8571. //                      de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO);
  8572. //                  }else{
  8573.                    
  8574.                     DataElement deLabel = new DataElement();
  8575.                     deLabel.setType(DataElementType.TEXT);
  8576.                     deLabel.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  8577.                     deLabel.setValue(StatiAccordo.upper(StatiAccordo.finale.toString()));
  8578.                     deLabel.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  8579.                     dati.add(deLabel);
  8580.                    
  8581.                     de.setType(DataElementType.HIDDEN);
  8582.                     de.setValue(StatiAccordo.finale.toString());
  8583.                     de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO);

  8584.                     if(ripristinoStatoOperativo){
  8585.                         dati.add(de);

  8586.                         de = new DataElement();
  8587.                         de.setType(DataElementType.LINK);

  8588.                         Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, idSoggettoErogatoreDelServizio);
  8589.                         Parameter pId = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, idServ);
  8590.                         Parameter pMyId = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, id);    
  8591.                         Parameter pFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE, idSoggettoFruitore);    

  8592.                         de.setUrl(
  8593.                                 AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE,
  8594.                                 pId,    pMyId, pIdSoggettoErogatore ,pFruitore,
  8595.                                 new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_RIPRISTINA_STATO, StatiAccordo.operativo.toString()),
  8596.                                 new Parameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME, Costanti.DATA_ELEMENT_EDIT_MODE_VALUE_EDIT_IN_PROGRESS));
  8597.                         de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_RIPRISTINA_STATO_OPERATIVO);
  8598.                     }
  8599. //                  }
  8600.                 }
  8601.             }else{
  8602.                 de.setType(DataElementType.HIDDEN);
  8603.                 de.setValue(StatiAccordo.finale.toString());
  8604.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO);
  8605.             }
  8606.             dati.add(de);
  8607.            
  8608.            
  8609.             // &correlato
  8610.             Parameter pCorrelato = null;
  8611.             if (correlato != null) {
  8612.                 pCorrelato = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_CORRELATO, correlato);
  8613.             }

  8614.             Parameter pTipoWSDLEr = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE);
  8615.             Parameter pTipoWSDLFru = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE);
  8616.             Parameter pId = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, id);
  8617.             Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, idSoggettoErogatoreDelServizio);
  8618.             Parameter pIdSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE, idSoggettoFruitore);
  8619.            
  8620.             Parameter pIdServ = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SERVIZIO, idServ);

  8621.             Parameter pNomeProv = new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_NOME, nomeprov);
  8622.             Parameter pTipoProv = new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_TIPO, tipoprov);
  8623.             Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, nomeservizio);
  8624.             Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, tiposervizio);
  8625.             Parameter pVersioneServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VERSIONE, versioneservizio.intValue()+"");

  8626.             Parameter pTipoAccordo = AccordiServizioParteComuneUtilities.getParametroAccordoServizio(tipoAccordo);


  8627.             if(!viewOnlyConnettore && serviceBinding.equals(ServiceBinding.SOAP) && interfaceType.equals(org.openspcoop2.protocol.manifest.constants.InterfaceType.WSDL_11) && showPortiAccesso){
  8628.                 if (this.isModalitaAvanzata()) {
  8629.    
  8630.                     de = new DataElement();
  8631.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SPECIFICA_PORTI_ACCESSO );
  8632.                     de.setType(DataElementType.TITLE);
  8633.                     dati.add(de);
  8634.    
  8635.                     if(isProfiloAsincronoSupportatoDalProtocollo){
  8636.                         List<Parameter> lstParam = new ArrayList<>();
  8637.    
  8638.                         if(isRuoloNormale){
  8639.                             lstParam = new ArrayList<>();
  8640.                             lstParam.add(pId);
  8641.                             lstParam.add(pIdSoggettoErogatore);
  8642.                             lstParam.add(pIdSoggettoFruitore);
  8643.                             lstParam.add(pTipoWSDLEr);
  8644.                             if(pCorrelato != null){
  8645.                                 lstParam.add(pCorrelato);
  8646.                             }
  8647.    
  8648.                             de = new DataElement();
  8649.                             de.setType(DataElementType.LINK);
  8650.                             if (tipoOp.equals(TipoOperazione.CHANGE)) {
  8651.                                 de.setUrl( AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_WSDL_CHANGE, lstParam.toArray(new Parameter[lstParam.size()]));
  8652.                             } else {
  8653.                                 lstParam.add(pIdServ);
  8654.                                 lstParam.add(pNomeProv);
  8655.                                 lstParam.add(pTipoProv);
  8656.                                 lstParam.add(pNomeServizio);
  8657.                                 lstParam.add(pTipoServizio);
  8658.                                 lstParam.add(pVersioneServizio);
  8659.                                 lstParam.add(pTipoAccordo);
  8660.    
  8661.                                 de.setUrl(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_WSDL_CHANGE,
  8662.                                         lstParam.toArray(new Parameter[lstParam.size()]));
  8663.    
  8664.                                 //                  de.setUrl("accordiErogatoriFruitoriWSDLChange.do?id=" + id + "&tipo=wsdlimpler" + "&idSoggErogatore=" + idSoggettoErogatoreDelServizio +
  8665.                                 //                          "&idServ=" + idServ + "&nomeprov=" + nomeprov + "&tipoprov=" + tipoprov + "&nomeservizio=" + nomeservizio +
  8666.                                 //                          "&tiposervizio=" + tiposervizio + tmpCorrelato+
  8667.                                 //                          AccordiServizioParteComuneUtilities.getParametroAccordoServizio(tipoAccordo, "&"));
  8668.                             }
  8669.                             de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_EROGATORE_ESTESO);
  8670.                             dati.add(de);
  8671.                         }else {
  8672.                             lstParam = new ArrayList<>();
  8673.                             lstParam.add(pId);
  8674.                             lstParam.add(pIdSoggettoErogatore);
  8675.                             lstParam.add(pIdSoggettoFruitore);
  8676.                             lstParam.add(pTipoWSDLFru);
  8677.                             if(pCorrelato != null){
  8678.                                 lstParam.add(pCorrelato);
  8679.                             }
  8680.    
  8681.                             de = new DataElement();
  8682.                             de.setType(DataElementType.LINK);
  8683.                             if (tipoOp.equals(TipoOperazione.CHANGE)) {
  8684.                                 de.setUrl( AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_WSDL_CHANGE, lstParam.toArray(new Parameter[lstParam.size()]));
  8685.                             } else {
  8686.                                 lstParam.add(pIdServ);
  8687.                                 lstParam.add(pNomeProv);
  8688.                                 lstParam.add(pTipoProv);
  8689.                                 lstParam.add(pNomeServizio);
  8690.                                 lstParam.add(pTipoServizio);
  8691.                                 lstParam.add(pVersioneServizio);
  8692.                                 lstParam.add(pTipoAccordo);
  8693.    
  8694.                                 de.setUrl(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_WSDL_CHANGE,
  8695.                                         lstParam.toArray(new Parameter[lstParam.size()]));
  8696.    
  8697.                                 //                  de.setUrl("accordiErogatoriFruitoriWSDLChange.do?id=" + id + "&tipo=wsdlimplfru" + "&idSoggErogatore=" + idSoggettoErogatoreDelServizio +
  8698.                                 //                          "&idServ=" + idServ + "&nomeprov=" + nomeprov + "&tipoprov=" + tipoprov + "&nomeservizio=" + nomeservizio + "&tiposervizio=" +
  8699.                                 //                          tiposervizio + tmpCorrelato+
  8700.                                 //                          AccordiServizioParteComuneUtilities.getParametroAccordoServizio(tipoAccordo, "&"));
  8701.                             }
  8702.                             de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO_FRUITORE_ESTESO);
  8703.                             dati.add(de);
  8704.                         }
  8705.                     }else {
  8706.                         List<Parameter> lstParam = new ArrayList<>();
  8707.                         lstParam.add(pId);
  8708.                         lstParam.add(pIdSoggettoErogatore);
  8709.                         lstParam.add(pIdSoggettoFruitore);
  8710.                         lstParam.add(pTipoWSDLEr);
  8711.                         if(pCorrelato != null){
  8712.                             lstParam.add(pCorrelato);
  8713.                         }
  8714.    
  8715.                         de = new DataElement();
  8716.                         de.setType(DataElementType.LINK);
  8717.                         if (tipoOp.equals(TipoOperazione.CHANGE)) {
  8718.                             de.setUrl( AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_WSDL_CHANGE, lstParam.toArray(new Parameter[lstParam.size()]));
  8719.                         } else {
  8720.                             lstParam.add(pIdServ);
  8721.                             lstParam.add(pNomeProv);
  8722.                             lstParam.add(pTipoProv);
  8723.                             lstParam.add(pNomeServizio);
  8724.                             lstParam.add(pTipoServizio);
  8725.                             lstParam.add(pVersioneServizio);
  8726.                             lstParam.add(pTipoAccordo);
  8727.    
  8728.                             de.setUrl(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_WSDL_CHANGE,
  8729.                                     lstParam.toArray(new Parameter[lstParam.size()]));
  8730.    
  8731.                             //                  de.setUrl("accordiErogatoriFruitoriWSDLChange.do?id=" + id + "&tipo=wsdlimpler" + "&idSoggErogatore=" + idSoggettoErogatoreDelServizio +
  8732.                             //                          "&idServ=" + idServ + "&nomeprov=" + nomeprov + "&tipoprov=" + tipoprov + "&nomeservizio=" + nomeservizio +
  8733.                             //                          "&tiposervizio=" + tiposervizio + tmpCorrelato+
  8734.                             //                          AccordiServizioParteComuneUtilities.getParametroAccordoServizio(tipoAccordo, "&"));
  8735.                         }
  8736.                         de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_WSDL_IMPLEMENTATIVO);
  8737.                         dati.add(de);
  8738.                     }
  8739.                 }
  8740.             }
  8741.         }

  8742.         return dati;
  8743.     }

  8744.     public List<DataElement> addServiziFruitoriToDatiAsHidden(List<DataElement> dati, String idSoggettoFruitore, String wsdlimpler,
  8745.             String wsdlimplfru, String[] soggettiList, String[] soggettiListLabel, String idServ, String id,
  8746.             TipoOperazione tipoOp, String idSoggettoErogatoreDelServizio, String nomeprov, String tipoprov,
  8747.             String nomeservizio, String tiposervizio, String correlato, String stato, String oldStato, String statoServizio,
  8748.             String tipoAccordo, boolean validazioneDocumenti,
  8749.             String azioneConnettore) throws Exception {

  8750.         boolean isModalitaAvanzata = this.isModalitaAvanzata();

  8751.         if(azioneConnettore!=null && !"".equals(azioneConnettore)) {
  8752.             DataElement de = new DataElement();
  8753.             de.setType(DataElementType.HIDDEN);
  8754.             de.setValue(azioneConnettore);
  8755.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE);
  8756.             dati.add(de);
  8757.         }
  8758.        
  8759.         if (tipoOp.equals(TipoOperazione.ADD)) {
  8760.             // in caso di add allora visualizzo la lista dei soggetti
  8761.             DataElement de = new DataElement();
  8762.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_FRUITORE);
  8763.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE);
  8764.             de.setType(DataElementType.HIDDEN);
  8765.             de.setValue(idSoggettoFruitore);
  8766.             dati.add(de);

  8767.             if(this.isShowGestioneWorkflowStatoDocumenti()){
  8768.                 de = new DataElement();
  8769.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  8770.                 if (!isModalitaAvanzata) {
  8771.                     de.setType(DataElementType.HIDDEN);
  8772.                     de.setValue(statoServizio);
  8773.                 }else{
  8774.                     de.setType(DataElementType.HIDDEN);
  8775.                     de.setValue(stato);
  8776.                 }
  8777.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO);
  8778.                 dati.add(de);
  8779.             }else{
  8780.                 de = new DataElement();
  8781.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  8782.                 de.setType(DataElementType.HIDDEN);
  8783.                 de.setValue(StatiAccordo.finale.toString());
  8784.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO);
  8785.                 dati.add(de);
  8786.             }

  8787.             de = new DataElement();
  8788.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_VALIDAZIONE_DOCUMENTI_ESTESA);
  8789.             de.setValue(""+validazioneDocumenti);
  8790.             de.setType(DataElementType.HIDDEN);
  8791.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  8792.             de.setSize(this.getSize());
  8793.             dati.add(de);

  8794.             de = new DataElement();
  8795.             de.setValue("");
  8796.             de.setType(DataElementType.HIDDEN);
  8797.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE);
  8798.             dati.add(de);


  8799.             de = new DataElement();
  8800.             de.setValue("");
  8801.             de.setType(DataElementType.HIDDEN);
  8802.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE);
  8803.             dati.add(de);
  8804.         } else {
  8805.             // in caso di change non visualizzo la select list ma il tipo e il
  8806.             // nome del soggetto
  8807.             @SuppressWarnings("unused")
  8808.             String nomeSoggetto = "";
  8809.             for (int i = 0; i < soggettiList.length; i++) {
  8810.                 if (soggettiList[i].equals(idSoggettoFruitore)) {
  8811.                     nomeSoggetto = soggettiListLabel[i];
  8812.                     break;
  8813.                 }
  8814.             }
  8815.             DataElement de = new DataElement();
  8816.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_PROVIDER_FRUITORE);
  8817.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE);
  8818.             de.setType(DataElementType.HIDDEN);
  8819.             //de.setValue(nomeSoggetto);
  8820.             de.setValue(idSoggettoFruitore);
  8821.             dati.add(de);

  8822.             de = new DataElement();
  8823.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_STATO);
  8824.             de.setType(DataElementType.HIDDEN);
  8825.             de.setValue(stato);
  8826.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_STATO);
  8827.             dati.add(de);
  8828.         }

  8829.         return dati;
  8830.     }

  8831.     private static boolean addFruitoreToDati_farVedere =false;
  8832.     public static boolean isAddFruitoreToDati_farVedere() {
  8833.         return addFruitoreToDati_farVedere;
  8834.     }
  8835.     public static void setAddFruitoreToDati_farVedere(boolean addFruitoreToDati_farVedere) {
  8836.         AccordiServizioParteSpecificaHelper.addFruitoreToDati_farVedere = addFruitoreToDati_farVedere;
  8837.     }
  8838.     public List<DataElement> addFruitoreToDati(TipoOperazione tipoOp, String[] versioniLabel, String[] versioniValues,
  8839.             List<DataElement> dati,
  8840.             String oldStatoPackage, String idServizio, String idServizioFruitore, String idSoggettoErogatoreDelServizio,
  8841.             String nomeservizio, String tiposervizio, Integer versioneservizio, String idSoggettoFruitore,
  8842.             AccordoServizioParteSpecifica asps, Fruitore fruitore) throws Exception{

  8843.         boolean isModalitaAvanzata = this.isModalitaAvanzata();

  8844.         // Occhio che sotto questo if ci sono dei campi HIDDEN
  8845.         if(addFruitoreToDati_farVedere && tipoOp.equals(TipoOperazione.CHANGE)){

  8846.             Soggetto fruitoreSogg = this.soggettiCore.getSoggettoRegistro(new IDSoggetto(fruitore.getTipo(), fruitore.getNome()));
  8847.            
  8848.             boolean esterno = this.pddCore.isPddEsterna(fruitoreSogg.getPortaDominio());            
  8849.             if(!esterno){
  8850.            
  8851.                 IDPortaDelegata idPD = null;
  8852.                 IDSoggetto idSoggettoFruitoreObject = new IDSoggetto(fruitore.getTipo(), fruitore.getNome());
  8853.                 if(isModalitaAvanzata==false){
  8854.                     IDServizio idServizioObject = this.idServizioFactory.getIDServizioFromValues(asps.getTipo(), asps.getNome(),
  8855.                             asps.getTipoSoggettoErogatore(),asps.getNomeSoggettoErogatore(),asps.getVersione());
  8856.                     idPD = this.porteDelegateCore.getIDPortaDelegataAssociataDefault(idServizioObject, idSoggettoFruitoreObject);
  8857.                 }
  8858.                
  8859.                
  8860.                 DataElement de = new DataElement();
  8861.                 if(isModalitaAvanzata || idPD==null){
  8862.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_DELEGATE);
  8863.                 }
  8864.                 else{
  8865.                     de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_SPECIFICA_PORTA_DELEGATA);
  8866.                 }
  8867.                 de.setType(DataElementType.TITLE);
  8868.                 dati.add(de);
  8869.                
  8870.                 de = new DataElement();
  8871.                 de.setType(DataElementType.LINK);
  8872.                 if(isModalitaAvanzata || idPD==null){
  8873.                    
  8874.                     Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  8875.                    
  8876.                     de.setUrl(
  8877.                             AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_PORTE_DELEGATE_LIST,
  8878.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID,idServizio),
  8879.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO, idSoggettoFruitore ),
  8880.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, idSoggettoErogatoreDelServizio),
  8881.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, nomeservizio),
  8882.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, tiposervizio),
  8883.                             new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, idServizioFruitore));
  8884.                     if(contaListe){
  8885.                         try{
  8886.                             // BugFix OP-674
  8887. //                          int num = this.apsCore.serviziFruitoriPorteDelegateList(this.soggettiCore.getIdSoggetto(fruitore.getNome(), fruitore.getTipo()),
  8888. //                                  asps.getServizio().getTipo(),asps.getServizio().getNome(), asps.getId(),
  8889. //                                  asps.getServizio().getTipoSoggettoErogatore(), asps.getServizio().getNomeSoggettoErogatore(), asps.getIdSoggetto(),
  8890. //                                  new Search(true)).size();
  8891.                             ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  8892.                             IDServizio idServizioFromAccordo = this.idServizioFactory.getIDServizioFromAccordo(asps);
  8893.                             //long idSoggetto = this.soggettiCore.getIdSoggetto(fruitore.getNome(), fruitore.getTipo());
  8894.                             IDSoggetto idSoggettoFr = new IDSoggetto(fruitore.getNome(), fruitore.getTipo());
  8895.                             this.apsCore.serviziFruitoriMappingList(fruitore.getId(), idSoggettoFr, idServizioFromAccordo, searchForCount);
  8896.                             //int numPD = fruLista.size();
  8897.                             int numPD = searchForCount.getNumEntries(Liste.CONFIGURAZIONE_FRUIZIONE);
  8898.                             ServletUtils.setDataElementCustomLabel(de, AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_DELEGATE, (long) numPD );
  8899.                            
  8900.                         }catch(Exception e){
  8901.                             this.logError("Calcolo numero pa non riuscito",e);
  8902.                             ServletUtils.setDataElementCustomLabel(de, AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_DELEGATE, AccordiServizioParteSpecificaCostanti.LABEL_N_D);
  8903.                         }
  8904.                     }else{
  8905.                         de.setValue(AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_DELEGATE);
  8906.                     }
  8907.                    
  8908.                 }
  8909.                 else{
  8910.                     // Utilizza la configurazione come parent
  8911.                     ServletUtils.setObjectIntoSession(this.request, this.session, PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE, PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT);
  8912.                    
  8913.                     PortaDelegata pd = this.porteDelegateCore.getPortaDelegata(idPD);
  8914.                     de.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_CHANGE,
  8915.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, "" + pd.getIdSoggetto()),
  8916.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_PORTA,pd.getNome()),
  8917.                             new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, "" + pd.getId())
  8918.                             );
  8919.                     de.setValue(Costanti.LABEL_VISUALIZZA);
  8920.                 }
  8921.                 dati.add(de);
  8922.                
  8923.             }
  8924.            
  8925.         }

  8926.         if(tipoOp.equals(TipoOperazione.CHANGE)){
  8927.             DataElement de = new DataElement();
  8928.             de.setValue(idServizioFruitore);
  8929.             de.setType(DataElementType.HIDDEN);
  8930.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID);
  8931.             dati.add(de);

  8932.         }

  8933.         return dati;
  8934.     }

  8935.     public List<DataElement> addFruitoreToDatiAsHidden(TipoOperazione tipoOp, String[] versioniLabel, String[] versioniValues,
  8936.             List<DataElement> dati,
  8937.             String oldStatoPackage, String idServizio, String idServizioFruitore, String idSoggettoErogatoreDelServizio,
  8938.             String nomeservizio, String tiposervizio, String idSoggettoFruitore){

  8939.    
  8940.         if(tipoOp.equals(TipoOperazione.CHANGE)){
  8941.             DataElement de = new DataElement();
  8942.             de.setValue(idServizioFruitore);
  8943.             de.setType(DataElementType.HIDDEN);
  8944.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID);
  8945.             dati.add(de);

  8946.             //          boolean modificaAbilitata = ( (this.apsCore.isShowGestioneWorkflowStatoDocumenti()==false)
  8947.             //                  || (StatiAccordo.finale.toString().equals(oldStatoPackage)==false) );


  8948.         }
  8949.        
  8950.         return dati;
  8951.     }

  8952.     public List<DataElement>  addTipiAllegatiToDati(TipoOperazione tipoOp, String idServizio, String ruolo,
  8953.             String[] ruoli, String[] tipiAmmessi, String[] tipiAmmessiLabel, String tipoFile,
  8954.             List<DataElement> dati, String modificaAPI, List<BinaryParameter> binaryParameterDocumenti) {
  8955.        
  8956.         DataElement de = new DataElement();
  8957.         de.setType(DataElementType.TITLE);
  8958.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATO);
  8959.         dati.add(de);
  8960.        
  8961.         de = new DataElement();
  8962.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_RUOLO);
  8963.         de.setType(DataElementType.SELECT);
  8964.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_RUOLO);
  8965.         de.setValues(ruoli);
  8966.         //              de.setOnChange("CambiaTipoDocumento('serviziAllegati')");
  8967.         de.setPostBack(true);
  8968.         de.setSelected(ruolo!=null ? ruolo : "");
  8969.         de.setSize( getSize());
  8970.         dati.add(de);

  8971.         if(tipiAmmessi!=null){
  8972.             de = new DataElement();
  8973.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPO_FILE);
  8974.             de.setType(DataElementType.SELECT);
  8975.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_FILE);
  8976.             de.setValues(tipiAmmessi);
  8977.             de.setLabels(tipiAmmessiLabel);
  8978.             de.setSelected(tipoFile);
  8979.             de.setSize( getSize());
  8980.             dati.add(de);
  8981.         }

  8982.        
  8983.         if(TipoOperazione.ADD.equals(tipoOp)){
  8984.             // dal parametro in posizione 0 leggiamo i dati per creare l'elemento grafico
  8985.             BinaryParameter allegato0 = binaryParameterDocumenti.get(0);
  8986.            
  8987.             DataElement fileDataElement = allegato0.getFileDataElement(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_THE_FILE, "", getSize());
  8988.             fileDataElement.setType(DataElementType.MULTI_FILE);
  8989.             fileDataElement.setRequired(true);
  8990.             dati.add(fileDataElement);
  8991.             dati.addAll(BinaryParameter.getFileNameDataElement(binaryParameterDocumenti));
  8992.             dati.add(BinaryParameter.getFileIdDataElement(binaryParameterDocumenti));
  8993.         } else {
  8994.             de = new DataElement();
  8995.             de.setValue(idServizio);
  8996.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_THE_FILE);
  8997.             de.setType(DataElementType.FILE);
  8998.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_THE_FILE);
  8999.             de.setSize( getSize());
  9000.             dati.add(de);
  9001.         }
  9002.        
  9003.         if(modificaAPI!=null) {
  9004.             de = new DataElement();
  9005.             de.setType(DataElementType.HIDDEN);
  9006.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_API);
  9007.             de.setValue(modificaAPI);
  9008.             dati.add(de);
  9009.         }

  9010.         return dati;
  9011.     }

  9012.     public List<DataElement>  addInfoAllegatiToDati(TipoOperazione tipoOp,    String idAllegato,
  9013.             AccordoServizioParteSpecifica asps, Documento doc,
  9014.             List<DataElement> dati, String modificaAPI) throws Exception {

  9015.         DataElement de = new DataElement();
  9016.         de.setType(DataElementType.TITLE);
  9017.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATO);
  9018.         dati.add(de);
  9019.        
  9020.         de = new DataElement();
  9021.         de.setValue(idAllegato);
  9022.         de.setType(DataElementType.HIDDEN);
  9023.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_ALLEGATO);
  9024.         dati.add(de);

  9025.         boolean stato = this.isEditModeInProgress() && this.isShowGestioneWorkflowStatoDocumenti() && StatiAccordo.finale.toString().equals(asps.getStatoPackage());
  9026.        
  9027.         if(!stato) {
  9028.             de = new DataElement();
  9029.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_NOME_ATTUALE);
  9030.             de.setType(DataElementType.SUBTITLE);
  9031.             dati.add(de);
  9032.         }

  9033.         de = new DataElement();
  9034.         de.setValue(doc.getRuolo());
  9035.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_RUOLO);
  9036.         de.setType(DataElementType.TEXT);
  9037.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_RUOLO);
  9038.         de.setSize( getSize());
  9039.         dati.add(de);

  9040.         de = new DataElement();
  9041.         de.setValue(doc.getFile());
  9042.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_NOME_FILE);
  9043.         de.setType(DataElementType.TEXT);
  9044.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_DOCUMENTO);
  9045.         de.setSize( getSize());
  9046.         dati.add(de);

  9047.         de = new DataElement();
  9048.         de.setValue(doc.getTipo());
  9049.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPO_FILE);
  9050.         de.setType(DataElementType.TEXT);
  9051.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_FILE);
  9052.         de.setSize( getSize());
  9053.         dati.add(de);

  9054.         if(stato){
  9055.             this.pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  9056.         }
  9057.         else{  
  9058.            
  9059.             de = new DataElement();
  9060.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_ACCORDO_PARTE_COMUNE_NOME_NUOVO);
  9061.             de.setType(DataElementType.SUBTITLE);
  9062.             dati.add(de);
  9063.            
  9064.             de = new DataElement();
  9065.             de.setType(DataElementType.FILE);
  9066.             de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_THE_FILE);
  9067.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_THE_FILE);
  9068.             de.setSize( getSize());
  9069.             dati.add(de);
  9070.         }

  9071.         if(modificaAPI!=null) {
  9072.             de = new DataElement();
  9073.             de.setType(DataElementType.HIDDEN);
  9074.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_API);
  9075.             de.setValue(modificaAPI);
  9076.             dati.add(de);
  9077.         }
  9078.        
  9079.         return dati;
  9080.     }


  9081.     public List<DataElement> addViewAllegatiToDati(TipoOperazione tipoOp, String idAllegato, String idServizio,
  9082.             Documento doc, StringBuilder contenutoAllegato, String errore,
  9083.             List<DataElement> dati, String modificaAPI) {
  9084.         DataElement de = new DataElement();

  9085.         de.setValue(idAllegato);
  9086.         de.setType(DataElementType.HIDDEN);
  9087.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_ALLEGATO);
  9088.         dati.add(de);

  9089.         de = new DataElement();
  9090.         de.setType(DataElementType.TITLE);
  9091.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_ALLEGATO);
  9092.         dati.add(de);
  9093.        
  9094.         de = new DataElement();
  9095.         de.setValue(doc.getRuolo());
  9096.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_RUOLO);
  9097.         de.setType(DataElementType.TEXT);
  9098.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_RUOLO);
  9099.         de.setSize( getSize());
  9100.         dati.add(de);

  9101.         de = new DataElement();
  9102.         de.setValue(doc.getFile());
  9103.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_NOME_FILE);
  9104.         de.setType(DataElementType.TEXT);
  9105.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_DOCUMENTO);
  9106.         de.setSize( getSize());
  9107.         dati.add(de);

  9108.         de = new DataElement();
  9109.         de.setValue(doc.getTipo());
  9110.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_TIPO_FILE);
  9111.         de.setType(DataElementType.TEXT);
  9112.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_FILE);
  9113.         de.setSize( getSize());
  9114.         dati.add(de);

  9115.         if(this.core.isShowAllegati()) {
  9116.             if(errore!=null){
  9117.                 de = new DataElement();
  9118.                 de.setValue(errore);
  9119.                 de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_PARAMETRO_APS_THE_FILE);
  9120.                 de.setType(DataElementType.TEXT );
  9121.                 de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_DOCUMENTO);
  9122.                 de.setSize( getSize());
  9123.                 dati.add(de);
  9124.             }
  9125.             else{
  9126.                 de = new DataElement();
  9127.                 de.setLabel("");
  9128.                 de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  9129.                 de.setValue(contenutoAllegato.toString());
  9130.                 de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_SIZE);
  9131.                 de.setCols(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_COLUMNS);
  9132.                 dati.add(de);
  9133.             }
  9134.         }
  9135.        
  9136.         DataElement saveAs = new DataElement();
  9137.         saveAs.setValue(AccordiServizioParteSpecificaCostanti.LABEL_APS_DOWNLOAD);
  9138.         saveAs.setType(DataElementType.LINK);
  9139.         Parameter pIdAccordo = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_ACCORDO, idServizio);
  9140.         Parameter pIdAllegato = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_ALLEGATO, idAllegato);
  9141.         Parameter pTipoDoc = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_DOCUMENTO, "asps");
  9142.         //          String params = "idAccordo="+idServizio+"&idAllegato="+idAllegato+"&tipoDocumento=asps";
  9143.         saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT, pIdAccordo, pIdAllegato, pTipoDoc);
  9144.         saveAs.setDisabilitaAjaxStatus();
  9145.         dati.add(saveAs);

  9146.         if(modificaAPI!=null) {
  9147.             de = new DataElement();
  9148.             de.setType(DataElementType.HIDDEN);
  9149.             de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_API);
  9150.             de.setValue(modificaAPI);
  9151.             dati.add(de);
  9152.         }
  9153.        
  9154.         return dati;
  9155.     }
  9156.    
  9157.     public List<DataElement> addConfigurazioneErogazioneToDati(TipoOperazione tipoOperazione, List<DataElement> dati, String nome, String nomeGruppo,
  9158.             String[] azioni, String[] azioniDisponibiliList, String[] azioniDisponibiliLabelList,
  9159.             String idAsps, String idSoggettoErogatoreDelServizio, String identificazione,
  9160.             AccordoServizioParteSpecifica asps, AccordoServizioParteComuneSintetico as, ServiceBinding serviceBinding, String modeCreazione, String modeCreazioneConnettore,
  9161.             String[] listaMappingLabels, String[] listaMappingValues, String mapping, String mappingLabel, boolean paMappingSelezionatoMulti, String nomeSA, String [] saSoggetti,
  9162.             String controlloAccessiStato,
  9163.             String erogazioneAutenticazione, String erogazioneAutenticazioneOpzionale, TipoAutenticazionePrincipal erogazioneAutenticazionePrincipal, List<String> erogazioneAutenticazioneParametroList, boolean erogazioneIsSupportatoAutenticazioneSoggetti,
  9164.             String erogazioneAutorizzazione, String erogazioneAutorizzazioneAutenticati, String erogazioneAutorizzazioneRuoli,
  9165.             String erogazioneRuolo, String erogazioneAutorizzazioneRuoliTipologia, String erogazioneAutorizzazioneRuoliMatch,
  9166.             List<String> soggettiAutenticati,  List<String> soggettiAutenticatiLabel, String soggettoAutenticato,
  9167.             String gestioneToken, String[] gestioneTokenPolicyLabels, String[] gestioneTokenPolicyValues,
  9168.             String gestioneTokenPolicy, String gestioneTokenOpzionale,
  9169.             String gestioneTokenValidazioneInput, String gestioneTokenIntrospection, String gestioneTokenUserInfo, String gestioneTokenForward,
  9170.             String autenticazioneTokenIssuer,String autenticazioneTokenClientId,String autenticazioneTokenSubject,String autenticazioneTokenUsername,String autenticazioneTokenEMail,
  9171.             String autorizzazioneToken, String autorizzazioneTokenOptions,
  9172.             String autorizzazioneScope, String scope, String autorizzazioneScopeMatch,BinaryParameter allegatoXacmlPolicy,
  9173.             String identificazioneAttributiStato, String[] attributeAuthorityLabels, String[] attributeAuthorityValues, String [] attributeAuthoritySelezionate, String attributeAuthorityAttributi,
  9174.             String autorizzazioneAutenticatiToken,
  9175.             String autorizzazioneRuoliToken, String autorizzazioneRuoliTipologiaToken, String autorizzazioneRuoliMatchToken) throws Exception {
  9176.        
  9177.         Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  9178.        
  9179.         DataElement de = new DataElement();
  9180.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_APPLICATIVE);
  9181.         de.setType(DataElementType.TITLE);
  9182.         dati.add(de);
  9183.        
  9184.         // idSoggetto erogatore
  9185.         de = new DataElement();
  9186.         de.setType(DataElementType.HIDDEN);
  9187.         de.setName(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);
  9188.         de.setValue(idSoggettoErogatoreDelServizio);
  9189.         dati.add(de);
  9190.        
  9191.         // Nome Gruppo
  9192.         de = new DataElement();
  9193.         de.setName(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_GRUPPO);
  9194.         de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_NOME_GRUPPO);
  9195.         de.setValue(nomeGruppo);
  9196.         de.setType(DataElementType.TEXT_EDIT);
  9197.         de.setRequired(true);
  9198.         dati.add(de);
  9199.        
  9200.         // Azione
  9201.         DataElement deAzione = new DataElement();
  9202.         deAzione.setLabel(this.getLabelAzioni(serviceBinding));
  9203.         deAzione.setValues(azioniDisponibiliList);
  9204.         deAzione.setLabels(azioniDisponibiliLabelList);
  9205.         deAzione.setSelezionati(azioni);
  9206.         deAzione.setType(DataElementType.MULTI_SELECT);
  9207.         deAzione.setName(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_AZIONI);
  9208.         deAzione.setRows(CostantiControlStation.RIGHE_MULTISELECT_AZIONI);
  9209.         deAzione.setRequired(true);
  9210.         dati.add(deAzione);
  9211.        
  9212.        
  9213.         // Nome
  9214.         de = new DataElement();
  9215.         de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_NOME);
  9216.         de.setValue(nome);
  9217.         de.setType(DataElementType.HIDDEN);
  9218.         de.setRequired(true);
  9219.         de.setName(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME);
  9220.         dati.add(de);
  9221.        
  9222.         // mode
  9223.         de = new DataElement();
  9224.         de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE);
  9225.         String[] modeLabels = {PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_EREDITA,PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_NUOVA};
  9226.         String[] modeValues = {PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_EREDITA, PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_NUOVA};
  9227.         de.setLabels(modeLabels);
  9228.         de.setValues(modeValues);
  9229.         de.setSelected(modeCreazione);
  9230.         de.setType(DataElementType.SELECT);
  9231.         de.setName(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MODE_CREAZIONE);
  9232.         de.setPostBack(true, true);
  9233.         dati.add(de);
  9234.        
  9235.        
  9236.         boolean showModeConnettore = !this.isModalitaStandard();
  9237.         //  modo creazione: se erediti la configurazione da una precedente allora devi solo sezionarla, altrimenti devi compilare le sezioni SA e controllo accessi
  9238.         if(modeCreazione.equals(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_EREDITA)) {
  9239.             // mapping
  9240.             de = new DataElement();
  9241.             de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MAPPING_GRUPPO);
  9242.             de.setLabels(listaMappingLabels);
  9243.             de.setValues(listaMappingValues);
  9244.             de.setSelected(mapping);
  9245.             de.setToolTip(mappingLabel);
  9246.             de.setType(DataElementType.SELECT);
  9247.             de.setName(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MAPPING);
  9248.             de.setPostBack(true);
  9249.             dati.add(de);
  9250.            
  9251.             showModeConnettore = showModeConnettore && !paMappingSelezionatoMulti;
  9252.         }
  9253.        
  9254.         // mode Connettore
  9255.         de = new DataElement();
  9256.         de.setLabel(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_CONNETTORE);
  9257.         de.setName(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MODE_CREAZIONE_CONNETTORE);
  9258.         if(showModeConnettore) {
  9259.             de.setType(DataElementType.CHECKBOX);
  9260.             de.setSelected(ServletUtils.isCheckBoxEnabled(modeCreazioneConnettore));
  9261.             de.setPostBack(true);
  9262.         } else {
  9263.             de.setType(DataElementType.HIDDEN);
  9264.             de.setValue(modeCreazione);
  9265.         }
  9266.         dati.add(de);
  9267.        
  9268.         if(!modeCreazione.equals(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_EREDITA)) {
  9269.            
  9270.             // Controllo Accesso
  9271.            
  9272.             boolean forceAutenticato = false;
  9273.             boolean forceHttps = false;
  9274.             boolean forceDisableOptional = false;
  9275.             boolean forceGestioneToken = false;
  9276.             boolean forceMostraSezioneToken = false;
  9277.             String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(asps.getTipoSoggettoErogatore());
  9278.             if(this.isProfiloModIPA(protocollo)) {
  9279.                 forceAutenticato = true; // in modI ci vuole sempre autenticazione https sull'erogazione (cambia l'opzionalita' o meno)
  9280.                 forceHttps = forceAutenticato;
  9281.                
  9282.                 if(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_NUOVA.equals(modeCreazione)) {
  9283.                    
  9284.                     BooleanNullable forcePDNDWrapper = BooleanNullable.NULL();
  9285.                     BooleanNullable forceOAuthWrapper = BooleanNullable.NULL();
  9286.                     this.readModIConfiguration(BooleanNullable.NULL(), forcePDNDWrapper, forceOAuthWrapper,
  9287.                             this.idAccordoFactory.getIDAccordoFromAccordo(as),asps.getPortType(),
  9288.                             azioniDisponibiliList!=null && azioniDisponibiliList.length>0 ? Arrays.asList(azioniDisponibiliList) : null); // verifica per tutte le azioni disponibili
  9289.                     boolean forcePDND = false;
  9290.                     boolean forceOAuth = false;
  9291.                     if(forcePDNDWrapper.getValue()!=null) {
  9292.                         forcePDND = forcePDNDWrapper.getValue().booleanValue();
  9293.                     }
  9294.                     if(forceOAuthWrapper.getValue()!=null) {
  9295.                         forceOAuth = forceOAuthWrapper.getValue().booleanValue();
  9296.                     }
  9297.                     if (forcePDND || forceOAuth) {
  9298.                         deAzione.setPostBack(true);
  9299.                     }
  9300.                    
  9301.                 }
  9302.                
  9303.                 boolean forcePDND = false;
  9304.                 boolean forceOAuth = false;
  9305.                                
  9306.                 BooleanNullable forceHttpsClientWrapper = BooleanNullable.NULL();
  9307.                 BooleanNullable forcePDNDWrapper = BooleanNullable.NULL();
  9308.                 BooleanNullable forceOAuthWrapper = BooleanNullable.NULL();
  9309.                
  9310.                 List<String> azioniList = null;
  9311.                 if(azioni!=null && azioni.length>0) {
  9312.                     azioniList = Arrays.asList(azioni);
  9313.                 }
  9314.                 this.readModIConfiguration(forceHttpsClientWrapper, forcePDNDWrapper, forceOAuthWrapper,
  9315.                         this.idAccordoFactory.getIDAccordoFromAccordo(as),asps.getPortType(),
  9316.                         azioniList);
  9317.                
  9318.                 if(forceHttpsClientWrapper.getValue()!=null) {
  9319.                     forceDisableOptional = forceHttpsClientWrapper.getValue().booleanValue();
  9320.                 }
  9321.                 if(forcePDNDWrapper.getValue()!=null) {
  9322.                     forcePDND = forcePDNDWrapper.getValue().booleanValue();
  9323.                 }
  9324.                 if(forceOAuthWrapper.getValue()!=null) {
  9325.                     forceOAuth = forceOAuthWrapper.getValue().booleanValue();
  9326.                 }
  9327.                
  9328.                 if (forcePDND || forceOAuth) {
  9329.                    
  9330.                     forceGestioneToken = true;
  9331.                     forceMostraSezioneToken = true;
  9332.                                        
  9333.                     gestioneToken = StatoFunzionalita.ABILITATO.getValue();
  9334.                    
  9335.                     if(forcePDND) {
  9336.                         List<String> tokenPolicies = this.getTokenPolicyGestione(true, false,
  9337.                                 false, // alla posizione 0 NON viene aggiunto -
  9338.                                 gestioneTokenPolicy, tipoOperazione);
  9339.                         if(tokenPolicies!=null && !tokenPolicies.isEmpty()) {
  9340.                             if(gestioneTokenPolicy==null || StringUtils.isEmpty(gestioneTokenPolicy) || CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(gestioneTokenPolicy)) {
  9341.                                 gestioneTokenPolicy = tokenPolicies.get(0);
  9342.                             }
  9343.                             gestioneTokenPolicyLabels = tokenPolicies.toArray(new String[1]);
  9344.                             gestioneTokenPolicyValues = tokenPolicies.toArray(new String[1]);
  9345.                         }
  9346.                     }
  9347.                     else {
  9348.                         List<String> tokenPolicies = this.getTokenPolicyGestione(false, true,
  9349.                                 false, // alla posizione 0 NON viene aggiunto -
  9350.                                 gestioneTokenPolicy, tipoOperazione);
  9351.                         if(tokenPolicies!=null && !tokenPolicies.isEmpty()) {
  9352.                             if(gestioneTokenPolicy==null || StringUtils.isEmpty(gestioneTokenPolicy) || CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(gestioneTokenPolicy)) {
  9353.                                 gestioneTokenPolicy = tokenPolicies.get(0);
  9354.                             }
  9355.                             gestioneTokenPolicyLabels = tokenPolicies.toArray(new String[1]);
  9356.                             gestioneTokenPolicyValues = tokenPolicies.toArray(new String[1]);
  9357.                         }
  9358.                     }
  9359.                    
  9360.                     gestioneTokenOpzionale = StatoFunzionalita.DISABILITATO.getValue();
  9361.                    
  9362.                     if(gestioneTokenPolicy!=null && StringUtils.isNotEmpty(gestioneTokenPolicy) &&
  9363.                             !CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(gestioneTokenPolicy)) {
  9364.                         GenericProperties gp = this.confCore.getGenericProperties(gestioneTokenPolicy, CostantiConfigurazione.GENERIC_PROPERTIES_TOKEN_TIPOLOGIA_VALIDATION, false);
  9365.                         if(gp!=null && gp.sizePropertyList()>0) {
  9366.                             for (Property p : gp.getPropertyList()) {
  9367.                                 if(org.openspcoop2.pdd.core.token.Costanti.POLICY_VALIDAZIONE_STATO.equals(p.getNome())) {
  9368.                                     if("true".equalsIgnoreCase(p.getValore())) {
  9369.                                         gestioneTokenValidazioneInput = StatoFunzionalita.ABILITATO.getValue();
  9370.                                     }
  9371.                                     else {
  9372.                                         gestioneTokenValidazioneInput = StatoFunzionalita.DISABILITATO.getValue();
  9373.                                     }
  9374.                                 }
  9375.                                 else if(org.openspcoop2.pdd.core.token.Costanti.POLICY_INTROSPECTION_STATO.equals(p.getNome())) {
  9376.                                     if("true".equalsIgnoreCase(p.getValore())) {
  9377.                                         gestioneTokenIntrospection = StatoFunzionalita.ABILITATO.getValue();
  9378.                                     }
  9379.                                     else {
  9380.                                         gestioneTokenIntrospection = StatoFunzionalita.DISABILITATO.getValue();
  9381.                                     }
  9382.                                 }
  9383.                                 else if(org.openspcoop2.pdd.core.token.Costanti.POLICY_USER_INFO_STATO.equals(p.getNome())) {
  9384.                                     if("true".equalsIgnoreCase(p.getValore())) {
  9385.                                         gestioneTokenUserInfo = StatoFunzionalita.ABILITATO.getValue();
  9386.                                     }
  9387.                                     else {
  9388.                                         gestioneTokenUserInfo = StatoFunzionalita.DISABILITATO.getValue();
  9389.                                     }
  9390.                                 }
  9391.                                 else if(org.openspcoop2.pdd.core.token.Costanti.POLICY_TOKEN_FORWARD_STATO.equals(p.getNome())) {
  9392.                                     if("true".equalsIgnoreCase(p.getValore())) {
  9393.                                         gestioneTokenForward = StatoFunzionalita.ABILITATO.getValue();
  9394.                                     }
  9395.                                     else {
  9396.                                         gestioneTokenForward = StatoFunzionalita.DISABILITATO.getValue();
  9397.                                     }
  9398.                                 }
  9399.                             }
  9400.                         }
  9401.                     }
  9402.                 }
  9403.             }
  9404.            
  9405.             this.controlloAccessiAdd(dati, tipoOperazione, controlloAccessiStato, forceAutenticato);
  9406.            
  9407.             this.controlloAccessiGestioneToken(dati, tipoOperazione, gestioneToken, gestioneTokenPolicyLabels, gestioneTokenPolicyValues,
  9408.                     gestioneTokenPolicy, gestioneTokenOpzionale,
  9409.                     gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenForward, null,protocollo, false,
  9410.                     forceGestioneToken, forceMostraSezioneToken);
  9411.            
  9412.             this.controlloAccessiAutenticazione(dati, tipoOperazione, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD, null,protocollo,
  9413.                     erogazioneAutenticazione, null, erogazioneAutenticazioneOpzionale, erogazioneAutenticazionePrincipal, erogazioneAutenticazioneParametroList, false, erogazioneIsSupportatoAutenticazioneSoggetti,false,
  9414.                     gestioneToken, gestioneTokenPolicy, autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  9415.                     false, null, 0,
  9416.                     forceHttps, forceDisableOptional);
  9417.            
  9418.             this.controlloAccessiAutorizzazione(dati, tipoOperazione, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD, null,protocollo,
  9419.                     erogazioneAutenticazione, null,
  9420.                     erogazioneAutorizzazione, null,
  9421.                     erogazioneAutorizzazioneAutenticati, null, 0, soggettiAutenticati, soggettiAutenticatiLabel, soggettoAutenticato,
  9422.                     erogazioneAutorizzazioneRuoli, null, 0, erogazioneRuolo,
  9423.                     erogazioneAutorizzazioneRuoliTipologia, erogazioneAutorizzazioneRuoliMatch,
  9424.                     false, erogazioneIsSupportatoAutenticazioneSoggetti, contaListe, false, false,autorizzazioneScope,null,0,scope,autorizzazioneScopeMatch,
  9425.                     gestioneToken, gestioneTokenPolicy,
  9426.                     autorizzazioneToken, autorizzazioneTokenOptions,allegatoXacmlPolicy,
  9427.                     null, 0, null, 0,
  9428.                     identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  9429.                     autorizzazioneAutenticatiToken, null, 0,
  9430.                     autorizzazioneRuoliToken, null, 0, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);
  9431.         }
  9432.        
  9433.        
  9434.         return dati;
  9435.     }

  9436.     public boolean configurazioneErogazioneCheckData(TipoOperazione tipoOp, String nome, String nomeGruppo, String[] azioni,
  9437.             AccordoServizioParteSpecifica asps, List<String> azioniOccupate,
  9438.             String modeCreazione, String idPorta, boolean isSupportatoAutenticazione,
  9439.             AccordiServizioParteSpecificaPorteApplicativeMappingInfo mappingInfo) throws Exception{
  9440.        
  9441.         if(nomeGruppo==null || "".equals(nomeGruppo.trim())) {
  9442.             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NOME_GRUPPO_NON_PUO_ESSERE_VUOTA);
  9443.             return false;
  9444.         }
  9445.         // Check lunghezza
  9446.         if(this.checkLength255(nomeGruppo, PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_GRUPPO)==false) {
  9447.             return false;
  9448.         }
  9449.         if(AccordiServizioParteSpecificaUtilities.getMappingPAFilterByDescription(mappingInfo.getListaMappingErogazione(), nomeGruppo)!=null) {
  9450.             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NOME_GRUPPO_GIA_ESISTENTE);
  9451.             return false;
  9452.         }
  9453.        
  9454.         if(azioni == null || azioni.length == 0) {
  9455.             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_PORTA_NON_PUO_ESSERE_VUOTA);
  9456.             return false;
  9457.         }
  9458.         for (String azioneTmp : azioni) {
  9459.             if(azioneTmp == null || azioneTmp.equals("") || azioneTmp.equals("-")) {
  9460.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_PORTA_NON_PUO_ESSERE_VUOTA);
  9461.                 return false;
  9462.             }
  9463.         }
  9464.        
  9465.         for (String azioneTmp : azioni) {
  9466.             if(azioniOccupate.contains(azioneTmp)) {
  9467.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_PORTA_GIA_PRESENTE);
  9468.                 return false;          
  9469.             }
  9470.         }
  9471.        
  9472.         if(checkAzioniUtilizzateErogazione(mappingInfo, azioni)==false) {
  9473.             return false;
  9474.         }
  9475.        
  9476.         if(modeCreazione.equals(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_EREDITA)) {
  9477.            
  9478.         } else {
  9479.             String autenticazione = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE);
  9480.             String autenticazioneCustom = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM);
  9481.             String autenticazioneOpzionale = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_OPZIONALE);
  9482.             String autenticazionePrincipalTipo = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TIPO);
  9483.             TipoAutenticazionePrincipal autenticazionePrincipal = TipoAutenticazionePrincipal.toEnumConstant(autenticazionePrincipalTipo, false);
  9484.             List<String> autenticazioneParametroList = this.convertFromDataElementValue_parametroAutenticazioneList(autenticazione, autenticazionePrincipal);
  9485.            
  9486.             String autorizzazione = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE);
  9487.             String autorizzazioneCustom = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM);
  9488.             String autorizzazioneAutenticati = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE);
  9489.             String autorizzazioneRuoli = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI);
  9490.             String autorizzazioneRuoliTipologia = this.getParameter(CostantiControlStation.PARAMETRO_RUOLO_TIPOLOGIA);
  9491.             String ruoloMatch = this.getParameter(CostantiControlStation.PARAMETRO_RUOLO_MATCH);
  9492.            
  9493.             String autorizzazioneContenutiStato = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_STATO);
  9494.             String autorizzazioneContenuti = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI);
  9495.             String autorizzazioneContenutiProperties = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_PROPERTIES);
  9496.            
  9497. //          if() {
  9498. //              
  9499. //          }
  9500.            
  9501.             // Se autenticazione = custom, nomeauth dev'essere specificato
  9502.             if (CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM.equals(autenticazione) &&
  9503.                     (autenticazioneCustom == null || autenticazioneCustom.equals(""))) {
  9504.                 this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_INDICARE_UN_NOME_PER_AUTENTICAZIONE_XX, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM));
  9505.                 return false;
  9506.             }

  9507.             // Se autorizzazione = custom, nomeautor dev'essere specificato
  9508.             if (CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM.equals(autorizzazione) &&
  9509.                     (autorizzazioneCustom == null || autorizzazioneCustom.equals(""))) {
  9510.                 this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_INDICARE_UN_NOME_PER_AUTORIZZAZIONE_XX, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM));
  9511.                 return false;
  9512.             }
  9513.            
  9514.             PortaApplicativa pa = null;
  9515.             if (TipoOperazione.CHANGE == tipoOp){
  9516.                 pa = this.porteApplicativeCore.getPortaApplicativa(Long.parseLong(idPorta));
  9517.             }
  9518.            
  9519.             List<String> ruoli = new ArrayList<>();
  9520.             if(pa!=null && pa.getRuoli()!=null && pa.getRuoli().sizeRuoloList()>0){
  9521.                 for (int i = 0; i < pa.getRuoli().sizeRuoloList(); i++) {
  9522.                     ruoli.add(pa.getRuoli().getRuolo(i).getNome());
  9523.                 }
  9524.             }
  9525.            
  9526.             String gestioneToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN);
  9527.             String gestioneTokenPolicy = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  9528.             String gestioneTokenValidazioneInput = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  9529.             String gestioneTokenIntrospection = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  9530.             String gestioneTokenUserInfo = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  9531.             String gestioneTokenTokenForward = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  9532.            
  9533.             String autorizzazioneAutenticatiToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE_TOKEN);
  9534.             String autorizzazioneRuoliToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_TOKEN);
  9535.            
  9536.             String autorizzazione_token = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN);
  9537.             String autorizzazione_tokenOptions = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_OPTIONS);
  9538.             String autorizzazioneScope = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE);
  9539.             String autorizzazioneScopeMatch = this.getParameter(CostantiControlStation.PARAMETRO_SCOPE_MATCH);
  9540.            
  9541.             BinaryParameter allegatoXacmlPolicy = this.getBinaryParameter(CostantiControlStation.PARAMETRO_DOCUMENTO_SICUREZZA_XACML_POLICY);
  9542.             String protocollo = ProtocolFactoryManager.getInstance().getProtocolByServiceType(asps.getTipo());
  9543.            
  9544.             String identificazioneAttributiStato = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO);
  9545.             String [] attributeAuthoritySelezionate = this.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  9546.             String attributeAuthorityAttributi = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI);
  9547.            
  9548.             if(this.controlloAccessiCheck(tipoOp, autenticazione, autenticazioneOpzionale, autenticazionePrincipal, autenticazioneParametroList,
  9549.                     autorizzazione, autorizzazioneAutenticati, autorizzazioneRuoli,
  9550.                     autorizzazioneRuoliTipologia, ruoloMatch,
  9551.                     isSupportatoAutenticazione, false, pa, ruoli,gestioneToken, gestioneTokenPolicy,
  9552.                     gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  9553.                     autorizzazioneAutenticatiToken, autorizzazioneRuoliToken,
  9554.                     autorizzazione_token,autorizzazione_tokenOptions,
  9555.                     autorizzazioneScope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  9556.                     autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties,
  9557.                     protocollo,
  9558.                     identificazioneAttributiStato, attributeAuthoritySelezionate, attributeAuthorityAttributi)==false){
  9559.                 return false;
  9560.             }
  9561.         }
  9562.        
  9563.         return true;
  9564.     }
  9565.        
  9566.     public boolean configurazioneFruizioneCheckData(TipoOperazione tipoOp, String nome, String nomeGruppo, String [] azioni,
  9567.             AccordoServizioParteSpecifica asps, List<String> azioniOccupate,
  9568.             String modeCreazione, String idPorta, boolean isSupportatoAutenticazione,
  9569.             AccordiServizioParteSpecificaFruitoriPorteDelegateMappingInfo mappingInfo) throws Exception{
  9570.        
  9571.         if(nomeGruppo==null || "".equals(nomeGruppo.trim())) {
  9572.             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NOME_GRUPPO_NON_PUO_ESSERE_VUOTA);
  9573.             return false;
  9574.         }
  9575.        
  9576.         // Check lunghezza
  9577.         if(this.checkLength255(nomeGruppo, PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME_GRUPPO)==false) {
  9578.             return false;
  9579.         }
  9580.        
  9581.         if(AccordiServizioParteSpecificaUtilities.getMappingPDFilterByDescription(mappingInfo.getListaMappingFruizione(), nomeGruppo)!=null) {
  9582.             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_NOME_GRUPPO_GIA_ESISTENTE);
  9583.             return false;
  9584.         }
  9585.        
  9586.         if(azioni == null || azioni.length == 0) {
  9587.             this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_PORTA_NON_PUO_ESSERE_VUOTA);
  9588.             return false;
  9589.         }
  9590.         for (String azioneTmp : azioni) {
  9591.             if(azioneTmp == null || azioneTmp.equals("") || azioneTmp.equals("-")) {
  9592.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_PORTA_NON_PUO_ESSERE_VUOTA);
  9593.                 return false;
  9594.             }
  9595.         }
  9596.        
  9597.         for (String azioneTmp : azioni) {
  9598.             if(azioniOccupate.contains(azioneTmp)) {
  9599.                 this.pd.setMessage(CostantiControlStation.MESSAGGIO_ERRORE_AZIONE_PORTA_GIA_PRESENTE);
  9600.                 return false;          
  9601.             }
  9602.         }
  9603.        
  9604.         if(checkAzioniUtilizzateFruizione(mappingInfo, azioni)==false) {
  9605.             return false;
  9606.         }
  9607.        
  9608.         if(modeCreazione.equals(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_EREDITA)) {
  9609.            
  9610.         } else {
  9611.             String autenticazione = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE);
  9612.             String autenticazioneCustom = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM);
  9613.             String autenticazioneOpzionale = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_OPZIONALE);
  9614.             String autenticazionePrincipalTipo = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TIPO);
  9615.             TipoAutenticazionePrincipal autenticazionePrincipal = TipoAutenticazionePrincipal.toEnumConstant(autenticazionePrincipalTipo, false);
  9616.             List<String> autenticazioneParametroList = this.convertFromDataElementValue_parametroAutenticazioneList(autenticazione, autenticazionePrincipal);
  9617.            
  9618.             String autorizzazione = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE);
  9619.             String autorizzazioneCustom = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM);
  9620.             String autorizzazioneAutenticati = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE);
  9621.             String autorizzazioneRuoli = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI);
  9622.             String autorizzazioneRuoliTipologia = this.getParameter(CostantiControlStation.PARAMETRO_RUOLO_TIPOLOGIA);
  9623.             String ruoloMatch = this.getParameter(CostantiControlStation.PARAMETRO_RUOLO_MATCH);
  9624.            
  9625.             String autorizzazioneContenutiStato = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_STATO);
  9626.             String autorizzazioneContenuti = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI);
  9627.             String autorizzazioneContenutiProperties = this.getParameter(CostantiControlStation.PARAMETRO_AUTORIZZAZIONE_CONTENUTI_PROPERTIES);
  9628.            
  9629.             // Se autenticazione = custom, nomeauth dev'essere specificato
  9630.             if (CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM.equals(autenticazione) &&
  9631.                     (autenticazioneCustom == null || autenticazioneCustom.equals(""))) {
  9632.                 this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_INDICARE_UN_NOME_PER_AUTENTICAZIONE_XX, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM));
  9633.                 return false;
  9634.             }

  9635.             // Se autorizzazione = custom, nomeautor dev'essere specificato
  9636.             if (CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM.equals(autorizzazione) &&
  9637.                     (autorizzazioneCustom == null || autorizzazioneCustom.equals(""))) {
  9638.                 this.pd.setMessage(MessageFormat.format(AccordiServizioParteSpecificaCostanti.MESSAGGIO_ERRORE_INDICARE_UN_NOME_PER_AUTORIZZAZIONE_XX, CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM));
  9639.                 return false;
  9640.             }
  9641.            
  9642.             PortaDelegata pd = null;
  9643.             if (TipoOperazione.CHANGE == tipoOp){
  9644.                 pd = this.porteDelegateCore.getPortaDelegata(Long.parseLong(idPorta));
  9645.             }
  9646.            
  9647.             List<String> ruoli = new ArrayList<>();
  9648.             if(pd!=null && pd.getRuoli()!=null && pd.getRuoli().sizeRuoloList()>0){
  9649.                 for (int i = 0; i < pd.getRuoli().sizeRuoloList(); i++) {
  9650.                     ruoli.add(pd.getRuoli().getRuolo(i).getNome());
  9651.                 }
  9652.             }
  9653.            
  9654.             String gestioneToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN);
  9655.             String gestioneTokenPolicy = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  9656.             String gestioneTokenValidazioneInput = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  9657.             String gestioneTokenIntrospection = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  9658.             String gestioneTokenUserInfo = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  9659.             String gestioneTokenTokenForward = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  9660.            
  9661.             String autorizzazioneAutenticatiToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE_TOKEN);
  9662.             String autorizzazioneRuoliToken = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_TOKEN);
  9663.            
  9664.             String autorizzazione_token = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN);
  9665.             String autorizzazione_tokenOptions = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_OPTIONS);
  9666.             String autorizzazioneScope = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE);
  9667.             String autorizzazioneScopeMatch = this.getParameter(CostantiControlStation.PARAMETRO_SCOPE_MATCH);
  9668.            
  9669.             BinaryParameter allegatoXacmlPolicy = this.getBinaryParameter(CostantiControlStation.PARAMETRO_DOCUMENTO_SICUREZZA_XACML_POLICY);
  9670.             String protocollo = ProtocolFactoryManager.getInstance().getProtocolByServiceType(asps.getTipo());
  9671.            
  9672.             String identificazioneAttributiStato = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO);
  9673.             String [] attributeAuthoritySelezionate = this.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  9674.             String attributeAuthorityAttributi = this.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI);
  9675.            
  9676.             if(this.controlloAccessiCheck(tipoOp, autenticazione, autenticazioneOpzionale, autenticazionePrincipal, autenticazioneParametroList,
  9677.                     autorizzazione, autorizzazioneAutenticati, autorizzazioneRuoli,
  9678.                     autorizzazioneRuoliTipologia, ruoloMatch,
  9679.                     isSupportatoAutenticazione, true, pd, ruoli,gestioneToken, gestioneTokenPolicy,
  9680.                     gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  9681.                     autorizzazioneAutenticatiToken, autorizzazioneRuoliToken,
  9682.                     autorizzazione_token,autorizzazione_tokenOptions,
  9683.                     autorizzazioneScope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  9684.                     autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties,
  9685.                     protocollo,
  9686.                     identificazioneAttributiStato, attributeAuthoritySelezionate, attributeAuthorityAttributi)==false){
  9687.                 return false;
  9688.             }
  9689.         }
  9690.        
  9691.         return true;
  9692.     }


  9693.     public List<DataElement> addConfigurazioneFruizioneToDati(TipoOperazione tipoOp, List<DataElement> dati,
  9694.             String nome, String nomeGruppo,
  9695.             String [] azioni, String[] azioniDisponibiliList, String[] azioniDisponibiliLabelList, String idAsps,
  9696.             IDSoggetto idSoggettoFruitore, String identificazione, AccordoServizioParteSpecifica asps,
  9697.             AccordoServizioParteComuneSintetico as, ServiceBinding serviceBinding, String modeCreazione, String modeCreazioneConnettore,
  9698.             String[] listaMappingLabels, String[] listaMappingValues, String mapping, String mappingLabel, List<String> saList, String nomeSA,
  9699.             String controlloAccessiStato,
  9700.             String fruizioneAutenticazione, String fruizioneAutenticazioneOpzionale, TipoAutenticazionePrincipal fruizioneAutenticazionePrincipal, List<String> fruizioneAutenticazioneParametroList, boolean erogazioneIsSupportatoAutenticazioneSoggetti,
  9701.             String fruizioneAutorizzazione, String fruizioneAutorizzazioneAutenticati,
  9702.             String fruizioneAutorizzazioneRuoli, String fruizioneRuolo, String fruizioneAutorizzazioneRuoliTipologia,
  9703.             String fruizioneAutorizzazioneRuoliMatch, String fruizioneServizioApplicativo,
  9704.             String gestioneToken, String[] gestioneTokenPolicyLabels, String[] gestioneTokenPolicyValues,
  9705.             String gestioneTokenPolicy, String gestioneTokenOpzionale,
  9706.             String gestioneTokenValidazioneInput, String gestioneTokenIntrospection, String gestioneTokenUserInfo, String gestioneTokenForward,
  9707.             String autenticazioneTokenIssuer,String autenticazioneTokenClientId,String autenticazioneTokenSubject,String autenticazioneTokenUsername,String autenticazioneTokenEMail,
  9708.             String autorizzazioneToken, String autorizzazioneTokenOptions,
  9709.             String autorizzazioneScope,  String scope, String autorizzazioneScopeMatch, BinaryParameter allegatoXacmlPolicy,
  9710.             String identificazioneAttributiStato, String[] attributeAuthorityLabels, String[] attributeAuthorityValues, String [] attributeAuthoritySelezionate, String attributeAuthorityAttributi,
  9711.             String autorizzazioneAutenticatiToken,
  9712.             String autorizzazioneRuoliToken, String autorizzazioneRuoliTipologiaToken, String autorizzazioneRuoliMatchToken) throws Exception{
  9713.        
  9714.         String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  9715.         boolean gestioneFruitori = false;
  9716.         if(tipologia!=null) {
  9717.             if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  9718.                 gestioneFruitori = true;
  9719.             }
  9720.         }
  9721.        
  9722.         Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  9723.        
  9724.         DataElement de = new DataElement();
  9725.         de.setLabel(AccordiServizioParteSpecificaCostanti.LABEL_APS_PORTE_DELEGATE);
  9726.         de.setType(DataElementType.TITLE);
  9727.         dati.add(de);
  9728.        
  9729.         // Nome Gruppo
  9730.         de = new DataElement();
  9731.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME_GRUPPO);
  9732.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME_GRUPPO);
  9733.         de.setValue(nomeGruppo);
  9734.         de.setType(DataElementType.TEXT_EDIT);
  9735.         de.setRequired(true);
  9736.         dati.add(de);
  9737.        
  9738.         // Azione
  9739.         de = new DataElement();
  9740.         de.setLabel(this.getLabelAzioni(serviceBinding));
  9741.         de.setValues(azioniDisponibiliList);
  9742.         de.setLabels(azioniDisponibiliLabelList);
  9743.         de.setSelezionati(azioni);
  9744.         de.setType(DataElementType.MULTI_SELECT);
  9745.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_AZIONI);
  9746.         de.setRows(CostantiControlStation.RIGHE_MULTISELECT_AZIONI);
  9747.         de.setRequired(true);
  9748.         dati.add(de);
  9749.        
  9750.        
  9751.         // Nome
  9752.         de = new DataElement();
  9753.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_NOME);
  9754.         de.setValue(nome);
  9755.         de.setType(DataElementType.HIDDEN);
  9756.         de.setRequired(true);
  9757.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_NOME);
  9758.         dati.add(de);
  9759.        
  9760.         // mode
  9761.         de = new DataElement();
  9762.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODO_CREAZIONE);
  9763.         String[] modeLabels = {PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODO_CREAZIONE_EREDITA,PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODO_CREAZIONE_NUOVA};
  9764.         String[] modeValues = {PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_MODO_CREAZIONE_EREDITA, PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_MODO_CREAZIONE_NUOVA};
  9765.         de.setLabels(modeLabels);
  9766.         de.setValues(modeValues);
  9767.         de.setSelected(modeCreazione);
  9768.         de.setType(DataElementType.SELECT);
  9769.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_CREAZIONE);
  9770.         de.setPostBack(true, true);
  9771.         dati.add(de);
  9772.        
  9773.         //  modo creazione: se erediti la configurazione da una precedente allora devi solo sezionarla, altrimenti devi compilare le sezioni SA e controllo accessi
  9774.         if(modeCreazione.equals(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_MODO_CREAZIONE_EREDITA)) {
  9775.             // mapping
  9776.             de = new DataElement();
  9777.             de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MAPPING_GRUPPO);
  9778.             de.setLabels(listaMappingLabels);
  9779.             de.setValues(listaMappingValues);
  9780.             de.setSelected(mapping);
  9781.             de.setToolTip(mappingLabel);
  9782.             de.setType(DataElementType.SELECT);
  9783.             de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MAPPING);
  9784.             de.setPostBack(true);
  9785.             dati.add(de);
  9786.         }
  9787.        
  9788.         // Controllo se richiedere il connettore
  9789.         boolean connettoreStatic = false;
  9790.         if(gestioneFruitori) {
  9791.             connettoreStatic = this.apsCore.isConnettoreStatic(this.soggettiCore.getProtocolloAssociatoTipoSoggetto(asps.getTipoSoggettoErogatore()));
  9792.         }
  9793.        
  9794.         // mode Connettore
  9795.         de = new DataElement();
  9796.         de.setLabel(PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_MODO_CREAZIONE_CONNETTORE);
  9797.         de.setName(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_MODE_CREAZIONE_CONNETTORE);
  9798.         if(this.isModalitaStandard() || connettoreStatic) {
  9799.             de.setType(DataElementType.HIDDEN);
  9800.             de.setValue(modeCreazione);
  9801.         }
  9802.         else {
  9803.             de.setType(DataElementType.CHECKBOX);
  9804.             de.setSelected(ServletUtils.isCheckBoxEnabled(modeCreazioneConnettore));
  9805.             de.setPostBack(true);
  9806.         }
  9807.         dati.add(de);
  9808.        
  9809.         if(!modeCreazione.equals(PorteDelegateCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_DELEGATE_MODO_CREAZIONE_EREDITA)) {
  9810.            
  9811.             this.controlloAccessiAdd(dati, tipoOp, controlloAccessiStato, false);
  9812.            
  9813.             String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(asps.getTipoSoggettoErogatore());
  9814.            
  9815.             this.controlloAccessiGestioneToken(dati, tipoOp, gestioneToken, gestioneTokenPolicyLabels, gestioneTokenPolicyValues,
  9816.                     gestioneTokenPolicy, gestioneTokenOpzionale,
  9817.                     gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenForward, null,protocollo,true,
  9818.                     false);
  9819.        
  9820.             this.controlloAccessiAutenticazione(dati, tipoOp, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD,null,protocollo,
  9821.                     fruizioneAutenticazione, null, fruizioneAutenticazioneOpzionale, fruizioneAutenticazionePrincipal, fruizioneAutenticazioneParametroList, false, true,true,
  9822.                     gestioneToken, gestioneTokenPolicy, autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  9823.                     false, null, 0,
  9824.                     false, false);
  9825.            
  9826.             this.controlloAccessiAutorizzazione(dati, tipoOp, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD,null,protocollo,
  9827.                 fruizioneAutenticazione, null,
  9828.                 fruizioneAutorizzazione, null,
  9829.                 fruizioneAutorizzazioneAutenticati, null, 0, saList, fruizioneServizioApplicativo,
  9830.                 fruizioneAutorizzazioneRuoli, null, 0, fruizioneRuolo,
  9831.                 fruizioneAutorizzazioneRuoliTipologia, fruizioneAutorizzazioneRuoliMatch,
  9832.                 false, erogazioneIsSupportatoAutenticazioneSoggetti, contaListe, true, false,autorizzazioneScope,null,0,scope,autorizzazioneScopeMatch,
  9833.                 gestioneToken, gestioneTokenPolicy,
  9834.                 autorizzazioneToken, autorizzazioneTokenOptions,allegatoXacmlPolicy,
  9835.                 null, 0 , null, 0,
  9836.                 identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  9837.                 autorizzazioneAutenticatiToken, null, 0,
  9838.                 autorizzazioneRuoliToken, null, 0, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);
  9839.         }
  9840.        
  9841.         return dati;
  9842.     }

  9843.    
  9844.     public List<Parameter> getTitoloAps(TipoOperazione tipoOperazione, AccordoServizioParteSpecifica asps, boolean gestioneFruitori, String labelApsTitle, String servletNameApsChange, boolean addApsChange, String tipoSoggettoFruitore, String nomeSoggettoFruitore) throws Exception {
  9845.        
  9846.         if(tipoOperazione!=null) {
  9847.             // nop
  9848.         }
  9849.        
  9850.         List<Parameter> listaParams = new ArrayList<>();
  9851.        
  9852.         Parameter pIdServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId()+ "");
  9853.         Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  9854.         Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  9855.         Boolean vistaErogazioni = ServletUtils.getBooleanAttributeFromSession(ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI, this.session, this.request).getValue();
  9856.         String labelApsChange = null;
  9857.        
  9858.         List<Parameter> listParametersErogazioniChange = new ArrayList<>();
  9859.         listParametersErogazioniChange.add(pIdServizio);
  9860.         listParametersErogazioniChange.add(pNomeServizio);
  9861.         listParametersErogazioniChange.add(pTipoServizio);
  9862.         if(gestioneFruitori) {
  9863.             Parameter pTipoSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE, tipoSoggettoFruitore);
  9864.             Parameter pNomeSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE, nomeSoggettoFruitore);
  9865.             listParametersErogazioniChange.add(pTipoSoggettoFruitore);
  9866.             listParametersErogazioniChange.add(pNomeSoggettoFruitore);
  9867.         }
  9868.         if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  9869.             if(gestioneFruitori) {
  9870.                 listaParams.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_FRUIZIONI, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST));
  9871.                
  9872.             } else {
  9873.                 listaParams.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_EROGAZIONI, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST));
  9874.             }
  9875.            
  9876.            
  9877.             listaParams.add(new Parameter(labelApsTitle, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_CHANGE, listParametersErogazioniChange));
  9878.            
  9879.             String paramModificaProfilo = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_PROFILO);
  9880.             String paramModificaAPI = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_API);
  9881.             String paramCambiaAPI = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_CAMBIA_API);
  9882.             String paramModificaDescrizione = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MODIFICA_DESCRIZIONE);
  9883.             String paramCambiaErogatore = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_CAMBIA_SOGGETTO_EROGATORE);
  9884.            
  9885.             User user = ServletUtils.getUserFromSession(this.request, this.session);
  9886.             boolean isAccordiCooperazione = user.getPermessi().isAccordiCooperazione();
  9887.             boolean isServizi = user.getPermessi().isServizi();
  9888.             String asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO;
  9889.             if(isServizi && !isAccordiCooperazione){
  9890.                 asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO_SOLO_PARTE_COMUNE;
  9891.             }
  9892.             if(!isServizi  && isAccordiCooperazione){
  9893.                 asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO_SOLO_COMPOSTO;
  9894.             }
  9895.             /**if(isServizi  && isAccordiCooperazione){
  9896.                 asLabel = AccordiServizioParteSpecificaCostanti.LABEL_APC_COMPOSTO;
  9897.             }*/
  9898.            
  9899.             if("true".equals(paramModificaAPI) || "true".equals(paramCambiaAPI)) {
  9900.                 labelApsChange = asLabel;
  9901.             }
  9902.             else if("true".equals(paramCambiaErogatore)) {
  9903.                 labelApsChange = AccordiServizioParteSpecificaCostanti.LABEL_APS_SOGGETTO_EROGATORE;
  9904.             }
  9905.             else if("true".equals(paramModificaProfilo)) {
  9906.                 labelApsChange = AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_PROTOCOLLO;
  9907.             }
  9908.             else if("true".equals(paramModificaDescrizione)) {
  9909.                 labelApsChange = AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_DESCRIZIONE;
  9910.             }
  9911.             else {
  9912.                 labelApsChange = ErogazioniCostanti.LABEL_ASPS_MODIFICA_SERVIZIO_INFO_GENERALI;
  9913.             }
  9914.            
  9915.         } else {
  9916.             if(gestioneFruitori) {
  9917.                 listaParams.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  9918.             }
  9919.             else {
  9920.                 listaParams.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  9921.             }
  9922.             labelApsChange = labelApsTitle;
  9923.         }
  9924.        
  9925.         if(addApsChange) {
  9926.             Parameter parameterApcChange = servletNameApsChange != null ? new Parameter(labelApsChange, servletNameApsChange, listParametersErogazioniChange) : new Parameter(labelApsChange, servletNameApsChange);
  9927.             listaParams.add(parameterApcChange);
  9928.         }
  9929.        
  9930.         return listaParams;
  9931.     }

  9932.     protected ProprietaOggetto creaProprietaOggetto(AccordoServizioParteSpecifica asps, boolean gestioneFruitori, Fruitore fruitore, IDServizio idServizio, IDSoggetto idSoggettoFruitore) {
  9933.         ProprietaOggetto pOggetto = null;
  9934.         if(gestioneFruitori) {
  9935.             pOggetto = ProprietaOggettoRegistro.mergeProprietaOggetto(fruitore.getProprietaOggetto(), idServizio, idSoggettoFruitore, this.porteDelegateCore, this);
  9936.         }
  9937.         else {
  9938.             pOggetto = ProprietaOggettoRegistro.mergeProprietaOggetto(asps.getProprietaOggetto(), idServizio, this.porteApplicativeCore, this.saCore, this);
  9939.         }
  9940.         return pOggetto;
  9941.     }
  9942.    
  9943.    
  9944. }