AccordiServizioParteSpecificaFruitoriPorteDelegateList.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.id.IDSoggetto;
  33. import org.openspcoop2.core.mapping.MappingFruizionePortaDelegata;
  34. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  35. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  36. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  37. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  38. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  39. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  40. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  41. import org.openspcoop2.web.lib.mvc.ForwardParams;
  42. import org.openspcoop2.web.lib.mvc.GeneralData;
  43. import org.openspcoop2.web.lib.mvc.PageData;
  44. import org.openspcoop2.web.lib.mvc.ServletUtils;

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

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

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

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

  61.         GeneralHelper generalHelper = new GeneralHelper(session);

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

  64.         try {
  65.             AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);

  66.             String idServizio = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID);
  67.             Long idS = Long.parseLong(idServizio);
  68.            
  69.             String idFruizione = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID);
  70.             Long idFru = Long.parseLong(idFruizione);
  71.            
  72.             String idSoggFruitoreDelServizio = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO);
  73.             @SuppressWarnings("unused")
  74.             Long idSoggFru = Long.parseLong(idSoggFruitoreDelServizio);
  75.            
  76.             String paramGestioneGruppi = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_GRUPPI);
  77.             if(paramGestioneGruppi!=null && !"".equals(paramGestioneGruppi)) {
  78.                 boolean gestioneGruppi = Boolean.valueOf(paramGestioneGruppi);
  79.                 ServletUtils.setObjectIntoSession(request, session, gestioneGruppi+"", AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_GRUPPI);
  80.             }
  81.            
  82.             String paramGestioneConfigurazioni = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_CONFIGURAZIONI);
  83.             if(paramGestioneConfigurazioni!=null && !"".equals(paramGestioneConfigurazioni)) {
  84.                 boolean gestioneConfigurazioni = Boolean.valueOf(paramGestioneConfigurazioni);
  85.                 ServletUtils.setObjectIntoSession(request, session, gestioneConfigurazioni+"", AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_GESTIONE_CONFIGURAZIONI);
  86.             }
  87.            
  88.             String idTab = apsHelper.getParameter(CostantiControlStation.PARAMETRO_ID_TAB);
  89.             if(!apsHelper.isModalitaCompleta() && StringUtils.isNotEmpty(idTab)) {
  90.                 ServletUtils.setObjectIntoSession(request, session, idTab, CostantiControlStation.PARAMETRO_ID_TAB);
  91.             }
  92.            
  93.             // Preparo il menu
  94.             apsHelper.makeMenu();
  95.    
  96.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore();
  97.             SoggettiCore soggettiCore = new SoggettiCore(apsCore);
  98.    
  99.             // Preparo la lista
  100.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);
  101.    
  102.             int idLista = Liste.CONFIGURAZIONE_FRUIZIONE;
  103.    
  104.             ricerca = apsHelper.checkSearchParameters(idLista, ricerca);
  105.    
  106.             AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(idS);
  107.             IDServizio idServizioFromAccordo = IDServizioFactory.getInstance().getIDServizioFromAccordo(asps);
  108.             IDSoggetto idSoggettoFruitore = new IDSoggetto();
  109.             String tipoSoggettoFruitore = null;
  110.             String nomeSoggettoFruitore = null;
  111.             if(apsCore.isRegistroServiziLocale()){
  112.                 org.openspcoop2.core.registry.Soggetto soggettoFruitore = soggettiCore.getSoggettoRegistro(Integer.parseInt(idSoggFruitoreDelServizio));
  113.                 tipoSoggettoFruitore = soggettoFruitore.getTipo();
  114.                 nomeSoggettoFruitore = soggettoFruitore.getNome();
  115.             }else{
  116.                 org.openspcoop2.core.config.Soggetto soggettoFruitore = soggettiCore.getSoggetto(Integer.parseInt(idSoggFruitoreDelServizio));
  117.                 tipoSoggettoFruitore = soggettoFruitore.getTipo();
  118.                 nomeSoggettoFruitore = soggettoFruitore.getNome();
  119.             }
  120.             idSoggettoFruitore.setTipo(tipoSoggettoFruitore);
  121.             idSoggettoFruitore.setNome(nomeSoggettoFruitore);
  122.              
  123.            
  124.             List<MappingFruizionePortaDelegata> lista = apsCore.serviziFruitoriMappingList(idFru, idSoggettoFruitore , idServizioFromAccordo, ricerca);
  125.    
  126.             apsHelper.serviziFruitoriMappingList(lista, idServizio, idSoggFruitoreDelServizio, idSoggettoFruitore, idFruizione, ricerca);
  127.    
  128.             ServletUtils.setSearchObjectIntoSession(request, session, ricerca);
  129.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  130.            
  131.             // Forward control to the specified success URI
  132.             ForwardParams fwP = apsHelper.isModalitaCompleta() ? ForwardParams.LIST() : AccordiServizioParteSpecificaCostanti.TIPO_OPERAZIONE_CONFIGURAZIONE;
  133.            
  134.             return ServletUtils.getStrutsForward (mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI_PORTE_DELEGATE, fwP);
  135.         } catch (Exception e) {
  136.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  137.                     AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI_PORTE_DELEGATE,
  138.                     ForwardParams.LIST());
  139.         }  
  140.     }
  141. }