ErogazioniChange.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.erogazioni;

  21. import javax.servlet.http.HttpServletRequest;
  22. import javax.servlet.http.HttpServletResponse;
  23. import javax.servlet.http.HttpSession;

  24. import org.apache.struts.action.Action;
  25. import org.apache.struts.action.ActionForm;
  26. import org.apache.struts.action.ActionForward;
  27. import org.apache.struts.action.ActionMapping;
  28. import org.openspcoop2.core.commons.Filtri;
  29. import org.openspcoop2.core.commons.Liste;
  30. import org.openspcoop2.core.commons.SearchUtils;
  31. import org.openspcoop2.core.id.IDSoggetto;
  32. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  33. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  34. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  35. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  36. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  37. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCore;
  38. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCostanti;
  39. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCostanti;
  40. import org.openspcoop2.web.lib.mvc.ForwardParams;
  41. import org.openspcoop2.web.lib.mvc.GeneralData;
  42. import org.openspcoop2.web.lib.mvc.PageData;
  43. import org.openspcoop2.web.lib.mvc.ServletUtils;
  44. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  45. /**
  46.  * ErogazioniChange
  47.  *
  48.  * @author Andrea Poli (poli@link.it)
  49.  * @author Giuliano Pintori (pintori@link.it)
  50.  * @author $Author$
  51.  * @version $Rev$, $Date$
  52.  *
  53.  */
  54. public final class ErogazioniChange extends Action {

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

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

  58.         // Inizializzo PageData
  59.         PageData pd = new PageData();

  60.         GeneralHelper generalHelper = new GeneralHelper(session);

  61.         // Inizializzo GeneralData
  62.         GeneralData gd = generalHelper.initGeneralData(request);

  63.         // Parametri relativi al tipo operazione
  64.         TipoOperazione tipoOp = TipoOperazione.CHANGE;
  65.        
  66.         try {
  67.             ErogazioniHelper apsHelper = new ErogazioniHelper(request, pd, session);
  68.             String id = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID);
  69.             long idInt  = Long.parseLong(id);
  70.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore();
  71.             AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(idInt);
  72.            
  73.             String tipoSoggettoFruitore = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_SOGGETTO_FRUITORE);
  74.             String nomeSoggettoFruitore = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SOGGETTO_FRUITORE);
  75.             IDSoggetto idSoggettoFruitore = null;
  76.             if(tipoSoggettoFruitore!=null && !"".equals(tipoSoggettoFruitore) &&
  77.                     nomeSoggettoFruitore!=null && !"".equals(nomeSoggettoFruitore)) {
  78.                 idSoggettoFruitore = new IDSoggetto(tipoSoggettoFruitore, nomeSoggettoFruitore);
  79.             }
  80.            
  81.             // Rimuovo eventuali salvataggi fatti accedendo in precedenza
  82.             ServletUtils.removeRisultatiRicercaFromSession(request, session, Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI);
  83.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);
  84.             ricerca.setSearchString(Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI, "");
  85.             ricerca.clearFilter(Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI, Filtri.FILTRO_CONNETTORE_TIPO);
  86.             ricerca.clearFilter(Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI, Filtri.FILTRO_CONNETTORE_TIPO_PLUGIN);
  87.             ricerca.clearFilter(Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI, Filtri.FILTRO_CONNETTORE_TOKEN_POLICY);
  88.             ricerca.clearFilter(Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI, Filtri.FILTRO_CONNETTORE_ENDPOINT);
  89.             ricerca.clearFilter(Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI, Filtri.FILTRO_CONNETTORE_KEYSTORE);
  90.             ricerca.clearFilter(Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI, Filtri.FILTRO_CONNETTORE_DEBUG);
  91.             SearchUtils.clearFilter(ricerca, Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI, PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_FILTRO_HIDDEN_TAB_SELEZIONATO);
  92.            
  93.            
  94.             String resetElementoCacheS = apsHelper.getParameter(CostantiControlStation.PARAMETRO_ELIMINA_ELEMENTO_DALLA_CACHE);
  95.             boolean resetElementoCache = ServletUtils.isCheckBoxEnabled(resetElementoCacheS);
  96.            
  97.             boolean resetElementoCacheDettaglio = false;
  98.             String postBackElementName = apsHelper.getPostBackElementName();
  99.             if(postBackElementName != null && postBackElementName.equals(CostantiControlStation.PARAMETRO_ELIMINA_ELEMENTO_DALLA_CACHE)) {
  100.                 resetElementoCacheDettaglio = true;
  101.             }
  102.            
  103.             if(resetElementoCache || resetElementoCacheDettaglio) {
  104.                 // reset elemento dalla cache
  105.                 return apsHelper.prepareErogazioneChangeResetCache(mapping, gd, ricerca, tipoOp, asps, idSoggettoFruitore);
  106.             }
  107.            
  108.             apsHelper.prepareErogazioneChange(tipoOp, asps, idSoggettoFruitore);
  109.            
  110.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  111.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, ErogazioniCostanti.OBJECT_NAME_ASPS_EROGAZIONI, ForwardParams.CHANGE());
  112.         } catch (Exception e) {
  113.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  114.                     ErogazioniCostanti.OBJECT_NAME_ASPS_EROGAZIONI, ForwardParams.CHANGE());
  115.         }  

  116.     }
  117. }