SoggettiList.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.soggetti;

  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.Soggetto;
  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.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.  * soggettiList
  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 SoggettiList 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.         try {

  60.             // ctrlstatHelper ch = new ctrlstatHelper(request, pd, con, session);
  61.             // Preparo il menu
  62.             // ch.makeMenu();
  63.             SoggettiHelper soggettiHelper = new SoggettiHelper(request, pd, session);
  64.             soggettiHelper.makeMenu();

  65.             String filterDominioInterno = soggettiHelper.getParameter(SoggettiCostanti.PARAMETRO_SOGGETTO_FILTER_DOMINIO_INTERNO);
  66.             boolean forceFilterDominioInterno = false;
  67.             if("true".equalsIgnoreCase(filterDominioInterno)) {
  68.                 forceFilterDominioInterno = true;
  69.             }
  70.            
  71.             SoggettiCore soggettiCore = new SoggettiCore();
  72.            
  73.             boolean multiTenant = soggettiCore.isMultitenant();
  74.            
  75.             // Preparo la lista
  76.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);

  77.             int idLista = Liste.SOGGETTI;
  78.            
  79.             // poiche' esistono filtri che hanno necessita di postback salvo in sessione
  80.             List<Soggetto> lista = null;
  81.             if(soggettiCore.isRegistroServiziLocale() &&
  82.                 !ServletUtils.isSearchDone(soggettiHelper)) {
  83.                 lista = ServletUtils.getRisultatiRicercaFromSession(request, session, idLista,  Soggetto.class);
  84.             }
  85.            
  86.             ricerca = soggettiHelper.checkSearchParameters(idLista, ricerca);
  87.             String userLogin = ServletUtils.getUserLoginFromSession(session);
  88.        
  89.             if(forceFilterDominioInterno) {
  90.                 ricerca.addFilter(idLista, Filtri.FILTRO_DOMINIO, SoggettiCostanti.SOGGETTO_DOMINIO_OPERATIVO_VALUE);
  91.             }
  92.             else if(!multiTenant && !soggettiHelper.isModalitaCompleta()) {
  93.                 ricerca.addFilter(idLista, Filtri.FILTRO_DOMINIO, SoggettiCostanti.SOGGETTO_DOMINIO_ESTERNO_VALUE);
  94.             }
  95.            
  96.             if(soggettiCore.isRegistroServiziLocale()){
  97.                 if(lista==null) {
  98.                     if(soggettiCore.isVisioneOggettiGlobale(userLogin)){
  99.                         lista = soggettiCore.soggettiRegistroList(null, ricerca);
  100.                     }else{
  101.                         lista = soggettiCore.soggettiRegistroList(userLogin, ricerca);
  102.                     }
  103.                 }
  104.                
  105.                 if(!soggettiHelper.isPostBackFilterElement()) {
  106.                     ServletUtils.setRisultatiRicercaIntoSession(request, session, idLista, lista); // salvo poiche' esistono filtri che hanno necessita di postback
  107.                 }
  108.                
  109.                 soggettiHelper.prepareSoggettiList(lista, ricerca);
  110.             }
  111.             else{
  112.                 List<org.openspcoop2.core.config.Soggetto> listaConfig = null;
  113.                 if(soggettiCore.isVisioneOggettiGlobale(userLogin)){
  114.                     listaConfig = soggettiCore.soggettiList(null, ricerca);
  115.                 }else{
  116.                     listaConfig = soggettiCore.soggettiList(userLogin, ricerca);
  117.                 }
  118.                 soggettiHelper.prepareSoggettiConfigList(listaConfig, ricerca);
  119.             }
  120.                        
  121.             String msg = soggettiHelper.getParameter(Costanti.PARAMETER_NAME_MSG_ERROR_EXPORT);
  122.             if(msg!=null && !"".equals(msg)){
  123.                 pd.setMessage("Errore durante esportazione: "+msg);
  124.             }

  125.             ServletUtils.setSearchObjectIntoSession(request, session, ricerca);
  126.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  127.            
  128.             return ServletUtils.getStrutsForward(mapping, SoggettiCostanti.OBJECT_NAME_SOGGETTI, ForwardParams.LIST());

  129.         } catch (Exception e) {
  130.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  131.                     SoggettiCostanti.OBJECT_NAME_SOGGETTI, ForwardParams.LIST());
  132.         }
  133.     }
  134. }