ConfigurazioneAllarmiList.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.config;

  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.allarmi.constants.RuoloPorta;
  31. import org.openspcoop2.core.commons.Liste;
  32. import org.openspcoop2.message.constants.ServiceBinding;
  33. import org.openspcoop2.monitor.engine.alarm.wrapper.ConfigurazioneAllarmeBean;
  34. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  35. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  36. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  37. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  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. /**
  43.  * ConfigurazioneAllarmiList
  44.  *
  45.  * @author Giuliano Pintori (pintori@link.it)
  46.  * @author $Author$
  47.  * @version $Rev$, $Date$
  48.  *
  49.  */
  50. public final class ConfigurazioneAllarmiList 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.             ConfigurazioneHelper confHelper = new ConfigurazioneHelper(request, pd, session);
  61.            
  62.             String ruoloPortaParam = confHelper.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_RUOLO_PORTA);
  63.             RuoloPorta ruoloPorta = null;
  64.             if(ruoloPortaParam!=null) {
  65.                 ruoloPorta = RuoloPorta.toEnumConstant(ruoloPortaParam);
  66.             }
  67.             String nomePorta = confHelper.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_NOME_PORTA);
  68.             ServiceBinding serviceBinding = null;
  69.             String serviceBindingParam = confHelper.getParameter(ConfigurazioneCostanti.PARAMETRO_CONFIGURAZIONE_ALLARMI_SERVICE_BINDING);
  70.             if(serviceBindingParam!=null && !"".equals(serviceBindingParam)) {
  71.                 serviceBinding = ServiceBinding.valueOf(serviceBindingParam);
  72.             }
  73.            
  74.             String idTab = confHelper.getParameter(CostantiControlStation.PARAMETRO_ID_TAB);
  75.             if(!confHelper.isModalitaCompleta() && StringUtils.isNotEmpty(idTab)) {
  76.                 ServletUtils.setObjectIntoSession(request, session, idTab, CostantiControlStation.PARAMETRO_ID_TAB);
  77.             }

  78.             ConfigurazioneCore confCore = new ConfigurazioneCore();

  79.             // Preparo il menu
  80.             confHelper.makeMenu();
  81.            
  82.             // Preparo la lista
  83.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);

  84.             int idLista = Liste.CONFIGURAZIONE_ALLARMI;

  85.             ricerca = confHelper.checkSearchParameters(idLista, ricerca);

  86.             List<ConfigurazioneAllarmeBean> lista = confCore.allarmiList(ricerca, ruoloPorta, nomePorta);
  87.            
  88.             confHelper.prepareAllarmiList(ricerca, lista, ruoloPorta, nomePorta, serviceBinding);
  89.            
  90.             // salvo l'oggetto ricerca nella sessione
  91.             ServletUtils.setSearchObjectIntoSession(request, session, ricerca);

  92.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  93.             // Forward control to the specified success URI
  94.             return ServletUtils.getStrutsForward (mapping,
  95.                     ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_ALLARMI,
  96.                     ForwardParams.LIST());
  97.         } catch (Exception e) {
  98.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  99.                     ConfigurazioneCostanti.OBJECT_NAME_CONFIGURAZIONE_ALLARMI, ForwardParams.LIST());
  100.         }
  101.     }
  102. }