AccordiServizioParteSpecificaWSDLChange.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.net.URLEncoder;
  22. import java.util.ArrayList;
  23. import java.util.Iterator;
  24. import java.util.List;
  25. import java.util.Map;
  26. import java.util.Properties;

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

  30. import org.apache.commons.lang.StringUtils;
  31. import org.apache.struts.action.Action;
  32. import org.apache.struts.action.ActionForm;
  33. import org.apache.struts.action.ActionForward;
  34. import org.apache.struts.action.ActionMapping;
  35. import org.openspcoop2.core.config.CanaleConfigurazione;
  36. import org.openspcoop2.core.config.CanaliConfigurazione;
  37. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  38. import org.openspcoop2.core.constants.CostantiDB;
  39. import org.openspcoop2.core.constants.TransferLengthModes;
  40. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  41. import org.openspcoop2.core.id.IDServizio;
  42. import org.openspcoop2.core.id.IDSoggetto;
  43. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  44. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  45. import org.openspcoop2.core.registry.Connettore;
  46. import org.openspcoop2.core.registry.PortType;
  47. import org.openspcoop2.core.registry.ProtocolProperty;
  48. import org.openspcoop2.core.registry.Soggetto;
  49. import org.openspcoop2.core.registry.constants.TipologiaServizio;
  50. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  51. import org.openspcoop2.core.registry.driver.db.IDAccordoDB;
  52. import org.openspcoop2.message.constants.ServiceBinding;
  53. import org.openspcoop2.protocol.engine.ProtocolFactoryManager;
  54. import org.openspcoop2.protocol.sdk.constants.ConsoleOperationType;
  55. import org.openspcoop2.protocol.sdk.properties.ProtocolPropertiesUtils;
  56. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  57. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  58. import org.openspcoop2.web.ctrlstat.costanti.ConnettoreServletType;
  59. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  60. import org.openspcoop2.web.ctrlstat.plugins.ExtendedConnettore;
  61. import org.openspcoop2.web.ctrlstat.plugins.servlet.ServletExtendedConnettoreUtils;
  62. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  63. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCore;
  64. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneUtilities;
  65. import org.openspcoop2.web.ctrlstat.servlet.aps.erogazioni.ErogazioniCostanti;
  66. import org.openspcoop2.web.ctrlstat.servlet.archivi.ArchiviCostanti;
  67. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  68. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoreStatusParams;
  69. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCostanti;
  70. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriHelper;
  71. import org.openspcoop2.web.ctrlstat.servlet.protocol_properties.ProtocolPropertiesCostanti;
  72. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  73. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  74. import org.openspcoop2.web.lib.mvc.Costanti;
  75. import org.openspcoop2.web.lib.mvc.DataElement;
  76. import org.openspcoop2.web.lib.mvc.GeneralData;
  77. import org.openspcoop2.web.lib.mvc.PageData;
  78. import org.openspcoop2.web.lib.mvc.Parameter;
  79. import org.openspcoop2.web.lib.mvc.ServletUtils;
  80. import org.openspcoop2.web.lib.mvc.TipoOperazione;
  81. import org.openspcoop2.web.lib.users.dao.PermessiUtente;

  82. /**
  83.  * serviziWSDLChange
  84.  *
  85.  * @author Andrea Poli (apoli@link.it)
  86.  * @author Stefano Corallo (corallo@link.it)
  87.  * @author Sandra Giangrandi (sandra@link.it)
  88.  * @author $Author$
  89.  * @version $Rev$, $Date$
  90.  *
  91.  */
  92. public final class AccordiServizioParteSpecificaWSDLChange extends Action {

  93.     @Override
  94.     public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

  95.         HttpSession session = request.getSession(true);

  96.         // Inizializzo PageData
  97.         PageData pd = new PageData();

  98.         GeneralHelper generalHelper = new GeneralHelper(session);

  99.         // Inizializzo GeneralData
  100.         GeneralData gd = generalHelper.initGeneralData(request);

  101.         IDAccordoFactory idAccordoFactory = IDAccordoFactory.getInstance();

  102.         try {
  103.            
  104.             AccordiServizioParteSpecificaWSDLChangeStrutsBean strutsBean = new AccordiServizioParteSpecificaWSDLChangeStrutsBean();
  105.            
  106.             strutsBean.consoleOperationType = ConsoleOperationType.CHANGE;
  107.                        
  108.             AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);
  109.            
  110.             strutsBean.editMode = apsHelper.getParameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME);
  111.             strutsBean.id = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID);
  112.             strutsBean.tipo = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO);
  113.             strutsBean.wsdl = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL);

  114.             if(apsHelper.isMultipart()){
  115.                 strutsBean.decodeRequestValidazioneDocumenti = true;
  116.             }

  117.             if(ServletUtils.isEditModeInProgress(strutsBean.editMode)){
  118.                 // primo accesso alla servlet
  119.                 strutsBean.validazioneDocumenti = true;
  120.             }else{
  121.                 if(!strutsBean.decodeRequestValidazioneDocumenti){
  122.                     String tmpValidazioneDocumenti = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  123.                     if(Costanti.CHECK_BOX_ENABLED_TRUE.equalsIgnoreCase(tmpValidazioneDocumenti) || Costanti.CHECK_BOX_ENABLED.equalsIgnoreCase(tmpValidazioneDocumenti)){
  124.                         strutsBean.validazioneDocumenti = true;
  125.                     }else{
  126.                         strutsBean.validazioneDocumenti = false;
  127.                     }
  128.                 }
  129.             }

  130.             long idServizioLong = Long.parseLong(strutsBean.id);

  131.             String tipologia = ServletUtils.getObjectFromSession(request, session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  132.             boolean gestioneFruitori = false;
  133.             if(tipologia!=null &&
  134.                 AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  135.                 gestioneFruitori = true;
  136.             }
  137.            
  138.             // Preparo il menu
  139.             apsHelper.makeMenu();

  140.             // Prendo il nome, il tipo e il wsdl attuale del servizio
  141.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore();
  142.             SoggettiCore soggettiCore = new SoggettiCore(apsCore);
  143.             AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore(apsCore);
  144.             ConfigurazioneCore confCore = new ConfigurazioneCore(apsCore);
  145.            
  146.             // carico i canali
  147.             CanaliConfigurazione gestioneCanali = confCore.getCanaliConfigurazione(false);
  148.             List<CanaleConfigurazione> canaleList = gestioneCanali != null ? gestioneCanali.getCanaleList() : new ArrayList<>();
  149.             boolean gestioneCanaliEnabled = gestioneCanali != null && org.openspcoop2.core.config.constants.StatoFunzionalita.ABILITATO.equals(gestioneCanali.getStato());
  150.             String canale = apsHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CANALI_CANALE);
  151.             String canaleStato = apsHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_CANALI_CANALE_STATO);

  152.             AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(idServizioLong);
  153.             String nomeservizio = asps.getNome();
  154.             String tiposervizio = asps.getTipo();
  155.             Integer versioneservizio = asps.getVersione();
  156.        
  157.             String tmpTitle = apsHelper.getLabelIdServizio(asps);

  158.             // Prendo Accordo di servizio parte comune
  159.             AccordoServizioParteComune as = apcCore.getAccordoServizioFull(idAccordoFactory.getIDAccordoFromUri(asps.getAccordoServizioParteComune()));
  160.             ServiceBinding serviceBinding = apcCore.toMessageServiceBinding(as.getServiceBinding());
  161.             org.openspcoop2.protocol.manifest.constants.InterfaceType formatoSpecifica = apcCore.formatoSpecifica2InterfaceType(as.getFormatoSpecifica());
  162.            
  163.             List<String> versioniProtocollo = null;
  164.             String protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(as.getSoggettoReferente().getTipo());
  165.             versioniProtocollo = apsCore.getVersioniProtocollo(protocollo);

  166.             String label = null;
  167.             if(apcCore.isProfiloDiCollaborazioneAsincronoSupportatoDalProtocollo(protocollo,serviceBinding)){
  168.                 if(strutsBean.tipo.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PARAMETRO_WSDL_IMPL_EROGATORE)){
  169.                     label = AccordiServizioParteSpecificaCostanti.LABEL_APS_WSDL_IMPLEMENTATIVO_EROGATORE_DI + tmpTitle;
  170.                 }
  171.                 if(strutsBean.tipo.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PARAMETRO_WSDL_IMPL_FRUITORE)){
  172.                     label = AccordiServizioParteSpecificaCostanti.LABEL_APS_WSDL_IMPLEMENTATIVO_FRUITORE_DI + tmpTitle;
  173.                 }
  174.             }else{
  175.                 label = AccordiServizioParteSpecificaCostanti.LABEL_APS_WSDL_IMPLEMENTATIVO_DI + tmpTitle;
  176.             }
  177.            
  178.             String oldwsdl = "";
  179.             byte[] wsdlbyte = null;
  180.             String tipologiaDocumentoScaricare = null;
  181.             if (strutsBean.tipo.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PARAMETRO_WSDL_IMPL_EROGATORE)) {
  182.                 wsdlbyte = asps.getByteWsdlImplementativoErogatore();
  183.                 tipologiaDocumentoScaricare = ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO_WSDL_IMPLEMENTATIVO_EROGATORE;
  184.             }
  185.             if (strutsBean.tipo.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PARAMETRO_WSDL_IMPL_FRUITORE)) {
  186.                 wsdlbyte = asps.getByteWsdlImplementativoFruitore();
  187.                 tipologiaDocumentoScaricare = ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO_WSDL_IMPLEMENTATIVO_FRUITORE;
  188.             }
  189.             if (wsdlbyte != null) {
  190.                 oldwsdl = new String(wsdlbyte);
  191.             }
  192.             Soggetto soggettoErogatoreID = soggettiCore.getSoggettoRegistro(new IDSoggetto(asps.getTipoSoggettoErogatore(),asps.getNomeSoggettoErogatore()));


  193.             Parameter parameterAPSChange = new Parameter( tmpTitle,
  194.                     AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE ,
  195.                     new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, ""+strutsBean.id),
  196.                     new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, nomeservizio),
  197.                     new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, tiposervizio),
  198.                     new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VERSIONE, versioneservizio+""),
  199.                     new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, soggettoErogatoreID.getId()+"")
  200.                     );
  201.            
  202.             String tipoSoggettoFruitore = null;
  203.             String nomeSoggettoFruitore = null;
  204.             Parameter pTipoSoggettoFruitore = null;
  205.             Parameter pNomeSoggettoFruitore = null;
  206.             if(gestioneFruitori) {
  207.                 tipoSoggettoFruitore = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE);
  208.                 nomeSoggettoFruitore = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE);
  209.                 pTipoSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE, tipoSoggettoFruitore);
  210.                 pNomeSoggettoFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE, nomeSoggettoFruitore);
  211.             }
  212.            
  213.             List<Parameter> lstParm = new ArrayList<>();
  214.             Boolean vistaErogazioni = ServletUtils.getBooleanAttributeFromSession(ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI, session, request).getValue();
  215.             if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  216.                 if(gestioneFruitori) {
  217.                     lstParm.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_FRUIZIONI, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST));
  218.                 } else {
  219.                     lstParm.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_EROGAZIONI, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_LIST));
  220.                 }
  221.                 List<Parameter> listErogazioniChange = new ArrayList<>();
  222.                 Parameter pIdServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId()+ "");
  223.                 Parameter pNomeServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SERVIZIO, asps.getNome());
  224.                 Parameter pTipoServizio = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SERVIZIO, asps.getTipo());
  225.                 listErogazioniChange.add(pIdServizio);
  226.                 listErogazioniChange.add(pNomeServizio);
  227.                 listErogazioniChange.add(pTipoServizio);
  228.                 if(gestioneFruitori) {
  229.                     listErogazioniChange.add(pNomeSoggettoFruitore);
  230.                     listErogazioniChange.add(pTipoSoggettoFruitore);
  231.                 }
  232.                 lstParm.add(new Parameter(tmpTitle, ErogazioniCostanti.SERVLET_NAME_ASPS_EROGAZIONI_CHANGE,
  233.                         listErogazioniChange.toArray(new Parameter[1])));
  234.                
  235.                 lstParm.add(new Parameter(ErogazioniCostanti.LABEL_ASPS_MODIFICA_SERVIZIO_INFO_GENERALI, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE,
  236.                         listErogazioniChange.toArray(new Parameter[1])));
  237.                
  238.             } else {
  239.                 if(gestioneFruitori) {
  240.                     lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  241.                 }
  242.                 else {
  243.                     lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  244.                 }
  245.                
  246.                 lstParm.add(parameterAPSChange);
  247.             }
  248.            
  249.             lstParm.add(new Parameter(label , null));
  250.            

  251.             if (ServletUtils.isEditModeInProgress(strutsBean.editMode) && apsHelper.isEditModeInProgress()) {

  252.                 // setto la barra del titolo
  253.                 ServletUtils.setPageDataTitle(pd, lstParm );

  254.                 // preparo i campi
  255.                 List<DataElement> dati = new ArrayList<>();
  256.                 dati.add(ServletUtils.getDataElementForEditModeFinished());
  257.                
  258.                 dati = apsHelper.addHiddenFieldsToDati(TipoOperazione.OTHER, strutsBean.id, null, null, null,
  259.                         null, tipoSoggettoFruitore, nomeSoggettoFruitore, dati);

  260.                 dati = apsHelper.addWSDLToDati(TipoOperazione.OTHER, apsHelper.getSize(), asps, oldwsdl, strutsBean.tipo, strutsBean.validazioneDocumenti,
  261.                         dati, tipologiaDocumentoScaricare, label);

  262.                 pd.setDati(dati);

  263.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  264.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS,
  265.                         AccordiServizioParteSpecificaCostanti.TIPO_OPERAZIONE_WSDL_CHANGE);
  266.             }

  267.             // Controlli sui campi immessi
  268.             boolean isOk = apsHelper.accordiParteSpecificaWSDLCheckData(pd, strutsBean.tipo, strutsBean.wsdl, asps, as, strutsBean.validazioneDocumenti);
  269.             if (!isOk) {

  270.                 // setto la barra del titolo
  271.                 ServletUtils.setPageDataTitle(pd, lstParm );

  272.                 // preparo i campi
  273.                 List<DataElement> dati = new ArrayList<>();

  274.                 dati.add(ServletUtils.getDataElementForEditModeFinished());

  275.                 dati = apsHelper.addHiddenFieldsToDati(TipoOperazione.OTHER, strutsBean.id, null, null, null,
  276.                         null, tipoSoggettoFruitore, nomeSoggettoFruitore, dati);

  277.                 dati = apsHelper.addWSDLToDati(TipoOperazione.OTHER,  apsHelper.getSize(), asps, oldwsdl, strutsBean.tipo, strutsBean.validazioneDocumenti,
  278.                         dati, tipologiaDocumentoScaricare, label);

  279.                 pd.setDati(dati);

  280.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  281.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS,
  282.                         AccordiServizioParteSpecificaCostanti.TIPO_OPERAZIONE_WSDL_CHANGE);
  283.             }

  284.             // Modifico i dati del wsdl del servizio nel db
  285.             if (strutsBean.tipo.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PARAMETRO_WSDL_IMPL_EROGATORE)) {
  286.                 asps.setByteWsdlImplementativoErogatore(strutsBean.wsdl.getBytes());
  287.             }
  288.             if (strutsBean.tipo.equals(AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_PARAMETRO_WSDL_IMPL_FRUITORE)) {
  289.                 asps.setByteWsdlImplementativoFruitore(strutsBean.wsdl.getBytes());
  290.             }

  291.             // effettuo le operazioni
  292.             String superUser = ServletUtils.getUserLoginFromSession(session);
  293.             apsCore.performUpdateOperation(superUser, apsHelper.smista(), asps);

  294.             // visualizzo la schermata di modifica del servizio
  295.             // setto la barra del titolo
  296.            
  297.             Parameter p = null;
  298.             if(gestioneFruitori) {
  299.                 p = new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FRUITORI, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST);
  300.             }
  301.             else {
  302.                 p = new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST);
  303.             }
  304.            
  305.             ServletUtils.setPageDataTitle(pd,
  306.                     p,
  307.                     new Parameter(tmpTitle, null)                   );

  308.             AccordoServizioParteSpecifica aspsT = apsCore.getAccordoServizioParteSpecifica(Long.parseLong(strutsBean.id));

  309.             String[] ptList = null;
  310.             String[] soggettiList = null;
  311.             String[] soggettiListLabel = null;
  312.             String[] accordiList = null;
  313.             String[] accordiListLabel = null;
  314.             // soggetti
  315.             List<Soggetto> list = soggettiCore.soggettiRegistroList("", new ConsoleSearch(true));
  316.             List<String> tipiServizi = apsCore.getTipiServiziGestitiProtocollo(protocollo,serviceBinding);
  317.             if (!list.isEmpty()) {
  318.                 soggettiList = new String[list.size()];
  319.                 soggettiListLabel = new String[list.size()];
  320.                 int i = 0;
  321.                 for (Soggetto soggetto : list) {
  322.                     soggettiList[i] = soggetto.getId().toString();
  323.                     soggettiListLabel[i] = soggetto.getTipo() + "/" + soggetto.getNome();
  324.                     i++;
  325.                 }
  326.             }

  327.             // accordi
  328.             PermessiUtente pu = ServletUtils.getUserFromSession(request, session).getPermessi();

  329.             boolean [] permessi = new boolean[2];
  330.             permessi[0] = pu.isServizi();
  331.             permessi[1] = pu.isAccordiCooperazione();
  332.             List<IDAccordoDB> listIdAccordi =  
  333.                     AccordiServizioParteComuneUtilities.idAccordiListFromPermessiUtente(apcCore, superUser, new ConsoleSearch(true), permessi, false, false);

  334.             if (!listIdAccordi.isEmpty()) {
  335.                 accordiList = new String[listIdAccordi.size()];
  336.                 accordiListLabel = new String[listIdAccordi.size()];
  337.                 int i = 0;
  338.                 for (IDAccordoDB accordoServizio : listIdAccordi) {
  339.                     accordiList[i] = accordoServizio.getId().toString();
  340.                     accordiListLabel[i] = accordoServizio.getNome();
  341.                     i++;
  342.                 }
  343.             }

  344.             String nomeSoggettoErogatore = aspsT.getNomeSoggettoErogatore();
  345.             String tipoSoggettoErogatore = aspsT.getTipoSoggettoErogatore();
  346.             String servcorr = "";
  347.             if (TipologiaServizio.CORRELATO.equals(aspsT.getTipologiaServizio()))
  348.                 servcorr = Costanti.CHECK_BOX_ENABLED;
  349.             else
  350.                 servcorr = Costanti.CHECK_BOX_DISABLED;
  351.             String accordo = aspsT.getIdAccordo().toString();
  352.             String profilo = aspsT.getVersioneProtocollo();
  353.             String portType = aspsT.getPortType();
  354.             String descrizione = aspsT.getDescrizione();
  355.             String statoPackage = aspsT.getStatoPackage();
  356.            
  357.             Connettore connettore = aspsT.getConfigurazioneServizio().getConnettore();

  358.             String connettoreDebug = null;
  359.             String endpointtype = null;
  360.             String tipoconn = null;
  361.             String autenticazioneHttp = null;
  362.             String url = null;
  363.             String nome = null;
  364.             String initcont = null;
  365.             String urlpgk = null;
  366.             String provurl = null;
  367.             String connfact = null;
  368.             String sendas = null;
  369.             String provider = "";
  370.             String user = "";
  371.             String password = "";
  372.            
  373.             String autenticazioneApiKey = null;
  374.             boolean useOAS3Names=true;
  375.             boolean useAppId=false;
  376.             String apiKeyHeader = null;
  377.             String apiKeyValue = null;
  378.             String appIdHeader = null;
  379.             String appIdValue = null;
  380.            
  381.             String httpsurl = null;
  382.             String httpstipologia = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TYPE ;
  383.             boolean httpshostverify = true;
  384.             boolean httpsTrustVerifyCert = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS;
  385.             String httpspath = "";
  386.             String httpstipo = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TIPOLOGIA_KEYSTORE_TYPE;
  387.             String httpspwd = "";
  388.             String httpsalgoritmo = "";
  389.             boolean httpsstato = false;
  390.             String httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_DEFAULT;
  391.             String httpspwdprivatekeytrust = "";
  392.             String httpspathkey = "";
  393.             String httpstipokey = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TIPOLOGIA_KEYSTORE_TYPE;
  394.             String httpspwdkey = "";
  395.             String httpspwdprivatekey = "";
  396.             String httpsalgoritmokey = "";
  397.             String httpsKeyAlias = null;
  398.             String httpsTrustStoreCRLs = null;
  399.             String httpsTrustStoreOCSPPolicy = null;
  400.             String httpsKeyStoreBYOKPolicy = null;
  401.             boolean autenticazioneToken = false;
  402.             String tokenPolicy = null;
  403.             boolean forcePDND = false;
  404.             boolean forceOAuth = false;
  405.             String proxyEnabled = null;
  406.             String proxyHostname  = null;
  407.             String proxyPort  = null;
  408.             String proxyUsername  = null;
  409.             String proxyPassword = null;
  410.             String tempiRispostaEnabled = null;
  411.             String tempiRispostaConnectionTimeout = null;
  412.             String tempiRispostaReadTimeout = null;
  413.             String tempiRispostaTempoMedioRisposta = null;
  414.             String transferMode = null;
  415.             String transferModeChunkSize = null;
  416.             String redirectMode = null;
  417.             String redirectMaxHop = null;
  418.             String opzioniAvanzate = null;
  419.             // file
  420.             String requestOutputFileName = null;
  421.             String requestOutputFileNamePermissions = null;
  422.             String requestOutputFileNameHeaders = null;
  423.             String requestOutputFileNameHeadersPermissions = null;
  424.             String requestOutputParentDirCreateIfNotExists = null;
  425.             String requestOutputOverwriteIfExists = null;
  426.             String responseInputMode = null;
  427.             String responseInputFileName = null;
  428.             String responseInputFileNameHeaders = null;
  429.             String responseInputDeleteAfterRead = null;
  430.             String responseInputWaitTime = null;
  431.            
  432.             ConnettoreStatusParams connettoreStatusParams = null;
  433.            
  434.             String servizioApplicativoServer = null;
  435.             boolean servizioApplicativoServerEnabled = false;
  436.             if ((endpointtype == null) || (url == null) || (nome == null)) {
  437.                 Map<String, String> props = connettore.getProperties();

  438.                 if (endpointtype == null) {
  439.                     if ((connettore.getCustom()!=null && connettore.getCustom()) &&
  440.                             !connettore.getTipo().equals(CostantiDB.CONNETTORE_TIPO_HTTPS) &&
  441.                             !connettore.getTipo().equals(CostantiDB.CONNETTORE_TIPO_FILE) &&
  442.                             !connettore.getTipo().equals(CostantiDB.CONNETTORE_TIPO_STATUS)) {
  443.                         endpointtype = ConnettoriCostanti.DEFAULT_CONNETTORE_TYPE_CUSTOM;
  444.                         tipoconn = connettore.getTipo();
  445.                     } else
  446.                         endpointtype = connettore.getTipo();
  447.                 }
  448.                 autenticazioneHttp = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTP);
  449.                 String userTmp = null;
  450.                 if(props!=null) {
  451.                     userTmp = props.get(CostantiDB.CONNETTORE_USER);
  452.                 }
  453.                 if(userTmp!=null && !"".equals(userTmp)){
  454.                     user = userTmp;
  455.                 }
  456.                 String passwordTmp = null;
  457.                 if(props!=null) {
  458.                         passwordTmp = props.get(CostantiDB.CONNETTORE_PWD);
  459.                 }
  460.                 if(passwordTmp!=null && !"".equals(passwordTmp)){
  461.                     password = passwordTmp;
  462.                 }
  463.                 autenticazioneHttp = apsHelper.getAutenticazioneHttp(autenticazioneHttp, endpointtype, user);
  464.                
  465.                 if(autenticazioneApiKey==null || StringUtils.isEmpty(autenticazioneApiKey)) {
  466.                     if(props!=null) {
  467.                         apiKeyHeader = props.get(CostantiDB.CONNETTORE_APIKEY_HEADER);
  468.                         apiKeyValue = props.get(CostantiDB.CONNETTORE_APIKEY);
  469.                         appIdHeader = props.get(CostantiDB.CONNETTORE_APIKEY_APPID_HEADER);
  470.                         appIdValue = props.get(CostantiDB.CONNETTORE_APIKEY_APPID);
  471.                     }
  472.                    
  473.                     autenticazioneApiKey = apsHelper.getAutenticazioneApiKey(autenticazioneApiKey, endpointtype, apiKeyValue);
  474.                     if(ServletUtils.isCheckBoxEnabled(autenticazioneApiKey)) {
  475.                         useOAS3Names = apsHelper.isAutenticazioneApiKeyUseOAS3Names(apiKeyHeader, appIdHeader);
  476.                         useAppId = apsHelper.isAutenticazioneApiKeyUseAppId(appIdValue);
  477.                     }
  478.                     else {
  479.                         apiKeyValue=null;
  480.                         apiKeyHeader=null;
  481.                         appIdHeader=null;
  482.                         appIdValue=null;
  483.                     }
  484.                 }
  485.                
  486.                 if(connettoreDebug==null && props!=null){
  487.                     String v = props.get(CostantiDB.CONNETTORE_DEBUG);
  488.                     if(v!=null){
  489.                         if("true".equals(v)){
  490.                             connettoreDebug = Costanti.CHECK_BOX_ENABLED;
  491.                         }
  492.                         else{
  493.                             connettoreDebug = Costanti.CHECK_BOX_DISABLED;
  494.                         }
  495.                     }
  496.                 }
  497.                                
  498.                 // proxy
  499.                 if(proxyEnabled==null && props!=null){
  500.                     String v = props.get(CostantiDB.CONNETTORE_PROXY_TYPE);
  501.                     if(v!=null && !"".equals(v)){
  502.                         proxyEnabled = Costanti.CHECK_BOX_ENABLED_TRUE;
  503.                        
  504.                         // raccolgo anche altre proprietà
  505.                         v = props.get(CostantiDB.CONNETTORE_PROXY_HOSTNAME);
  506.                         if(v!=null && !"".equals(v)){
  507.                             proxyHostname = v.trim();
  508.                         }
  509.                         v = props.get(CostantiDB.CONNETTORE_PROXY_PORT);
  510.                         if(v!=null && !"".equals(v)){
  511.                             proxyPort = v.trim();
  512.                         }
  513.                         v = props.get(CostantiDB.CONNETTORE_PROXY_USERNAME);
  514.                         if(v!=null && !"".equals(v)){
  515.                             proxyUsername = v.trim();
  516.                         }
  517.                         v = props.get(CostantiDB.CONNETTORE_PROXY_PASSWORD);
  518.                         if(v!=null && !"".equals(v)){
  519.                             proxyPassword = v.trim();
  520.                         }
  521.                     }
  522.                 }
  523.                
  524.                 // tempiRisposta
  525.                 if(tempiRispostaEnabled == null ||
  526.                         tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout)
  527.                         ||
  528.                         tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout)
  529.                         ||
  530.                         tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ){
  531.                    
  532.                     ConfigurazioneCore configCore = new ConfigurazioneCore(soggettiCore);
  533.                     ConfigurazioneGenerale configGenerale = configCore.getConfigurazioneControlloTraffico();
  534.                    
  535.                     if( props!=null ) {
  536.                         if(tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout) ) {
  537.                             String v = props.get(CostantiDB.CONNETTORE_CONNECTION_TIMEOUT);
  538.                             if(v!=null && !"".equals(v)){
  539.                                 tempiRispostaConnectionTimeout = v.trim();
  540.                                 tempiRispostaEnabled =  Costanti.CHECK_BOX_ENABLED_TRUE;
  541.                             }
  542.                             else {
  543.                                 tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaFruizione().getConnectionTimeout().intValue()+"";
  544.                             }
  545.                         }
  546.                            
  547.                         if(tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout) ) {
  548.                             String v = props.get(CostantiDB.CONNETTORE_READ_CONNECTION_TIMEOUT);
  549.                             if(v!=null && !"".equals(v)){
  550.                                 tempiRispostaReadTimeout = v.trim();
  551.                                 tempiRispostaEnabled =  Costanti.CHECK_BOX_ENABLED_TRUE;
  552.                             }
  553.                             else {
  554.                                 tempiRispostaReadTimeout = configGenerale.getTempiRispostaFruizione().getReadTimeout().intValue()+"";
  555.                             }
  556.                         }
  557.                        
  558.                         if(tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ) {
  559.                             String v = props.get(CostantiDB.CONNETTORE_TEMPO_MEDIO_RISPOSTA);
  560.                             if(v!=null && !"".equals(v)){
  561.                                 tempiRispostaTempoMedioRisposta = v.trim();
  562.                                 tempiRispostaEnabled =  Costanti.CHECK_BOX_ENABLED_TRUE;
  563.                             }
  564.                             else {
  565.                                 tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaFruizione().getTempoMedioRisposta().intValue()+"";
  566.                             }
  567.                         }
  568.                     }
  569.                     else {
  570.                         if(tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout) ) {
  571.                             tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaFruizione().getConnectionTimeout().intValue()+"";
  572.                         }
  573.                         if(tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout) ) {
  574.                             tempiRispostaReadTimeout = configGenerale.getTempiRispostaFruizione().getReadTimeout().intValue()+"";
  575.                         }
  576.                         if(tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ) {
  577.                             tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaFruizione().getTempoMedioRisposta().intValue()+"";
  578.                         }
  579.                     }
  580.                 }
  581.                
  582.                 // opzioni avanzate
  583.                 if(transferMode==null && props!=null){
  584.                     String v = props.get(CostantiDB.CONNETTORE_HTTP_DATA_TRANSFER_MODE);
  585.                     if(v!=null && !"".equals(v)){
  586.                        
  587.                         transferMode = v.trim();
  588.                        
  589.                         if(TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome().equals(transferMode)){
  590.                             // raccolgo anche altra proprietà correlata
  591.                             v = props.get(CostantiDB.CONNETTORE_HTTP_DATA_TRANSFER_MODE_CHUNK_SIZE);
  592.                             if(v!=null && !"".equals(v)){
  593.                                 transferModeChunkSize = v.trim();
  594.                             }
  595.                         }
  596.                        
  597.                     }
  598.                 }
  599.                
  600.                 if(redirectMode==null && props!=null){
  601.                     String v = props.get(CostantiDB.CONNETTORE_HTTP_REDIRECT_FOLLOW);
  602.                     if(v!=null && !"".equals(v)){
  603.                        
  604.                         if("true".equalsIgnoreCase(v.trim()) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v.trim())){
  605.                             redirectMode = CostantiConfigurazione.ABILITATO.getValue();
  606.                         }
  607.                         else{
  608.                             redirectMode = CostantiConfigurazione.DISABILITATO.getValue();
  609.                         }                  
  610.                        
  611.                         if(CostantiConfigurazione.ABILITATO.getValue().equals(redirectMode)){
  612.                             // raccolgo anche altra proprietà correlata
  613.                             v = props.get(CostantiDB.CONNETTORE_HTTP_REDIRECT_MAX_HOP);
  614.                             if(v!=null && !"".equals(v)){
  615.                                 redirectMaxHop = v.trim();
  616.                             }
  617.                         }
  618.                        
  619.                     }
  620.                 }
  621.                
  622.                 if(tokenPolicy==null && props!=null){
  623.                     String v = props.get(CostantiDB.CONNETTORE_TOKEN_POLICY);
  624.                     if(v!=null && !"".equals(v)){
  625.                         tokenPolicy = v;
  626.                         autenticazioneToken = true;
  627.                     }
  628.                 }
  629.                
  630.                 opzioniAvanzate = ConnettoriHelper.getOpzioniAvanzate(apsHelper, transferMode, redirectMode);
  631.                
  632.                 // http
  633.                 if (url == null && props!=null) {
  634.                     url = props.get(CostantiDB.CONNETTORE_HTTP_LOCATION);
  635.                 }
  636.                
  637.                 // jms
  638.                 if (nome == null && props!=null) {
  639.                     nome = props.get(CostantiDB.CONNETTORE_JMS_NOME);
  640.                     strutsBean.tipo = props.get(CostantiDB.CONNETTORE_JMS_TIPO);
  641.                     initcont = props.get(CostantiDB.CONNETTORE_JMS_CONTEXT_JAVA_NAMING_FACTORY_INITIAL);
  642.                     urlpgk = props.get(CostantiDB.CONNETTORE_JMS_CONTEXT_JAVA_NAMING_FACTORY_URL_PKG);
  643.                     provurl = props.get(CostantiDB.CONNETTORE_JMS_CONTEXT_JAVA_NAMING_PROVIDER_URL);
  644.                     connfact = props.get(CostantiDB.CONNETTORE_JMS_CONNECTION_FACTORY);
  645.                     sendas = props.get(CostantiDB.CONNETTORE_JMS_SEND_AS);
  646.                    
  647.                 }
  648.                 if (httpsurl == null && props!=null) {
  649.                     httpsurl = props.get(CostantiDB.CONNETTORE_HTTPS_LOCATION);
  650.                     httpstipologia = props.get(CostantiDB.CONNETTORE_HTTPS_SSL_TYPE);
  651.                     httpshostverify = Boolean.valueOf(props.get(CostantiDB.CONNETTORE_HTTPS_HOSTNAME_VERIFIER));
  652.                     String httpsTrustVerifyCertS = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_ALL_CERTS);
  653.                     if(httpsTrustVerifyCertS!=null){
  654.                         httpsTrustVerifyCert = !Boolean.valueOf(httpsTrustVerifyCertS);
  655.                     }
  656.                     else {
  657.                         httpsTrustVerifyCert = true; // backward compatibility
  658.                     }
  659.                     httpspath = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_LOCATION);
  660.                     httpstipo = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_TYPE);
  661.                     httpspwd = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_PASSWORD);
  662.                     httpsalgoritmo = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_MANAGEMENT_ALGORITM);
  663.                     httpspwdprivatekeytrust = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_PASSWORD);
  664.                     httpspathkey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_LOCATION);
  665.                     httpstipokey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_TYPE);
  666.                     httpspwdkey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_PASSWORD);
  667.                     httpspwdprivatekey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_PASSWORD);
  668.                     httpsalgoritmokey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM);
  669.                     httpsKeyAlias = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_ALIAS);
  670.                     httpsTrustStoreCRLs = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_CRLS);
  671.                     httpsTrustStoreOCSPPolicy = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY);
  672.                     httpsKeyStoreBYOKPolicy = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY);
  673.                     if (httpspathkey == null) {
  674.                         httpsstato = false;
  675.                         httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_DEFAULT;
  676.                     } else {
  677.                         httpsstato = true;
  678.                         if (httpspathkey.equals(httpspath) &&
  679.                                 httpstipokey.equals(httpstipo) &&
  680.                                 (
  681.                                     (httpspwdkey!=null && httpspwdkey.equals(httpspwd))
  682.                                     ||
  683.                                     (httpspwdkey==null && httpspwd==null)
  684.                                 )
  685.                                 &&
  686.                                 httpsalgoritmokey.equals(httpsalgoritmo))
  687.                             httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_DEFAULT;
  688.                         else
  689.                             httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_RIDEFINISCI;
  690.                     }
  691.                 }
  692.                
  693.                 // file
  694.                 if(responseInputMode==null && props!=null){
  695.                    
  696.                     requestOutputFileName = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE);  
  697.                     requestOutputFileNamePermissions = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE_PERMISSIONS);  
  698.                     requestOutputFileNameHeaders = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE_HEADERS);  
  699.                     requestOutputFileNameHeadersPermissions = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE_HEADERS_PERMISSIONS);
  700.                     String v = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_AUTO_CREATE_DIR);
  701.                     if(v!=null && !"".equals(v) &&
  702.                         ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  703.                         ){
  704.                         requestOutputParentDirCreateIfNotExists = Costanti.CHECK_BOX_ENABLED_TRUE;
  705.                     }                  
  706.                     v = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_OVERWRITE_FILE);
  707.                     if(v!=null && !"".equals(v) &&
  708.                         ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  709.                         ){
  710.                         requestOutputOverwriteIfExists = Costanti.CHECK_BOX_ENABLED_TRUE;
  711.                     }  
  712.                    
  713.                     v = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_MODE);
  714.                     if(v!=null && !"".equals(v) &&
  715.                         ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  716.                         ){
  717.                         responseInputMode = CostantiConfigurazione.ABILITATO.getValue();
  718.                     }
  719.                     if(CostantiConfigurazione.ABILITATO.getValue().equals(responseInputMode)){                      
  720.                         responseInputFileName = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_FILE);
  721.                         responseInputFileNameHeaders = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_FILE_HEADERS);
  722.                         v = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_FILE_DELETE_AFTER_READ);
  723.                         if(v!=null && !"".equals(v) &&
  724.                             ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  725.                             ){
  726.                             responseInputDeleteAfterRead = Costanti.CHECK_BOX_ENABLED_TRUE;
  727.                         }                      
  728.                         responseInputWaitTime = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME);                    
  729.                     }
  730.                    
  731.                 }
  732.                
  733.                 // status
  734.                 connettoreStatusParams = ConnettoreStatusParams.fillFrom(props);
  735.             }

  736.             Boolean isConnettoreCustomUltimaImmagineSalvata = connettore.getCustom();
  737.            
  738.             List<ExtendedConnettore> listExtendedConnettore =
  739.                     ServletExtendedConnettoreUtils.getExtendedConnettore(connettore, ConnettoreServletType.ACCORDO_SERVIZIO_PARTE_SPECIFICA_CHANGE, apsHelper,
  740.                             true, null);
  741.            
  742.             // Lista port-type associati all'accordo di servizio
  743.             // se l'accordo e' selezionato allora prendo quello selezionato
  744.             // altrimenti il primo
  745.             // della lista
  746.             if (accordo != null && !"".equals(accordo)) {
  747.                 as = apcCore.getAccordoServizioFull(Long.parseLong(accordo));
  748.             } else {
  749.                 as = apcCore.getAccordoServizioFull(idAccordoFactory.getIDAccordoFromUri(aspsT.getAccordoServizioParteComune()));
  750.             }
  751.            
  752.             String canaleAPI = as != null ? as.getCanale() : null;  

  753.             if(as!=null) {
  754.                 List<PortType> portTypes = apcCore.accordiPorttypeList(as.getId().intValue(), new ConsoleSearch(true));
  755.                 if (!portTypes.isEmpty()) {
  756.                     ptList = new String[portTypes.size() + 1];
  757.                     ptList[0] = "-";
  758.                     int i = 1;
  759.                     for (Iterator<PortType> iterator = portTypes.iterator(); iterator.hasNext();) {
  760.                         PortType portType2 = iterator.next();
  761.                         ptList[i] = portType2.getNome();
  762.                         i++;
  763.                     }
  764.                 }
  765.             }
  766.            
  767.             strutsBean.wsdlimpler = new BinaryParameter();
  768.             strutsBean.wsdlimplfru = new BinaryParameter();
  769.            
  770.             strutsBean.protocolFactory = ProtocolFactoryManager.getInstance().getProtocolFactoryByName(protocollo);
  771.             strutsBean.consoleDynamicConfiguration =  strutsBean.protocolFactory.createDynamicConfigurationConsole();
  772.             strutsBean.registryReader = soggettiCore.getRegistryReader(strutsBean.protocolFactory);
  773.             strutsBean.configRegistryReader = soggettiCore.getConfigIntegrationReader(strutsBean.protocolFactory);
  774.             IDServizio idAps = apsHelper.getIDServizioFromValues(tiposervizio, nomeservizio, tipoSoggettoErogatore,nomeSoggettoErogatore, versioneservizio+"");
  775.             idAps.setPortType(asps.getPortType());
  776.             strutsBean.consoleConfiguration = strutsBean.consoleDynamicConfiguration.getDynamicConfigAccordoServizioParteSpecifica(strutsBean.consoleOperationType, apsHelper,
  777.                     strutsBean.registryReader, strutsBean.configRegistryReader, idAps );
  778.                    
  779.             List<ProtocolProperty> oldProtocolPropertyList = null;
  780.             if(as!=null) {
  781.                 oldProtocolPropertyList = as.getProtocolPropertyList();
  782.             }
  783.             strutsBean.protocolProperties = apsHelper.estraiProtocolPropertiesDaRequest(strutsBean.consoleConfiguration, strutsBean.consoleOperationType);
  784.             ProtocolPropertiesUtils.mergeProtocolPropertiesRegistry(strutsBean.protocolProperties, oldProtocolPropertyList, strutsBean.consoleOperationType);
  785.            
  786.             Properties propertiesProprietario = new Properties();
  787.             propertiesProprietario.setProperty(ProtocolPropertiesCostanti.PARAMETRO_PP_ID_PROPRIETARIO, strutsBean.id);
  788.             propertiesProprietario.setProperty(ProtocolPropertiesCostanti.PARAMETRO_PP_TIPO_PROPRIETARIO, ProtocolPropertiesCostanti.PARAMETRO_PP_TIPO_PROPRIETARIO_VALUE_ACCORDO_SERVIZIO_PARTE_SPECIFICA);
  789.             propertiesProprietario.setProperty(ProtocolPropertiesCostanti.PARAMETRO_PP_NOME_PROPRIETARIO, tmpTitle);
  790.             propertiesProprietario.setProperty(ProtocolPropertiesCostanti.PARAMETRO_PP_URL_ORIGINALE_CHANGE,
  791.                     URLEncoder.encode(parameterAPSChange.getValue(), "UTF-8"));
  792.             propertiesProprietario.setProperty(ProtocolPropertiesCostanti.PARAMETRO_PP_PROTOCOLLO, protocollo);
  793.             propertiesProprietario.setProperty(ProtocolPropertiesCostanti.PARAMETRO_PP_TIPO_ACCORDO, "");
  794.            
  795.             // preparo i campi
  796.             List<DataElement> dati = new ArrayList<>();

  797.             dati = apsHelper.addHiddenFieldsToDati(TipoOperazione.OTHER, strutsBean.id, null, null, dati);

  798.             dati = apsHelper.addServiziToDati(dati, nomeservizio, tiposervizio, null, null,
  799.                     provider, tipoSoggettoErogatore , nomeSoggettoErogatore, soggettiList,
  800.                     soggettiListLabel, accordo, serviceBinding, formatoSpecifica,
  801.                     accordiList, accordiListLabel, servcorr, strutsBean.wsdlimpler, strutsBean.wsdlimplfru,
  802.                     TipoOperazione.CHANGE, strutsBean.id, tipiServizi, profilo, portType, ptList,
  803.                     (aspsT.getPrivato()!=null && aspsT.getPrivato()),idAccordoFactory.getUriFromAccordo(as),
  804.                     descrizione, null,
  805.                     soggettoErogatoreID.getId(), statoPackage,statoPackage,
  806.                     versioneservizio.intValue()+"", versioniProtocollo,strutsBean.validazioneDocumenti,
  807.                     null,null,true,null,
  808.                     null,
  809.                     null,null,null,null,null,null,false,
  810.                     null,null,null,null,null,null,null,
  811.                     protocollo, null,
  812.                     null, null, null, tipoSoggettoFruitore, nomeSoggettoFruitore,
  813.                     null, null, null, null, null,
  814.                     null, null, null, null,
  815.                     null,null,null,null,null,null,null,null,null,
  816.                     null,null, null,
  817.                     null,null,null,null,null,
  818.                     null,null,
  819.                     null,null,null,null,false, canaleStato, canaleAPI, canale, canaleList, gestioneCanaliEnabled,
  820.                     null,null,null,null,null,
  821.                     null,
  822.                     null, null, null);

  823.             boolean postBackViaPost = false;
  824.            
  825.             dati = apsHelper.addEndPointToDati(dati, serviceBinding, connettoreDebug, endpointtype, autenticazioneHttp, null,
  826.                     url, nome,
  827.                     strutsBean.tipo, user, password, initcont, urlpgk, provurl,
  828.                     connfact, sendas, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS,TipoOperazione.CHANGE,
  829.                     httpsurl, httpstipologia, httpshostverify,
  830.                     httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  831.                     httpsalgoritmo, httpsstato, httpskeystore,
  832.                     httpspwdprivatekeytrust, httpspathkey,
  833.                     httpstipokey, httpspwdkey,
  834.                     httpspwdprivatekey, httpsalgoritmokey,
  835.                     httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  836.                     tipoconn, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE, strutsBean.id,
  837.                     nomeservizio, tiposervizio, versioneservizio.intValue()+"", null, null, null, null, true,
  838.                     isConnettoreCustomUltimaImmagineSalvata,
  839.                     proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  840.                     tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  841.                     opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  842.                     requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  843.                     requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  844.                     responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  845.                     autenticazioneToken, tokenPolicy, forcePDND, forceOAuth,
  846.                     listExtendedConnettore, false,
  847.                     protocollo,false,false
  848.                     , false, servizioApplicativoServerEnabled, servizioApplicativoServer, null,
  849.                     autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  850.                     connettoreStatusParams,
  851.                     postBackViaPost
  852.                     );

  853.             pd.setDati(dati);


  854.             // imposto la baseurl per il redirect
  855.             gd = generalHelper.initGeneralData(request,AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE);

  856.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  857.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS,
  858.                     AccordiServizioParteSpecificaCostanti.TIPO_OPERAZIONE_WSDL_CHANGE);
  859.         } catch (Exception e) {
  860.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  861.                     AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS,
  862.                     AccordiServizioParteSpecificaCostanti.TIPO_OPERAZIONE_WSDL_CHANGE);
  863.         }  
  864.     }
  865. }