ErogazioniList.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 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.Liste;
  30. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  31. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  32. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  33. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  34. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCore;
  35. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCostanti;
  36. import org.openspcoop2.web.lib.mvc.Costanti;
  37. import org.openspcoop2.web.lib.mvc.ForwardParams;
  38. import org.openspcoop2.web.lib.mvc.GeneralData;
  39. import org.openspcoop2.web.lib.mvc.PageData;
  40. import org.openspcoop2.web.lib.mvc.ServletUtils;
  41. import org.openspcoop2.web.lib.users.dao.PermessiUtente;

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

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

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

  55.         // Inizializzo PageData
  56.         PageData pd = new PageData();

  57.         GeneralHelper generalHelper = new GeneralHelper(session);

  58.         // Inizializzo GeneralData
  59.         GeneralData gd = generalHelper.initGeneralData(request);

  60.         try {
  61.             ErogazioniHelper erogazioniHelper = new ErogazioniHelper(request, pd, session);
  62.            
  63.             ServletUtils.setObjectIntoSession(request, session, Boolean.valueOf(true), ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI);
  64.             // Preparo il menu
  65.             erogazioniHelper.makeMenu();
  66.            
  67.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore();

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

  69.             int idLista = Liste.SERVIZI;
  70.            
  71.             // poiche' esistono filtri che hanno necessita di postback salvo in sessione
  72.             List<AccordoServizioParteSpecifica> lista = null;
  73.             if(!ServletUtils.isSearchDone(erogazioniHelper)) {
  74.                 lista = ServletUtils.getRisultatiRicercaFromSession(request, session, idLista,  AccordoServizioParteSpecifica.class);
  75.             }
  76.            
  77.             ricerca = erogazioniHelper.checkSearchParameters(idLista, ricerca);
  78.            
  79.             erogazioniHelper.clearFiltroSoggettoByPostBackProtocollo(0, ricerca, idLista);
  80.            
  81.             String tipologiaParameterName = AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE;
  82.             String tipologia = erogazioniHelper.getParameter(tipologiaParameterName);
  83.             if(tipologia==null) {
  84.                 // guardo se sto entrando da altri link fuori dal menu di sinistra
  85.                 // in tal caso e' gia' impostato
  86.                 tipologia = ServletUtils.getObjectFromSession(request, session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  87.             }
  88.             boolean gestioneFruitori = false;
  89.             boolean gestioneErogatori = false;
  90.             if(tipologia!=null) {
  91.                 if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  92.                     gestioneFruitori = true;
  93.                 }
  94.                 else if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE.equals(tipologia)) {
  95.                     gestioneErogatori = true;
  96.                 }
  97.             }
  98.            
  99.             erogazioniHelper.checkGestione(request, session, ricerca, idLista, tipologiaParameterName,true);
  100.            
  101.             String superUser   = ServletUtils.getUserLoginFromSession(session);
  102.             PermessiUtente pu = ServletUtils.getUserFromSession(request, session).getPermessi();
  103.            
  104.             boolean [] permessi = new boolean[2];
  105.             permessi[0] = pu.isServizi();
  106.             permessi[1] = pu.isAccordiCooperazione();
  107.            
  108. /**         long before = org.openspcoop2.utils.date.DateManager.getTimeMillis();*/
  109.             if(lista==null) {
  110.                 if(apsCore.isVisioneOggettiGlobale(superUser)){
  111.                     lista = apsCore.soggettiServizioList(null, ricerca,permessi, gestioneFruitori, gestioneErogatori);
  112.                 }else{
  113.                     lista = apsCore.soggettiServizioList(superUser, ricerca,permessi, gestioneFruitori, gestioneErogatori);
  114.                 }
  115.             }
  116. /**         long after = org.openspcoop2.utils.date.DateManager.getTimeMillis();
  117. //          System.out.println("READ: "+org.openspcoop2.utils.Utilities.convertSystemTimeIntoString_millisecondi((after-before), true));*/

  118.             if(!erogazioniHelper.isPostBackFilterElement()) {
  119.                 ServletUtils.setRisultatiRicercaIntoSession(request, session, idLista, lista); // salvo poiche' esistono filtri che hanno necessita di postback
  120.             }
  121.            
  122. /**         before = org.openspcoop2.utils.date.DateManager.getTimeMillis();*/
  123.             erogazioniHelper.prepareErogazioniList(ricerca, lista);
  124. /**         after = org.openspcoop2.utils.date.DateManager.getTimeMillis();
  125. //          System.out.println("PRESENTATION: "+org.openspcoop2.utils.Utilities.convertSystemTimeIntoString_millisecondi((after-before), true));*/

  126.             String msg = erogazioniHelper.getParameter(Costanti.PARAMETER_NAME_MSG_ERROR_EXPORT);
  127.             if(msg!=null && !"".equals(msg)){
  128.                 pd.setMessage("Errore durante esportazione: "+msg);
  129.             }
  130.            
  131.             // salvo l'oggetto ricerca nella sessione
  132.             ServletUtils.setSearchObjectIntoSession(request, session, ricerca);

  133.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  134.             // Forward control to the specified success URI
  135.             return ServletUtils.getStrutsForward (mapping, ErogazioniCostanti.OBJECT_NAME_ASPS_EROGAZIONI,
  136.                     ForwardParams.LIST());
  137.         } catch (Exception e) {
  138.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  139.                     ErogazioniCostanti.OBJECT_NAME_ASPS_EROGAZIONI,
  140.                     ForwardParams.LIST());
  141.         }  
  142.     }
  143. }