AccordiServizioParteSpecificaList.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.struts.action.Action;
  26. import org.apache.struts.action.ActionForm;
  27. import org.apache.struts.action.ActionForward;
  28. import org.apache.struts.action.ActionMapping;
  29. import org.openspcoop2.core.commons.Filtri;
  30. import org.openspcoop2.core.commons.Liste;
  31. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  32. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  33. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  34. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  35. import org.openspcoop2.web.ctrlstat.servlet.aps.erogazioni.ErogazioniCostanti;
  36. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCostanti;
  37. import org.openspcoop2.web.lib.mvc.Costanti;
  38. import org.openspcoop2.web.lib.mvc.ForwardParams;
  39. import org.openspcoop2.web.lib.mvc.GeneralData;
  40. import org.openspcoop2.web.lib.mvc.PageData;
  41. import org.openspcoop2.web.lib.mvc.ServletUtils;
  42. import org.openspcoop2.web.lib.users.dao.PermessiUtente;

  43. /**
  44.  * serviziList
  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 AccordiServizioParteSpecificaList 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.             ServletUtils.setObjectIntoSession(request, session, null, ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI);
  66.             // ctrlstatHelper ch = new ctrlstatHelper (request, pd, con, session);
  67.            
  68.             // Preparo il menu
  69.             apsHelper.makeMenu();
  70.            
  71.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore();

  72.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);

  73.             int idLista = Liste.SERVIZI;
  74.                        
  75.             ricerca = apsHelper.checkSearchParameters(idLista, ricerca);

  76.             String tipologia = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  77.             if(tipologia==null) {
  78.                 // guardo se sto entrando da altri link fuori dal menu di sinistra
  79.                 // in tal caso e' gia' impostato
  80.                 tipologia = ServletUtils.getObjectFromSession(request, session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  81.             }
  82.             boolean gestioneFruitori = false;
  83.             boolean gestioneErogatori = false;
  84.             if(tipologia!=null) {
  85.                 if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE.equals(tipologia)) {
  86.                     ServletUtils.setObjectIntoSession(request, session, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE,
  87.                             AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  88.                     ricerca.addFilter(idLista, Filtri.FILTRO_DOMINIO, SoggettiCostanti.SOGGETTO_DOMINIO_OPERATIVO_VALUE);
  89.                     gestioneErogatori = true;
  90.                 }
  91.                 else if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  92.                     ServletUtils.setObjectIntoSession(request, session, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE,
  93.                             AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  94.                    
  95.                     boolean filtraSoloEsterni = true;
  96.                     if(apsCore.isMultitenant() && apsCore.getMultitenantSoggettiFruizioni()!=null) {
  97.                         switch (apsCore.getMultitenantSoggettiFruizioni()) {
  98.                         case SOLO_SOGGETTI_ESTERNI:
  99.                             filtraSoloEsterni = true;
  100.                             break;
  101.                         case ESCLUDI_SOGGETTO_FRUITORE:
  102.                         case TUTTI:
  103.                             filtraSoloEsterni = false;
  104.                             break;
  105.                         }
  106.                     }
  107.                    
  108.                     if(filtraSoloEsterni)
  109.                         ricerca.addFilter(idLista, Filtri.FILTRO_DOMINIO, SoggettiCostanti.SOGGETTO_DOMINIO_ESTERNO_VALUE);
  110.                    
  111.                     gestioneFruitori = true;
  112.                 }
  113.                 else if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_COMPLETA.equals(tipologia)) {
  114.                     ServletUtils.removeObjectFromSession(request, session, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  115.                 }
  116.             }
  117.            
  118.             String superUser   = ServletUtils.getUserLoginFromSession(session);
  119.             PermessiUtente pu = ServletUtils.getUserFromSession(request, session).getPermessi();
  120.            
  121.             boolean [] permessi = new boolean[2];
  122.             permessi[0] = pu.isServizi();
  123.             permessi[1] = pu.isAccordiCooperazione();
  124.            
  125.             List<AccordoServizioParteSpecifica> lista = null;
  126.             if(apsCore.isVisioneOggettiGlobale(superUser)){
  127.                 lista = apsCore.soggettiServizioList(null, ricerca,permessi, gestioneFruitori, gestioneErogatori);
  128.             }else{
  129.                 lista = apsCore.soggettiServizioList(superUser, ricerca,permessi, gestioneFruitori, gestioneErogatori);
  130.             }

  131.             apsHelper.prepareServiziList(ricerca, lista);

  132.             String msg = apsHelper.getParameter(Costanti.PARAMETER_NAME_MSG_ERROR_EXPORT);
  133.             if(msg!=null && !"".equals(msg)){
  134.                 pd.setMessage("Errore durante esportazione: "+msg);
  135.             }
  136.            
  137.             // salvo l'oggetto ricerca nella sessione
  138.             ServletUtils.setSearchObjectIntoSession(request, session, ricerca);

  139.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  140.             // Forward control to the specified success URI
  141.             return ServletUtils.getStrutsForward (mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS,
  142.                     ForwardParams.LIST());
  143.         } catch (Exception e) {
  144.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  145.                     AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS,
  146.                     ForwardParams.LIST());
  147.         }  
  148.     }
  149. }