PorteApplicativeTrasformazioniRichiesta.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.pa;

  21. import java.util.ArrayList;
  22. import java.util.List;

  23. import javax.servlet.http.HttpServletRequest;
  24. import javax.servlet.http.HttpServletResponse;
  25. import javax.servlet.http.HttpSession;

  26. import org.apache.commons.lang.StringUtils;
  27. import org.apache.struts.action.Action;
  28. import org.apache.struts.action.ActionForm;
  29. import org.apache.struts.action.ActionForward;
  30. import org.apache.struts.action.ActionMapping;
  31. import org.openspcoop2.core.config.PortaApplicativa;
  32. import org.openspcoop2.core.config.TrasformazioneRegola;
  33. import org.openspcoop2.core.config.TrasformazioneRegolaRichiesta;
  34. import org.openspcoop2.core.config.TrasformazioneRest;
  35. import org.openspcoop2.core.config.TrasformazioneSoap;
  36. import org.openspcoop2.core.config.Trasformazioni;
  37. import org.openspcoop2.core.config.constants.VersioneSOAP;
  38. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  39. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  40. import org.openspcoop2.message.constants.ServiceBinding;
  41. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  42. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  43. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  44. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCore;
  45. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCore;
  46. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  47. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  48. import org.openspcoop2.web.lib.mvc.Costanti;
  49. import org.openspcoop2.web.lib.mvc.DataElement;
  50. import org.openspcoop2.web.lib.mvc.GeneralData;
  51. import org.openspcoop2.web.lib.mvc.PageData;
  52. import org.openspcoop2.web.lib.mvc.Parameter;
  53. import org.openspcoop2.web.lib.mvc.ServletUtils;
  54. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  55. /**
  56.  * PorteApplicativeTrasformazioniRichiesta
  57.  *
  58.  * @author Giuliano Pintori (pintori@link.it)
  59.  * @author $Author$
  60.  * @version $Rev$, $Date$
  61.  *
  62.  */
  63. public class PorteApplicativeTrasformazioniRichiesta extends Action {

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

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

  67.         // Inizializzo PageData
  68.         PageData pd = new PageData();

  69.         GeneralHelper generalHelper = new GeneralHelper(session);
  70.        
  71.         String userLogin = ServletUtils.getUserLoginFromSession(session);

  72.         // Inizializzo GeneralData
  73.         GeneralData gd = generalHelper.initGeneralData(request);
  74.        
  75.         try {
  76.            
  77.             PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(request, pd, session);
  78.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte applicative
  79.             Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, session, request);
  80.             if(parentPA == null) parentPA = PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_NONE;
  81.             String idPorta = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  82.             long idInt = Long.parseLong(idPorta);
  83.             String idsogg = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO);
  84.             String idAsps = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS);
  85.             if(idAsps == null)
  86.                 idAsps = "";
  87.            
  88.             String idTrasformazioneS = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_TRASFORMAZIONE);
  89.             long idTrasformazione = Long.parseLong(idTrasformazioneS);

  90.             PorteApplicativeCore porteApplicativeCore = new PorteApplicativeCore();
  91.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(porteApplicativeCore);
  92.             AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore(porteApplicativeCore);
  93.             SoggettiCore soggettiCore = new SoggettiCore(porteApplicativeCore);
  94.            
  95.             // Preparo il menu
  96.             porteApplicativeHelper.makeMenu();

  97.             // Prendo nome della porta applicativa
  98.             PortaApplicativa pa = porteApplicativeCore.getPortaApplicativa(idInt);
  99.             String nomePorta = pa.getNome();
  100.             String protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(pa.getTipoSoggettoProprietario());
  101.            
  102.             Trasformazioni trasformazioni = pa.getTrasformazioni();
  103.             TrasformazioneRegola oldRegola = null;
  104.             for (TrasformazioneRegola reg : trasformazioni.getRegolaList()) {
  105.                 if(reg.getId().longValue() == idTrasformazione) {
  106.                     oldRegola = reg;
  107.                     break;
  108.                 }
  109.             }
  110.             if(oldRegola==null) {
  111.                 throw new Exception("TrasformazioneRegola con id '"+idTrasformazione+"' non trovata");
  112.             }
  113.            
  114.             String trasformazioneContenutoAbilitatoS  = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_REQ_CONVERSIONE_ENABLED);
  115.             boolean trasformazioneContenutoAbilitato = trasformazioneContenutoAbilitatoS != null ? ServletUtils.isCheckBoxEnabled(trasformazioneContenutoAbilitatoS) : false;
  116.             String trasformazioneContenutoTipoS = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO);
  117.             org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneContenutoTipo =
  118.                     trasformazioneContenutoTipoS != null ? org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(trasformazioneContenutoTipoS) :
  119.                         org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  120.            
  121.             BinaryParameter trasformazioneContenutoTemplate = porteApplicativeHelper.getBinaryParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_REQ_CONVERSIONE_TEMPLATE);
  122.             String trasformazioneContenutoTipoCheck = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK);
  123.             String trasformazioneRichiestaContentType = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_REQ_CONTENT_TYPE);
  124.             String trasformazioneRestAbilitatoS = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_REST_TRANSFORMATION);
  125.             boolean trasformazioneRestAbilitato =  trasformazioneRestAbilitatoS != null ? ServletUtils.isCheckBoxEnabled(trasformazioneRestAbilitatoS) : false;
  126.             String trasformazioneRestMethod = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_REST_METHOD);
  127.             String trasformazioneRestPath = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_REST_PATH);
  128.             String trasformazioneSoapAbilitatoS = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_SOAP_TRANSFORMATION);
  129.             boolean trasformazioneSoapAbilitato =  trasformazioneSoapAbilitatoS != null ? ServletUtils.isCheckBoxEnabled(trasformazioneSoapAbilitatoS) : false;
  130.             String trasformazioneSoapAction = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_SOAP_ACTION);
  131.             String trasformazioneSoapVersion = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_SOAP_VERSION);
  132.             String trasformazioneSoapEnvelope  =  porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_SOAP_ENVELOPE);
  133.             String trasformazioneSoapEnvelopeTipoS = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_SOAP_ENVELOPE_TIPO);
  134.             org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione trasformazioneSoapEnvelopeTipo =
  135.                     trasformazioneSoapEnvelopeTipoS != null ? org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(trasformazioneSoapEnvelopeTipoS) :
  136.                         org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  137.             BinaryParameter trasformazioneSoapEnvelopeTemplate = porteApplicativeHelper.getBinaryParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_SOAP_ENVELOPE_TEMPLATE);
  138.             String trasformazioneSoapEnvelopeTipoCheck = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_TIPO_CHECK);
  139.            
  140.             // Prendo il nome e il tipo del servizio
  141.             AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(idAsps));
  142.             AccordoServizioParteComuneSintetico apc = apcCore.getAccordoServizioSintetico(asps.getIdAccordo());
  143.             ServiceBinding serviceBindingMessage = apcCore.toMessageServiceBinding(apc.getServiceBinding());
  144.            
  145.             String postBackElementName = porteApplicativeHelper.getPostBackElementName();
  146.            
  147.             // se ho modificato il soggetto ricalcolo il servizio e il service binding
  148.             if (postBackElementName != null) {
  149.                 if(postBackElementName.equals(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_REQ_CONVERSIONE_ENABLED)) {
  150.                     trasformazioneContenutoTipo = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  151.                     trasformazioneRichiestaContentType = "";
  152.                     trasformazioneSoapAbilitato = false;
  153.                     trasformazioneSoapAction = "";
  154.                     trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_DISABILITATO;
  155.                     trasformazioneSoapEnvelopeTipo = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  156.                     trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11;
  157.                     trasformazioneRestAbilitato = false;
  158.                     if(ServiceBinding.SOAP.equals(serviceBindingMessage)) {
  159.                         trasformazioneRestMethod = "";
  160.                         trasformazioneRestPath = "";
  161.                     }
  162.                    
  163.                     porteApplicativeHelper.deleteBinaryParameters(trasformazioneContenutoTemplate, trasformazioneSoapEnvelopeTemplate);
  164.                 }
  165.                
  166.                 if(postBackElementName.equals(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO)) {
  167.                     trasformazioneContenutoTipoCheck = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_TIPO;
  168.                     porteApplicativeHelper.deleteBinaryParameters(trasformazioneContenutoTemplate);
  169.                 }
  170.                
  171.                 if(postBackElementName.equals(trasformazioneContenutoTemplate.getName()) &&
  172.                     StringUtils.isEmpty(trasformazioneContenutoTipoCheck)) {
  173.                     trasformazioneContenutoTipoCheck = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_FILE;
  174.                 }
  175.                
  176.                 if(postBackElementName.equals(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_SOAP_TRANSFORMATION)) {
  177.                     porteApplicativeHelper.deleteBinaryParameters(trasformazioneSoapEnvelopeTemplate);
  178.                     if(trasformazioneSoapAbilitato) {
  179.                         trasformazioneSoapAction = "";
  180.                         trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_DISABILITATO;
  181.                         trasformazioneSoapEnvelopeTipo = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  182.                         trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11;
  183.                     }
  184.                 }
  185.                
  186.                 if(postBackElementName.equals(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_SOAP_ENVELOPE)) {
  187.                     porteApplicativeHelper.deleteBinaryParameters(trasformazioneSoapEnvelopeTemplate);
  188.                     if(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_ATTACHMENT.equals(trasformazioneSoapEnvelope)) {
  189.                         trasformazioneSoapEnvelopeTipo = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  190.                     }
  191.                 }
  192.                
  193.                 if(postBackElementName.equals(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_SOAP_ENVELOPE_TIPO)) {
  194.                     trasformazioneSoapEnvelopeTipoCheck = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_TIPO;
  195.                     porteApplicativeHelper.deleteBinaryParameters(trasformazioneSoapEnvelopeTemplate);
  196.                 }
  197.                
  198.                 if(postBackElementName.equals(trasformazioneSoapEnvelopeTemplate.getName()) &&
  199.                     StringUtils.isEmpty(trasformazioneSoapEnvelopeTipoCheck)) {
  200.                     trasformazioneSoapEnvelopeTipoCheck = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_REQ_CONVERSIONE_TIPO_CHECK_UPDATE_FILE;
  201.                 }
  202.                
  203.                 if(postBackElementName.equals(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_REST_TRANSFORMATION) &&
  204.                     trasformazioneRestAbilitato) {
  205.                     trasformazioneRestMethod = "";
  206.                     trasformazioneRestPath = "";
  207.                 }
  208.             }
  209.            
  210.             String nomeTrasformazione = oldRegola.getNome();
  211.             Parameter pIdTrasformazione = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_TRASFORMAZIONE, idTrasformazioneS);
  212.            
  213.             // parametri visualizzazione link
  214.             String servletTrasformazioniRichiestaHeadersList = PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_RICHIESTA_HEADER_LIST;
  215.             String servletTrasformazioniRichiestaParametriList = PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_RICHIESTA_PARAMETRO_LIST;
  216.             TrasformazioneRegolaRichiesta oldRichiesta = oldRegola.getRichiesta();
  217.             int numeroTrasformazioniRichiestaHeaders= oldRichiesta != null ? oldRichiesta.sizeHeaderList() : 0;
  218.             int numeroTrasformazioniRichiestaParametri = oldRichiesta != null ? oldRichiesta.sizeParametroUrlList() : 0;
  219.            
  220.             List<Parameter> parametriInvocazioneServletTrasformazioniRichiestaHeaders = new ArrayList<>();
  221.             parametriInvocazioneServletTrasformazioniRichiestaHeaders.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, idPorta));
  222.             parametriInvocazioneServletTrasformazioniRichiestaHeaders.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idsogg));
  223.             parametriInvocazioneServletTrasformazioniRichiestaHeaders.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, idAsps));
  224.             parametriInvocazioneServletTrasformazioniRichiestaHeaders.add(pIdTrasformazione);
  225.             List<Parameter> parametriInvocazioneServletTrasformazioniRichiestaParametri = new ArrayList<>();
  226.             parametriInvocazioneServletTrasformazioniRichiestaParametri.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, idPorta));
  227.             parametriInvocazioneServletTrasformazioniRichiestaParametri.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idsogg));
  228.             parametriInvocazioneServletTrasformazioniRichiestaParametri.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, idAsps));
  229.             parametriInvocazioneServletTrasformazioniRichiestaParametri.add(pIdTrasformazione);
  230.            
  231.             List<Parameter> lstParam = porteApplicativeHelper.getTitoloPA(parentPA, idsogg, idAsps);

  232.             String labelPerPorta = null;
  233.             if(parentPA!=null && (parentPA.intValue() == PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE)) {
  234.                 labelPerPorta = porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  235.                         PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_DI,
  236.                         PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI,
  237.                         pa);
  238.             }
  239.             else {
  240.                 labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_DI+nomePorta;
  241.             }

  242.             lstParam.add(new Parameter(labelPerPorta,
  243.                     PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_LIST,
  244.                     new Parameter( PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, idPorta),
  245.                     new Parameter( PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idsogg),
  246.                     new Parameter( PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, idAsps)
  247.                     ));
  248.            
  249.             lstParam.add(new Parameter(nomeTrasformazione, PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_CHANGE,
  250.                     new Parameter( PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, idPorta),
  251.                     new Parameter( PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idsogg),
  252.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, idAsps), pIdTrasformazione));
  253.            
  254.             lstParam.add(new Parameter(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_RICHIESTA, null));
  255.            
  256.             ServletUtils.setPageDataTitle(pd, lstParam);
  257.            
  258.             // imposta menu' contestuale
  259.             porteApplicativeHelper.impostaComandiMenuContestualePA(idsogg, idAsps);
  260.            
  261.             // Se nomehid = null, devo visualizzare la pagina per l'inserimento
  262.             // dati
  263.             if (porteApplicativeHelper.isEditModeInProgress()) {
  264.                 // preparo i campi
  265.                 List<DataElement> dati = new ArrayList<>();
  266.                 dati.add(ServletUtils.getDataElementForEditModeFinished());
  267.                
  268.                 // primo accesso
  269.                 if(trasformazioneContenutoAbilitatoS == null) {
  270.                    
  271.                     if(oldRichiesta == null) {
  272.                         trasformazioneContenutoAbilitato = false;
  273.                         trasformazioneContenutoTipo = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  274.                         trasformazioneRichiestaContentType = "";
  275.                         trasformazioneSoapAbilitato = false;
  276.                         trasformazioneSoapAction = "";
  277.                         trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_DISABILITATO;
  278.                         trasformazioneSoapEnvelopeTipo = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  279.                         trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11;
  280.                         trasformazioneRestAbilitato = false;
  281.                         trasformazioneRestMethod = "";
  282.                         trasformazioneRestPath = "";
  283.                     } else {
  284.                         trasformazioneContenutoAbilitato = oldRichiesta.getConversione();
  285.                         trasformazioneContenutoTipo = StringUtils.isNotEmpty(oldRichiesta.getConversioneTipo()) ?
  286.                                 org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(oldRichiesta.getConversioneTipo()) : org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  287.                         trasformazioneContenutoTemplate.setValue(oldRichiesta.getConversioneTemplate());
  288.                         trasformazioneRichiestaContentType = StringUtils.isNotEmpty(oldRichiesta.getContentType()) ? oldRichiesta.getContentType() : "";
  289.                        
  290.                         if(oldRichiesta.getTrasformazioneSoap() == null) {
  291.                             trasformazioneSoapAbilitato = false;
  292.                             trasformazioneSoapAction = "";
  293.                             trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_DISABILITATO;
  294.                             trasformazioneSoapEnvelopeTipo = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  295.                             trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11;
  296.                         } else {
  297.                             trasformazioneSoapAbilitato = true;
  298.                             trasformazioneSoapAction = StringUtils.isNotEmpty(oldRichiesta.getTrasformazioneSoap().getSoapAction()) ? oldRichiesta.getTrasformazioneSoap().getSoapAction() : "";
  299.                            
  300.                             if(oldRichiesta.getTrasformazioneSoap().isEnvelope()) {
  301.                                 if(oldRichiesta.getTrasformazioneSoap().isEnvelopeAsAttachment()) {
  302.                                     trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_ATTACHMENT;
  303.                                 } else {
  304.                                     trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_BODY;
  305.                                 }
  306.                             } else {
  307.                                 trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_DISABILITATO;
  308.                             }
  309.                            
  310.                             trasformazioneSoapEnvelopeTipo = StringUtils.isNotEmpty(oldRichiesta.getTrasformazioneSoap().getEnvelopeBodyConversioneTipo()) ?
  311.                                     org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(oldRichiesta.getTrasformazioneSoap().getEnvelopeBodyConversioneTipo())
  312.                                     : org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  313.                             if(oldRichiesta.getTrasformazioneSoap().getVersione() != null) {
  314.                                
  315.                                 switch (oldRichiesta.getTrasformazioneSoap().getVersione()) {
  316.                                 case _1_2:
  317.                                     trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_12;
  318.                                     break;
  319.                                 case _1_1:
  320.                                 default:
  321.                                     trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11;
  322.                                     break;
  323.                                 }
  324.                             }else {
  325.                                 trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11;
  326.                             }
  327.                             trasformazioneSoapEnvelopeTemplate.setValue(oldRichiesta.getTrasformazioneSoap().getEnvelopeBodyConversioneTemplate());
  328.                         }
  329.                            
  330.                        
  331.                         if(oldRichiesta.getTrasformazioneRest() == null) {
  332.                             trasformazioneRestAbilitato = false;
  333.                             trasformazioneRestMethod = "";
  334.                             trasformazioneRestPath = "";
  335.                         } else {
  336.                             trasformazioneRestAbilitato = true;
  337.                             trasformazioneRestMethod = StringUtils.isNotEmpty(oldRichiesta.getTrasformazioneRest().getMetodo()) ? oldRichiesta.getTrasformazioneRest().getMetodo() : "";
  338.                             trasformazioneRestPath = StringUtils.isNotEmpty(oldRichiesta.getTrasformazioneRest().getPath()) ? oldRichiesta.getTrasformazioneRest().getPath() : "";
  339.                         }
  340.  
  341.                     }
  342.                 }

  343.                 dati = porteApplicativeHelper.addTrasformazioneRichiestaToDati(TipoOperazione.OTHER, protocollo, dati, idInt, oldRichiesta, false, idTrasformazioneS, trasformazioneContenutoAbilitato, trasformazioneContenutoTipo,
  344.                         trasformazioneContenutoTemplate, trasformazioneContenutoTipoCheck, trasformazioneRichiestaContentType, serviceBindingMessage, trasformazioneRestAbilitato,
  345.                         trasformazioneRestMethod, trasformazioneRestPath, trasformazioneSoapAbilitato, trasformazioneSoapAction,
  346.                         trasformazioneSoapVersion, trasformazioneSoapEnvelope, trasformazioneSoapEnvelopeTipo, trasformazioneSoapEnvelopeTemplate, trasformazioneSoapEnvelopeTipoCheck,
  347.                         servletTrasformazioniRichiestaHeadersList, parametriInvocazioneServletTrasformazioniRichiestaHeaders, numeroTrasformazioniRichiestaHeaders,
  348.                         servletTrasformazioniRichiestaParametriList, parametriInvocazioneServletTrasformazioniRichiestaParametri, numeroTrasformazioniRichiestaParametri,
  349.                         apc.getServiceBinding());
  350.                
  351.                 dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.CHANGE, idPorta, idsogg, idPorta,idAsps,  dati);
  352.                
  353.                 pd.setDati(dati);

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

  355.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_RICHIESTA,  PorteApplicativeCostanti.TIPO_OPERAZIONE_TRASFORMAZIONI_RICHIESTA);
  356.             }
  357.            
  358.             boolean isOk = porteApplicativeHelper.trasformazioniRichiestaCheckData(TipoOperazione.CHANGE, oldRegola, serviceBindingMessage);
  359.             if (!isOk) {

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

  362.                 dati.add(ServletUtils.getDataElementForEditModeFinished());
  363.                
  364.                 dati = porteApplicativeHelper.addTrasformazioneRichiestaToDati(TipoOperazione.OTHER, protocollo, dati, idInt, oldRichiesta, false, idTrasformazioneS, trasformazioneContenutoAbilitato, trasformazioneContenutoTipo,
  365.                         trasformazioneContenutoTemplate, trasformazioneContenutoTipoCheck, trasformazioneRichiestaContentType, serviceBindingMessage, trasformazioneRestAbilitato,
  366.                         trasformazioneRestMethod, trasformazioneRestPath, trasformazioneSoapAbilitato, trasformazioneSoapAction,
  367.                         trasformazioneSoapVersion, trasformazioneSoapEnvelope, trasformazioneSoapEnvelopeTipo, trasformazioneSoapEnvelopeTemplate, trasformazioneSoapEnvelopeTipoCheck,
  368.                         servletTrasformazioniRichiestaHeadersList, parametriInvocazioneServletTrasformazioniRichiestaHeaders, numeroTrasformazioniRichiestaHeaders,
  369.                         servletTrasformazioniRichiestaParametriList, parametriInvocazioneServletTrasformazioniRichiestaParametri, numeroTrasformazioniRichiestaParametri,
  370.                         apc.getServiceBinding());
  371.                
  372.                 dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.CHANGE, idPorta, idsogg, idPorta,idAsps,  dati);
  373.                
  374.                 pd.setDati(dati);

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

  376.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_RICHIESTA,  PorteApplicativeCostanti.TIPO_OPERAZIONE_TRASFORMAZIONI_RICHIESTA);
  377.             }
  378.            
  379.             // aggiorno la regola
  380.             trasformazioni = pa.getTrasformazioni();
  381.             for (TrasformazioneRegola reg : trasformazioni.getRegolaList()) {
  382.                 if(reg.getId().longValue() == idTrasformazione) {
  383.                    
  384.                     if(reg.getRichiesta() == null)
  385.                         reg.setRichiesta(new TrasformazioneRegolaRichiesta());
  386.                    
  387.                     reg.getRichiesta().setConversione(trasformazioneContenutoAbilitato);
  388.                    
  389.                     if(trasformazioneContenutoAbilitato) {
  390.                         if(trasformazioneContenutoTipo.isTemplateRequired()) {
  391.                             //  se e' stato aggiornato il template lo sovrascrivo
  392.                             if(trasformazioneContenutoTemplate.getValue() != null && trasformazioneContenutoTemplate.getValue().length  > 0)
  393.                                 reg.getRichiesta().setConversioneTemplate(trasformazioneContenutoTemplate.getValue());
  394.                         }else {
  395.                             reg.getRichiesta().setConversioneTemplate(null);
  396.                         }
  397.                        
  398.                         if(trasformazioneRichiestaContentType!=null && !"".equals(trasformazioneRichiestaContentType)) {
  399.                             reg.getRichiesta().setContentType(trasformazioneRichiestaContentType);
  400.                         }
  401.                         else {
  402.                             reg.getRichiesta().setContentType(null);
  403.                         }
  404.                         reg.getRichiesta().setConversioneTipo(trasformazioneContenutoTipo.getValue());
  405.                        
  406.                         if(trasformazioneRestAbilitato) {
  407.                             if(reg.getRichiesta().getTrasformazioneRest() == null)
  408.                                 reg.getRichiesta().setTrasformazioneRest(new TrasformazioneRest());
  409.                            
  410.                             reg.getRichiesta().getTrasformazioneRest().setMetodo(trasformazioneRestMethod);
  411.                             reg.getRichiesta().getTrasformazioneRest().setPath(trasformazioneRestPath);
  412.                         } else {
  413.                             reg.getRichiesta().setTrasformazioneRest(null);
  414.                            
  415.                             if(ServiceBinding.REST.equals(serviceBindingMessage)) {
  416.                                 if(StringUtils.isNotEmpty(trasformazioneRestMethod) || StringUtils.isNotEmpty(trasformazioneRestPath)) {
  417.                                     if(reg.getRichiesta().getTrasformazioneRest() == null)
  418.                                         reg.getRichiesta().setTrasformazioneRest(new TrasformazioneRest());
  419.                                    
  420.                                     reg.getRichiesta().getTrasformazioneRest().setMetodo(trasformazioneRestMethod);
  421.                                     reg.getRichiesta().getTrasformazioneRest().setPath(trasformazioneRestPath);
  422.                                 }
  423.                             }
  424.                         }
  425.                        
  426.                         if(trasformazioneSoapAbilitato) {
  427.                             if(reg.getRichiesta().getTrasformazioneSoap() == null)
  428.                                 reg.getRichiesta().setTrasformazioneSoap(new TrasformazioneSoap());
  429.                            
  430.                             reg.getRichiesta().getTrasformazioneSoap().setSoapAction(trasformazioneSoapAction);
  431.                             reg.getRichiesta().getTrasformazioneSoap().setVersione(VersioneSOAP.toEnumConstant(trasformazioneSoapVersion));
  432.                             if(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_ATTACHMENT.equals(trasformazioneSoapEnvelope)) { // attachment
  433.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelope(true);
  434.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelopeAsAttachment(true);
  435.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelopeBodyConversioneTipo(trasformazioneSoapEnvelopeTipo.getValue());
  436.                                
  437.                                 if(trasformazioneSoapEnvelopeTipo.isTemplateRequired()) {
  438.                                     //  se e' stato aggiornato il template lo sovrascrivo
  439.                                     if(trasformazioneSoapEnvelopeTemplate.getValue() != null && trasformazioneSoapEnvelopeTemplate.getValue().length  > 0)
  440.                                         reg.getRichiesta().getTrasformazioneSoap().setEnvelopeBodyConversioneTemplate(trasformazioneSoapEnvelopeTemplate.getValue());
  441.                                 }else {
  442.                                     reg.getRichiesta().getTrasformazioneSoap().setEnvelopeBodyConversioneTemplate(null);
  443.                                 }
  444.                                
  445.                             } else if(CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_BODY.equals(trasformazioneSoapEnvelope)) { // body
  446.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelope(true);
  447.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelopeAsAttachment(false);
  448.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelopeBodyConversioneTemplate(null);
  449.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelopeBodyConversioneTipo(null);
  450.                             } else  { // disabilitato
  451.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelope(false);
  452.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelopeAsAttachment(false);
  453.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelopeBodyConversioneTemplate(null);
  454.                                 reg.getRichiesta().getTrasformazioneSoap().setEnvelopeBodyConversioneTipo(null);
  455.                             }
  456.                                
  457.                         } else {
  458.                             reg.getRichiesta().setTrasformazioneSoap(null);
  459.                         }
  460.                     } else {
  461.                         reg.getRichiesta().setConversioneTemplate(null);
  462.                         reg.getRichiesta().setContentType(null);
  463.                         reg.getRichiesta().setConversioneTipo(null);
  464.                         reg.getRichiesta().setTrasformazioneRest(null);
  465.                         reg.getRichiesta().setTrasformazioneSoap(null);
  466.                        
  467.                         if(ServiceBinding.REST.equals(serviceBindingMessage)) {
  468.                             if(StringUtils.isNotEmpty(trasformazioneRestMethod) || StringUtils.isNotEmpty(trasformazioneRestPath)) {
  469.                                 if(reg.getRichiesta().getTrasformazioneRest() == null)
  470.                                     reg.getRichiesta().setTrasformazioneRest(new TrasformazioneRest());
  471.                                
  472.                                 reg.getRichiesta().getTrasformazioneRest().setMetodo(trasformazioneRestMethod);
  473.                                 reg.getRichiesta().getTrasformazioneRest().setPath(trasformazioneRestPath);
  474.                             } else {
  475.                                 reg.getRichiesta().setTrasformazioneRest(null);
  476.                             }
  477.                         }
  478.                     }
  479.                    
  480.                     break;
  481.                 }
  482.             }
  483.            
  484.             porteApplicativeCore.performUpdateOperation(userLogin, porteApplicativeHelper.smista(), pa);
  485.             porteApplicativeHelper.deleteBinaryParameters(trasformazioneContenutoTemplate,trasformazioneSoapEnvelopeTemplate);
  486.            
  487.             // ricarico la richiesta
  488.             // ricaricare id trasformazione
  489.             pa = porteApplicativeCore.getPortaApplicativa(Long.parseLong(idPorta));

  490.             TrasformazioneRegola trasformazioneAggiornata = porteApplicativeCore.getTrasformazione(pa.getId(), oldRegola.getNome());
  491.            
  492.             // setto il titolo della pagina
  493.             nomeTrasformazione = oldRegola.getNome();
  494.             pIdTrasformazione = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_TRASFORMAZIONE, trasformazioneAggiornata.getId() + "");
  495.            
  496.             // parametri visualizzazione link
  497.             // FIX: non devo aggiornarli, tanto non modifichero' direttamente le due liste e il metodo 'getTrasformazione' da cui si ottiene trasformazioneAggiornata non ritorna le due liste
  498.             //numeroTrasformazioniRichiestaHeaders= trasformazioneAggiornata.getRichiesta() != null ? trasformazioneAggiornata.getRichiesta().sizeHeaderList() : 0;
  499.             //numeroTrasformazioniRichiestaParametri = trasformazioneAggiornata.getRichiesta() != null ? trasformazioneAggiornata.getRichiesta().sizeParametroUrlList() : 0;
  500.            
  501.             parametriInvocazioneServletTrasformazioniRichiestaHeaders = new ArrayList<>();
  502.             parametriInvocazioneServletTrasformazioniRichiestaHeaders.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, idPorta));
  503.             parametriInvocazioneServletTrasformazioniRichiestaHeaders.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idsogg));
  504.             parametriInvocazioneServletTrasformazioniRichiestaHeaders.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, idAsps));
  505.             parametriInvocazioneServletTrasformazioniRichiestaHeaders.add(pIdTrasformazione);
  506.             parametriInvocazioneServletTrasformazioniRichiestaParametri = new ArrayList<>();
  507.             parametriInvocazioneServletTrasformazioniRichiestaParametri.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, idPorta));
  508.             parametriInvocazioneServletTrasformazioniRichiestaParametri.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idsogg));
  509.             parametriInvocazioneServletTrasformazioniRichiestaParametri.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, idAsps));
  510.             parametriInvocazioneServletTrasformazioniRichiestaParametri.add(pIdTrasformazione);
  511.            
  512.             lstParam = porteApplicativeHelper.getTitoloPA(parentPA, idsogg, idAsps);

  513.             labelPerPorta = null;
  514.             if(parentPA!=null && (parentPA.intValue() == PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE)) {
  515.                 labelPerPorta = porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  516.                         PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_DI,
  517.                         PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI,
  518.                         pa);
  519.             }
  520.             else {
  521.                 labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_DI+nomePorta;
  522.             }

  523.             lstParam.add(new Parameter(labelPerPorta,
  524.                     PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_LIST,
  525.                     new Parameter( PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, idPorta),
  526.                     new Parameter( PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idsogg),
  527.                     new Parameter( PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, idAsps)
  528.                     ));
  529.            
  530.             lstParam.add(new Parameter(nomeTrasformazione, PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_CHANGE,
  531.                     new Parameter( PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, idPorta),
  532.                     new Parameter( PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idsogg),
  533.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, idAsps), pIdTrasformazione));
  534.            
  535.             lstParam.add(new Parameter(PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_TRASFORMAZIONI_RICHIESTA, null));
  536.            
  537.             ServletUtils.setPageDataTitle(pd, lstParam);
  538.            
  539.             // preparo i campi
  540.             List<DataElement> dati = new ArrayList<>();
  541.            
  542.             TrasformazioneRegolaRichiesta richiesta = trasformazioneAggiornata.getRichiesta();
  543.            
  544.             if(richiesta == null) {
  545.                 trasformazioneContenutoAbilitato = false;
  546.                 trasformazioneContenutoTipo = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  547.                 trasformazioneRichiestaContentType = "";
  548.                 trasformazioneSoapAbilitato = false;
  549.                 trasformazioneSoapAction = "";
  550.                 trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_DISABILITATO;
  551.                 trasformazioneSoapEnvelopeTipo = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  552.                 trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11;
  553.                 trasformazioneRestAbilitato = false;
  554.                 trasformazioneRestMethod = "";
  555.                 trasformazioneRestPath = "";
  556.             } else {
  557.                 trasformazioneContenutoAbilitato = richiesta.getConversione();
  558.                 trasformazioneContenutoTipo = StringUtils.isNotEmpty(richiesta.getConversioneTipo()) ?
  559.                         org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(richiesta.getConversioneTipo()) : org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  560.                 trasformazioneContenutoTemplate.setValue(richiesta.getConversioneTemplate());
  561.                 trasformazioneRichiestaContentType = StringUtils.isNotEmpty(richiesta.getContentType()) ? richiesta.getContentType() : "";
  562.                
  563.                 if(richiesta.getTrasformazioneSoap() == null) {
  564.                     trasformazioneSoapAbilitato = false;
  565.                     trasformazioneSoapAction = "";
  566.                     trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_DISABILITATO;
  567.                     trasformazioneSoapEnvelopeTipo = org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  568.                     trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11;
  569.                 } else {
  570.                     trasformazioneSoapAbilitato = true;
  571.                     trasformazioneSoapAction = StringUtils.isNotEmpty(richiesta.getTrasformazioneSoap().getSoapAction()) ? richiesta.getTrasformazioneSoap().getSoapAction() : "";
  572.                    
  573.                     if(richiesta.getTrasformazioneSoap().isEnvelope()) {
  574.                         if(richiesta.getTrasformazioneSoap().isEnvelopeAsAttachment()) {
  575.                             trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_ATTACHMENT;
  576.                         } else {
  577.                             trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_AS_BODY;
  578.                         }
  579.                     } else {
  580.                         trasformazioneSoapEnvelope = CostantiControlStation.VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_SOAP_ENVELOPE_DISABILITATO;
  581.                     }
  582.                    
  583.                     trasformazioneSoapEnvelopeTipo = StringUtils.isNotEmpty(richiesta.getTrasformazioneSoap().getEnvelopeBodyConversioneTipo()) ?
  584.                             org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.toEnumConstant(richiesta.getTrasformazioneSoap().getEnvelopeBodyConversioneTipo())
  585.                             : org.openspcoop2.pdd.core.trasformazioni.TipoTrasformazione.EMPTY;
  586.                     if(richiesta.getTrasformazioneSoap().getVersione() != null) {
  587.                        
  588.                         switch (richiesta.getTrasformazioneSoap().getVersione()) {
  589.                         case _1_2:
  590.                             trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_12;
  591.                             break;
  592.                         case _1_1:
  593.                         default:
  594.                             trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11;
  595.                             break;
  596.                         }
  597.                     }else {
  598.                         trasformazioneSoapVersion = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_TRASFORMAZIONI_RICHIESTA_SOAP_VERSION_11;
  599.                     }
  600.                     trasformazioneSoapEnvelopeTemplate.setValue(richiesta.getTrasformazioneSoap().getEnvelopeBodyConversioneTemplate());
  601.                 }
  602.                    
  603.                
  604.                 if(richiesta.getTrasformazioneRest() == null) {
  605.                     trasformazioneRestAbilitato = false;
  606.                     trasformazioneRestMethod = "";
  607.                     trasformazioneRestPath = "";
  608.                 } else {
  609.                     trasformazioneRestAbilitato = true;
  610.                     trasformazioneRestMethod = StringUtils.isNotEmpty(richiesta.getTrasformazioneRest().getMetodo()) ? richiesta.getTrasformazioneRest().getMetodo() : "";
  611.                     trasformazioneRestPath = StringUtils.isNotEmpty(richiesta.getTrasformazioneRest().getPath()) ? richiesta.getTrasformazioneRest().getPath() : "";
  612.                 }

  613.             }
  614.            
  615.             trasformazioneContenutoTipoCheck= "";
  616.             trasformazioneSoapEnvelopeTipoCheck = "";
  617.            
  618.             dati = porteApplicativeHelper.addTrasformazioneRichiestaToDati(TipoOperazione.OTHER, protocollo, dati, idInt, richiesta, false, trasformazioneAggiornata.getId() + "", trasformazioneContenutoAbilitato, trasformazioneContenutoTipo,
  619.                     trasformazioneContenutoTemplate, trasformazioneContenutoTipoCheck, trasformazioneRichiestaContentType, serviceBindingMessage, trasformazioneRestAbilitato,
  620.                     trasformazioneRestMethod, trasformazioneRestPath, trasformazioneSoapAbilitato, trasformazioneSoapAction,
  621.                     trasformazioneSoapVersion, trasformazioneSoapEnvelope, trasformazioneSoapEnvelopeTipo, trasformazioneSoapEnvelopeTemplate, trasformazioneSoapEnvelopeTipoCheck,
  622.                     servletTrasformazioniRichiestaHeadersList, parametriInvocazioneServletTrasformazioniRichiestaHeaders, numeroTrasformazioniRichiestaHeaders,
  623.                     servletTrasformazioniRichiestaParametriList, parametriInvocazioneServletTrasformazioniRichiestaParametri, numeroTrasformazioniRichiestaParametri,
  624.                     apc.getServiceBinding());
  625.            
  626.             dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.CHANGE, idPorta, idsogg, idPorta,idAsps,  dati);
  627.            
  628.             pd.setDati(dati);
  629.                        
  630.             pd.setMessage(CostantiControlStation.LABEL_AGGIORNAMENTO_EFFETTUATO_CON_SUCCESSO, Costanti.MESSAGE_TYPE_INFO);
  631.             dati.add(ServletUtils.getDataElementForEditModeFinished());
  632.            
  633.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  634.            
  635.             // Forward control to the specified success URI
  636.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_RICHIESTA,  PorteApplicativeCostanti.TIPO_OPERAZIONE_TRASFORMAZIONI_RICHIESTA);
  637.         } catch (Exception e) {
  638.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  639.                     PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_TRASFORMAZIONI_RICHIESTA,  PorteApplicativeCostanti.TIPO_OPERAZIONE_TRASFORMAZIONI_RICHIESTA );
  640.         }
  641.     }
  642. }