AccordiServizioParteComuneResourcesAdd.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.apc;

  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.id.IDAccordo;
  32. import org.openspcoop2.core.id.IDResource;
  33. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  34. import org.openspcoop2.core.registry.IdSoggetto;
  35. import org.openspcoop2.core.registry.Resource;
  36. import org.openspcoop2.core.registry.constants.CostantiRegistroServizi;
  37. import org.openspcoop2.core.registry.constants.HttpMethod;
  38. import org.openspcoop2.core.registry.constants.StatoFunzionalita;
  39. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  40. import org.openspcoop2.message.constants.MessageType;
  41. import org.openspcoop2.message.constants.ServiceBinding;
  42. import org.openspcoop2.protocol.basic.archive.APIUtils;
  43. import org.openspcoop2.protocol.engine.ProtocolFactoryManager;
  44. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  45. import org.openspcoop2.protocol.sdk.ProtocolException;
  46. import org.openspcoop2.protocol.sdk.constants.ConsoleOperationType;
  47. import org.openspcoop2.protocol.sdk.properties.ConsoleConfiguration;
  48. import org.openspcoop2.protocol.sdk.properties.IConsoleDynamicConfiguration;
  49. import org.openspcoop2.protocol.sdk.properties.ProtocolProperties;
  50. import org.openspcoop2.protocol.sdk.properties.ProtocolPropertiesUtils;
  51. import org.openspcoop2.protocol.sdk.registry.IConfigIntegrationReader;
  52. import org.openspcoop2.protocol.sdk.registry.IRegistryReader;
  53. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  54. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  55. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  56. import org.openspcoop2.web.ctrlstat.servlet.apc.api.ApiCostanti;
  57. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  58. import org.openspcoop2.web.lib.mvc.Costanti;
  59. import org.openspcoop2.web.lib.mvc.DataElement;
  60. import org.openspcoop2.web.lib.mvc.ForwardParams;
  61. import org.openspcoop2.web.lib.mvc.GeneralData;
  62. import org.openspcoop2.web.lib.mvc.PageData;
  63. import org.openspcoop2.web.lib.mvc.Parameter;
  64. import org.openspcoop2.web.lib.mvc.ServletUtils;
  65. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  66. /**
  67.  * accordiPorttypeAdd
  68.  *
  69.  * @author Andrea Poli (apoli@link.it)
  70.  * @author Stefano Corallo (corallo@link.it)
  71.  * @author Sandra Giangrandi (sandra@link.it)
  72.  * @author $Author$
  73.  * @version $Rev$, $Date$
  74.  *
  75.  */
  76. public final class AccordiServizioParteComuneResourcesAdd extends Action {

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

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

  80.         // Inizializzo PageData
  81.         PageData pd = new PageData();

  82.         GeneralHelper generalHelper = new GeneralHelper(session);

  83.         // Inizializzo GeneralData
  84.         GeneralData gd = generalHelper.initGeneralData(request);

  85.         String userLogin = ServletUtils.getUserLoginFromSession(session);

  86.         IDAccordoFactory idAccordoFactory = IDAccordoFactory.getInstance();

  87.         // Protocol Properties
  88.         IConsoleDynamicConfiguration consoleDynamicConfiguration = null;
  89.         ConsoleConfiguration consoleConfiguration =null;
  90.         ProtocolProperties protocolProperties = null;
  91.         IProtocolFactory<?> protocolFactory= null;
  92.         IRegistryReader registryReader = null;
  93.         IConfigIntegrationReader configRegistryReader = null;
  94.         ConsoleOperationType consoleOperationType = null;
  95.        
  96.         // Parametri Protocol Properties relativi al tipo di operazione e al tipo di visualizzazione
  97.         consoleOperationType = ConsoleOperationType.ADD;
  98.        
  99.         // Parametri relativi al tipo operazione
  100.         TipoOperazione tipoOp = TipoOperazione.ADD;


  101.         try {
  102.             AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore();
  103.             SoggettiCore soggettiCore = new SoggettiCore(apcCore);

  104.             AccordiServizioParteComuneHelper apcHelper = new AccordiServizioParteComuneHelper(request, pd, session);
  105.            
  106.             String editMode = apcHelper.getParameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME);

  107.             String id = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_ID);
  108.             long idAccordoLong = Long.parseLong(id);
  109.             String nomeRisorsa = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_RESOURCES_NOME);
  110.             if (nomeRisorsa == null) {
  111.                 nomeRisorsa = "";
  112.             }
  113.             String descr = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_RESOURCES_DESCRIZIONE);
  114.             if (descr == null) {
  115.                 descr = "";
  116.             }
  117.            
  118.             String messageProcessorS = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_RESOURCES_MESSAGE_TYPE);
  119.             MessageType messageType = (StringUtils.isNotEmpty(messageProcessorS) && !messageProcessorS.equals(AccordiServizioParteComuneCostanti.DEFAULT_VALUE_PARAMETRO_APC_MESSAGE_TYPE_DEFAULT)) ? MessageType.valueOf(messageProcessorS) : null;
  120.        
  121.             String messageProcessorReqS = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_RESOURCES_MESSAGE_TYPE_REQUEST);
  122.             MessageType messageTypeRequest = (StringUtils.isNotEmpty(messageProcessorReqS) && !messageProcessorReqS.equals(AccordiServizioParteComuneCostanti.DEFAULT_VALUE_PARAMETRO_APC_MESSAGE_TYPE_DEFAULT)) ? MessageType.valueOf(messageProcessorReqS) : null;
  123.            
  124.             String messageProcessorResS = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_RESOURCES_MESSAGE_TYPE_RESPONSE);
  125.             MessageType messageTypeResponse = (StringUtils.isNotEmpty(messageProcessorResS) && !messageProcessorResS.equals(AccordiServizioParteComuneCostanti.DEFAULT_VALUE_PARAMETRO_APC_MESSAGE_TYPE_DEFAULT)) ? MessageType.valueOf(messageProcessorResS) : null;
  126.        
  127.             String path = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_RESOURCES_PATH);
  128.             if (path == null) {
  129.                 path = "";
  130.             }
  131.             String httpMethod = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_RESOURCES_HTTP_METHOD);
  132.            
  133.             String profProtocollo = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_AZIONI_PROFILO_BUSTA);
  134.             String filtrodupaz = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_AZIONI_FILTRO_DUPLICATI);
  135.             if ((filtrodupaz != null) && filtrodupaz.equals("null")) {
  136.                 filtrodupaz = null;
  137.             }
  138.             String confricaz = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_AZIONI_CONFERMA_RICEZIONE);
  139.             if ((confricaz != null) && confricaz.equals("null")) {
  140.                 confricaz = null;
  141.             }
  142.             String idcollaz = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_AZIONI_COLLABORAZIONE);
  143.             if ((idcollaz != null) && idcollaz.equals("null")) {
  144.                 idcollaz = null;
  145.             }
  146.             String idRifRichiestaAz = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_AZIONI_ID_RIFERIMENTO_RICHIESTA);
  147.             if ((idRifRichiestaAz != null) && idRifRichiestaAz.equals("null")) {
  148.                 idRifRichiestaAz = null;
  149.             }
  150.             String consordaz = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_AZIONI_CONSEGNA_ORDINE);
  151.             if ((consordaz != null) && consordaz.equals("null")) {
  152.                 consordaz = null;
  153.             }
  154.             String scadenzaaz = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_AZIONI_SCADENZA);
  155.             if (scadenzaaz == null) {
  156.                 scadenzaaz = "";
  157.             }
  158.            
  159.             String tipoAccordo = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_TIPO_ACCORDO);
  160.             if("".equals(tipoAccordo))
  161.                 tipoAccordo = null;

  162.             // Preparo il menu
  163.             apcHelper.makeMenu();

  164.             // Prendo il nome
  165.             AccordoServizioParteComune as = apcCore.getAccordoServizioFull(idAccordoLong);
  166.             String labelASTitle = apcHelper.getLabelIdAccordo(as);
  167.             IDAccordo idAs = idAccordoFactory.getIDAccordoFromAccordo(as);

  168.             String protocollo = null;
  169.             //calcolo del protocollo implementato dall'accordo
  170.             IdSoggetto soggettoReferente = as.getSoggettoReferente();
  171.             String tipoSoggettoReferente = soggettoReferente.getTipo();
  172.             protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(tipoSoggettoReferente);

  173.             protocolFactory = ProtocolFactoryManager.getInstance().getProtocolFactoryByName(protocollo);
  174.             consoleDynamicConfiguration =  protocolFactory.createDynamicConfigurationConsole();
  175.             registryReader = soggettiCore.getRegistryReader(protocolFactory);
  176.             configRegistryReader = soggettiCore.getConfigIntegrationReader(protocolFactory);
  177.            
  178.             ServiceBinding serviceBinding = null;
  179.             //calcolo del serviceBinding dall'accordo
  180.             serviceBinding = apcCore.toMessageServiceBinding(as.getServiceBinding());

  181.             IDResource idRisorsa = new IDResource();
  182.             idRisorsa.setIdAccordo(idAs);
  183.             idRisorsa.setNome(nomeRisorsa);
  184.             consoleConfiguration = consoleDynamicConfiguration.getDynamicConfigResource(consoleOperationType, apcHelper,
  185.                     registryReader, configRegistryReader, idRisorsa, httpMethod, path );
  186.             protocolProperties = apcHelper.estraiProtocolPropertiesDaRequest(consoleConfiguration, consoleOperationType);
  187.            
  188.             String uriAS = idAccordoFactory.getUriFromAccordo(as);
  189.             Parameter pTipoAccordo = AccordiServizioParteComuneUtilities.getParametroAccordoServizio(tipoAccordo);
  190.             Parameter pIdAccordo = new Parameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_ID, id );
  191.             Parameter pNomeAccordo = new Parameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_NOME, uriAS);

  192.             Boolean isModalitaVistaApiCustom = ServletUtils.getBooleanAttributeFromSession(ApiCostanti.SESSION_ATTRIBUTE_VISTA_APC_API, session, request, false).getValue();
  193.             List<Parameter> listaParams = apcHelper.getTitoloApc(TipoOperazione.ADD, as, tipoAccordo, labelASTitle, null, false);
  194.            
  195.             String labelRisorse = (isModalitaVistaApiCustom!=null && isModalitaVistaApiCustom.booleanValue()) ? AccordiServizioParteComuneCostanti.LABEL_RISORSE : AccordiServizioParteComuneCostanti.LABEL_RISORSE + " di " + labelASTitle;
  196.             listaParams.add(new Parameter(labelRisorse, AccordiServizioParteComuneCostanti.SERVLET_NAME_APC_RESOURCES_LIST, pIdAccordo, pNomeAccordo, pTipoAccordo));
  197.             listaParams.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_AGGIUNGI, null));


  198.             // Se idhid = null, devo visualizzare la pagina per l'inserimento
  199.             // dati
  200.             if(ServletUtils.isEditModeInProgress(editMode)){

  201.                 // setto la barra del titolo
  202.                 ServletUtils.setPageDataTitle(pd, listaParams);

  203.                 if (profProtocollo == null) {
  204.                     profProtocollo = AccordiServizioParteComuneCostanti.INFORMAZIONI_PROTOCOLLO_MODALITA_DEFAULT;
  205.                 }

  206.                 // Prende i default stabiliti nell'accordo relativo
  207.                 filtrodupaz = filtrodupaz != null && !"".equals(filtrodupaz) ? filtrodupaz : AccordiServizioParteComuneHelper.convertAbilitatoDisabilitatoDB2View(as.getFiltroDuplicati());
  208.                 confricaz = confricaz != null && !"".equals(confricaz) ? confricaz : AccordiServizioParteComuneHelper.convertAbilitatoDisabilitatoDB2View(as.getConfermaRicezione());
  209.                 idcollaz = idcollaz != null && !"".equals(idcollaz) ? idcollaz : AccordiServizioParteComuneHelper.convertAbilitatoDisabilitatoDB2View(as.getIdCollaborazione());
  210.                 idRifRichiestaAz = idRifRichiestaAz != null && !"".equals(idRifRichiestaAz) ? idRifRichiestaAz : AccordiServizioParteComuneHelper.convertAbilitatoDisabilitatoDB2View(as.getIdRiferimentoRichiesta());
  211.                 consordaz = consordaz != null && !"".equals(consordaz) ? consordaz : AccordiServizioParteComuneHelper.convertAbilitatoDisabilitatoDB2View(as.getConsegnaInOrdine());
  212.                 scadenzaaz = scadenzaaz != null && !"".equals(scadenzaaz) ? scadenzaaz : as.getScadenza();
  213.                
  214.                
  215.                 // preparo i campi
  216.                 List<DataElement> dati = new ArrayList<>();

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

  218.                 consoleDynamicConfiguration.updateDynamicConfigResource(consoleConfiguration, consoleOperationType, apcHelper, protocolProperties,
  219.                         registryReader, configRegistryReader, idRisorsa, httpMethod, path);

  220.                 dati = apcHelper.addAccordiResourceToDati(tipoOp, dati, id, null, nomeRisorsa, descr, path,httpMethod, messageType,  as.getStatoPackage(),tipoAccordo,protocollo,
  221.                         protocolFactory,serviceBinding,messageTypeRequest,messageTypeResponse,
  222.                         profProtocollo,
  223.                         filtrodupaz, filtrodupaz, confricaz, confricaz, idcollaz, idcollaz, idRifRichiestaAz, idRifRichiestaAz, consordaz, consordaz, scadenzaaz, scadenzaaz, false);

  224.                 // aggiunta campi custom
  225.                 dati = apcHelper.addProtocolPropertiesToDatiRegistry(dati, consoleConfiguration,consoleOperationType, protocolProperties);

  226.                 pd.setDati(dati);

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

  228.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping, AccordiServizioParteComuneCostanti.OBJECT_NAME_APC_RESOURCES, ForwardParams.ADD());
  229.             }

  230.             if (profProtocollo == null) {
  231.                 profProtocollo = AccordiServizioParteComuneCostanti.INFORMAZIONI_PROTOCOLLO_MODALITA_DEFAULT;
  232.             }
  233.            
  234.             boolean isOk = true;
  235.            
  236.             // controllo valori method e path
  237.             if(AccordiServizioParteComuneCostanti.DEFAULT_VALUE_PARAMETRO_APC_RESOURCES_HTTP_METHOD_QUALSIASI.equals(httpMethod) || "".equals(httpMethod)) {
  238.                 httpMethod = null;
  239.             }
  240.            
  241.             // 1. se il path non inizia per '/' aggiungo all'inizio della stringa
  242.             String pathNormalizzato = path;
  243.             if(pathNormalizzato!=null && !"".equals(pathNormalizzato)) {
  244.                 pathNormalizzato = apcHelper.normalizePathEmpty(path);
  245.             }
  246.             if(pathNormalizzato!=null && !"".equals(pathNormalizzato)) {
  247.                 pathNormalizzato = pathNormalizzato.trim();
  248.                 if(!pathNormalizzato.startsWith("/")) {
  249.                     pathNormalizzato = "/" + pathNormalizzato;
  250.                 }
  251.                 if(pathNormalizzato.length()>1 && pathNormalizzato.endsWith("/")) {
  252.                     pathNormalizzato = pathNormalizzato.substring(0, pathNormalizzato.length()-1);
  253.                 }
  254.             }
  255.            
  256.             // 2. se il nome non e; stato impostato allora genero un nome automatico
  257.             String nomeRisorsaProposto = nomeRisorsa;
  258.             if(StringUtils.isEmpty(nomeRisorsaProposto)) {
  259.                 boolean httpMethodAndPathQualsiasi = apcCore.isApiResourceHttpMethodAndPathQualsiasiEnabled();
  260.                 if(httpMethodAndPathQualsiasi) {
  261.                     if(pathNormalizzato==null || "".equals(pathNormalizzato)) {
  262.                         pd.setMessage("Il campo '"+AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_RESOURCES_PARAMETER_NOME+"' deve essere indicato se il campo '"+AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_RESOURCES_PATH+"' è definito come qualsiasi");
  263.                         isOk = false;
  264.                     }
  265.                     else {
  266.                         nomeRisorsaProposto = APIUtils.normalizeResourceName(HttpMethod.toEnumConstant(httpMethod), pathNormalizzato);
  267.                     }
  268.                 }
  269.                 else {
  270.                     if(httpMethod==null) {
  271.                         pd.setMessage("Il campo '"+AccordiServizioParteComuneCostanti.LABEL_PARAMETRO_APC_RESOURCES_PARAMETER_NOME+"' non è stato definito");
  272.                         isOk = false;
  273.                     }
  274.                     else {
  275.                         nomeRisorsaProposto = APIUtils.normalizeResourceName(HttpMethod.toEnumConstant(httpMethod), pathNormalizzato);
  276.                     }
  277.                 }
  278.             }
  279.            
  280.             // Controlli sui campi immessi
  281.             if(isOk){
  282.                 isOk = apcHelper.accordiResourceCheckData(tipoOp, id, nomeRisorsa, nomeRisorsaProposto, pathNormalizzato, httpMethod, descr, messageType, null,null,null,null,
  283.                         profProtocollo, filtrodupaz, confricaz, idcollaz, idRifRichiestaAz, consordaz, scadenzaaz);
  284.             }

  285.             // updateDynamic
  286.             if(isOk) {
  287.                 consoleDynamicConfiguration.updateDynamicConfigResource(consoleConfiguration, consoleOperationType, apcHelper, protocolProperties,
  288.                         registryReader, configRegistryReader, idRisorsa, httpMethod, path);
  289.             }
  290.            
  291.             // Validazione base dei parametri custom
  292.             if(isOk){
  293.                 try{
  294.                     apcHelper.validaProtocolProperties(consoleConfiguration, consoleOperationType, protocolProperties);
  295.                 }catch(ProtocolException e){
  296.                     ControlStationCore.getLog().error(e.getMessage(),e);
  297.                     pd.setMessage(e.getMessage());
  298.                     isOk = false;
  299.                 }
  300.             }

  301.             // Valido i parametri custom se ho gia' passato tutta la validazione prevista
  302.             if(isOk){
  303.                 try{
  304.                     //validazione campi dinamici
  305.                     consoleDynamicConfiguration.validateDynamicConfigResource(consoleConfiguration, consoleOperationType, apcHelper, protocolProperties,
  306.                             registryReader, configRegistryReader, idRisorsa, httpMethod, path);
  307.                 }catch(ProtocolException e){
  308.                     ControlStationCore.getLog().error(e.getMessage(),e);
  309.                     pd.setMessage(e.getMessage());
  310.                     isOk = false;
  311.                 }
  312.             }

  313.             if (!isOk) {

  314.                 // setto la barra del titolo
  315.                 ServletUtils.setPageDataTitle(pd, listaParams);

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

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

  319.                 consoleDynamicConfiguration.updateDynamicConfigResource(consoleConfiguration, consoleOperationType, apcHelper, protocolProperties,
  320.                         registryReader, configRegistryReader, idRisorsa, httpMethod, path);

  321.                 dati = apcHelper.addAccordiResourceToDati(tipoOp, dati, id, null, nomeRisorsa, descr,path,httpMethod, messageType, as.getStatoPackage(),tipoAccordo,protocollo, protocolFactory,serviceBinding,messageTypeRequest,messageTypeResponse,
  322.                         profProtocollo,
  323.                         filtrodupaz, filtrodupaz, confricaz, confricaz, idcollaz, idcollaz, idRifRichiestaAz, idRifRichiestaAz, consordaz, consordaz, scadenzaaz, scadenzaaz, false);

  324.                 // aggiunta campi custom
  325.                 dati = apcHelper.addProtocolPropertiesToDatiRegistry(dati, consoleConfiguration,consoleOperationType, protocolProperties);

  326.                 pd.setDati(dati);

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

  328.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping, AccordiServizioParteComuneCostanti.OBJECT_NAME_APC_RESOURCES, ForwardParams.ADD());
  329.             }

  330.             // Inserisco la risorsa nel db

  331.             Resource newRes = new Resource();
  332.             newRes.setNome(nomeRisorsaProposto);
  333.             newRes.setDescrizione(descr);
  334.             newRes.setPath("".equals(pathNormalizzato) ? null : pathNormalizzato);
  335.             newRes.setMethodRawEnumValue("".equals(httpMethod) ? null : httpMethod);
  336.             newRes.setMessageType(apcCore.fromMessageMessageType(messageType));
  337.             newRes.setRequestMessageType(apcCore.fromMessageMessageType(messageTypeRequest));
  338.             newRes.setResponseMessageType(apcCore.fromMessageMessageType(messageTypeResponse));
  339.            
  340.             newRes.setFiltroDuplicati(StatoFunzionalita.toEnumConstant(AccordiServizioParteComuneHelper.convertAbilitatoDisabilitatoView2DB(filtrodupaz)));
  341.             newRes.setConfermaRicezione(StatoFunzionalita.toEnumConstant(AccordiServizioParteComuneHelper.convertAbilitatoDisabilitatoView2DB(confricaz)));
  342.             newRes.setIdCollaborazione(StatoFunzionalita.toEnumConstant(AccordiServizioParteComuneHelper.convertAbilitatoDisabilitatoView2DB(idcollaz)));
  343.             newRes.setIdRiferimentoRichiesta(StatoFunzionalita.toEnumConstant(AccordiServizioParteComuneHelper.convertAbilitatoDisabilitatoView2DB(idRifRichiestaAz)));
  344.             newRes.setConsegnaInOrdine(StatoFunzionalita.toEnumConstant(AccordiServizioParteComuneHelper.convertAbilitatoDisabilitatoView2DB(consordaz)));
  345.             newRes.setScadenza(scadenzaaz);
  346.             newRes.setProfAzione(profProtocollo.equals(CostantiRegistroServizi.PROFILO_AZIONE_DEFAULT) ? profProtocollo : CostantiRegistroServizi.PROFILO_AZIONE_RIDEFINITO);
  347.        
  348.             as.addResource(newRes);
  349.            
  350.             //imposto properties custom
  351.             newRes.setProtocolPropertyList(ProtocolPropertiesUtils.toProtocolPropertiesRegistry(protocolProperties, consoleOperationType,null));

  352.             AccordiServizioParteComuneUtilities.createResource(apcCore.isEnableAutoMappingWsdlIntoAccordo(), apcCore, apcHelper, as, userLogin);
  353.            
  354.             // cancello i file temporanei
  355.             apcHelper.deleteBinaryProtocolPropertiesTmpFiles(protocolProperties);

  356.             // Preparo la lista
  357.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);

  358.             List<Resource> lista = apcCore.accordiResourceList(idAccordoLong, ricerca);

  359.             // Devo rileggere l'accordo dal db, perche' altrimenti
  360.             // manca l'id delle risorse
  361.             as = apcCore.getAccordoServizioFull(idAccordoLong);

  362.             apcHelper.prepareAccordiResourcesList(id,as, lista, ricerca,tipoAccordo);

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

  364.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, AccordiServizioParteComuneCostanti.OBJECT_NAME_APC_RESOURCES, ForwardParams.ADD());

  365.         } catch (Exception e) {
  366.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  367.                     AccordiServizioParteComuneCostanti.OBJECT_NAME_APC_RESOURCES, ForwardParams.ADD());
  368.         }
  369.     }
  370. }