AccordiServizioParteSpecificaPorteApplicativeList.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.util.List;

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

  25. import org.apache.commons.lang.StringUtils;
  26. import org.apache.struts.action.Action;
  27. import org.apache.struts.action.ActionForm;
  28. import org.apache.struts.action.ActionForward;
  29. import org.apache.struts.action.ActionMapping;
  30. import org.openspcoop2.core.commons.Liste;
  31. import org.openspcoop2.core.id.IDServizio;
  32. import org.openspcoop2.core.mapping.MappingErogazionePortaApplicativa;
  33. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  34. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  35. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  36. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  37. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  38. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  39. import org.openspcoop2.web.lib.mvc.ForwardParams;
  40. import org.openspcoop2.web.lib.mvc.GeneralData;
  41. import org.openspcoop2.web.lib.mvc.PageData;
  42. import org.openspcoop2.web.lib.mvc.ServletUtils;

  43. /**
  44.  * serviziPorteAppList
  45.  *
  46.  * @author Andrea Poli (apoli@link.it)
  47.  * @author Stefano Corallo (corallo@link.it)
  48.  * @author Sandra Giangrandi (sandra@link.it)
  49.  * @author $Author$
  50.  * @version $Rev$, $Date$
  51.  *
  52.  */
  53. public final class AccordiServizioParteSpecificaPorteApplicativeList extends Action {

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

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

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

  59.         GeneralHelper generalHelper = new GeneralHelper(session);

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

  62.         try {
  63.             AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);
  64.             /*
  65.              * Validate the request parameters specified by the user Note: Basic
  66.              * field validation done in porteDomForm.java Business logic validation
  67.              * done in porteDomAdd.java
  68.              */
  69.             String id = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID);
  70.             int idServizio = Integer.parseInt(id);
  71.             String idSoggettoErogatoreDelServizio = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);
  72.             if ((idSoggettoErogatoreDelServizio == null) || idSoggettoErogatoreDelServizio.equals("")) {
  73.                 PageData oldPD = ServletUtils.getPageDataFromSession(request, session);
  74.    
  75.                 idSoggettoErogatoreDelServizio = oldPD.getHidden(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);
  76.             }
  77.    
  78.             String paramGestioneGruppi = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_GRUPPI);
  79.             if(paramGestioneGruppi!=null && !"".equals(paramGestioneGruppi)) {
  80.                 boolean gestioneGruppi = Boolean.valueOf(paramGestioneGruppi);
  81.                 ServletUtils.setObjectIntoSession(request, session, gestioneGruppi+"", AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_GRUPPI);
  82.             }
  83.            
  84.             String paramGestioneConfigurazioni = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_CONFIGURAZIONI);
  85.             if(paramGestioneConfigurazioni!=null && !"".equals(paramGestioneConfigurazioni)) {
  86.                 boolean gestioneConfigurazioni = Boolean.valueOf(paramGestioneConfigurazioni);
  87.                 ServletUtils.setObjectIntoSession(request, session, gestioneConfigurazioni+"", AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_CONFIGURAZIONI);
  88.             }
  89.            
  90.             String idTab = apsHelper.getParameter(CostantiControlStation.PARAMETRO_ID_TAB);
  91.             if(!apsHelper.isModalitaCompleta() && StringUtils.isNotEmpty(idTab)) {
  92.                 ServletUtils.setObjectIntoSession(request, session, idTab, CostantiControlStation.PARAMETRO_ID_TAB);
  93.             }
  94.            
  95.             // Rimuovo l'eventuale lista per evitare che in presenza di connettori multipli ridefiniti su un gruppo, lo switch tra gruppi diversi faccia trovare in sessione la lista dei connettori errati
  96.             ServletUtils.removeRisultatiRicercaFromSession(request, session, Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI);
  97.            
  98.             // Preparo il menu
  99.             apsHelper.makeMenu();
  100.    
  101.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore();
  102.    
  103.             // Preparo la lista
  104.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);
  105.    
  106.             int idLista = Liste.CONFIGURAZIONE_EROGAZIONE;
  107.    
  108.             ricerca = apsHelper.checkSearchParameters(idLista, ricerca);
  109.    
  110.             AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(idServizio);
  111.             IDServizio idServizio2 = IDServizioFactory.getInstance().getIDServizioFromAccordo(asps);
  112.             List<MappingErogazionePortaApplicativa> lista = apsCore.mappingServiziPorteAppList(idServizio2,asps.getId(), ricerca);
  113.            
  114.             apsHelper.prepareServiziConfigurazioneList(lista, id, idSoggettoErogatoreDelServizio, ricerca);
  115.    
  116.             ServletUtils.setSearchObjectIntoSession(request, session, ricerca);
  117.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  118.            
  119.             ForwardParams fwP = apsHelper.isModalitaCompleta() ? ForwardParams.LIST() : AccordiServizioParteSpecificaCostanti.TIPO_OPERAZIONE_CONFIGURAZIONE;
  120.             // Forward control to the specified success URI
  121.             return ServletUtils.getStrutsForward (mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,
  122.                     fwP);
  123.         } catch (Exception e) {
  124.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  125.                     AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,
  126.                     ForwardParams.LIST());
  127.         }  
  128.     }
  129. }