AccordiServizioParteComuneList.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.apc;

  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.beans.AccordoServizioParteComuneSintetico;
  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.apc.api.ApiCostanti;
  35. import org.openspcoop2.web.lib.mvc.Costanti;
  36. import org.openspcoop2.web.lib.mvc.ForwardParams;
  37. import org.openspcoop2.web.lib.mvc.GeneralData;
  38. import org.openspcoop2.web.lib.mvc.PageData;
  39. import org.openspcoop2.web.lib.mvc.ServletUtils;

  40. /**
  41.  * accordiList
  42.  *
  43.  * @author Andrea Poli (apoli@link.it)
  44.  * @author Stefano Corallo (corallo@link.it)
  45.  * @author Sandra Giangrandi (sandra@link.it)
  46.  * @author $Author$
  47.  * @version $Rev$, $Date$
  48.  *
  49.  */
  50. public final class AccordiServizioParteComuneList extends Action {

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

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

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

  56.         GeneralHelper generalHelper = new GeneralHelper(session);

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

  59.    
  60.         try {
  61.             AccordiServizioParteComuneHelper apcHelper = new AccordiServizioParteComuneHelper(request, pd, session);
  62.            
  63.             ServletUtils.removeObjectFromSession(request, session, ApiCostanti.SESSION_ATTRIBUTE_VISTA_APC_API);

  64.             String tipoAccordo = apcHelper.getParameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_TIPO_ACCORDO);
  65.             if("".equals(tipoAccordo))
  66.                 tipoAccordo = null;
  67.            
  68.             apcHelper.makeMenu();

  69.             AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore();
  70.            
  71.             // Controllo i criteri di ricerca e recupero eventuali parametri
  72.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);

  73.             int idLista = Liste.ACCORDI;

  74.             ricerca = apcHelper.checkSearchParameters(idLista, ricerca);
  75.             String userLogin = ServletUtils.getUserLoginFromSession(session);
  76.            
  77.             List<AccordoServizioParteComuneSintetico> lista = AccordiServizioParteComuneUtilities.accordiList(apcCore, userLogin, ricerca, tipoAccordo);
  78.             apcHelper.prepareAccordiList(lista, ricerca, tipoAccordo);

  79.             String msg = apcHelper.getParameter(Costanti.PARAMETER_NAME_MSG_ERROR_EXPORT);
  80.             if(msg!=null && !"".equals(msg)){
  81.                 pd.setMessage("Errore durante esportazione: "+msg);
  82.             }
  83.            
  84.             // salvo l'oggetto ricerca nella sessione
  85.             ServletUtils.setSearchObjectIntoSession(request, session, ricerca);
  86.            
  87.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  88.            
  89.             return ServletUtils.getStrutsForward(mapping, AccordiServizioParteComuneCostanti.OBJECT_NAME_APC, ForwardParams.LIST());

  90.         } catch (Exception e) {
  91.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  92.                     AccordiServizioParteComuneCostanti.OBJECT_NAME_APC, ForwardParams.LIST());
  93.         }
  94.     }
  95. }