PorteApplicativeConnettoriMultipliProprietaList.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.pa;

  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.config.PortaApplicativa;
  31. import org.openspcoop2.core.config.PortaApplicativaServizioApplicativo;
  32. import org.openspcoop2.core.config.Proprieta;
  33. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  34. import org.openspcoop2.web.ctrlstat.core.ControlStationCoreException;
  35. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  36. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  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. /**
  42.  * PorteApplicativeConnettoriMultipliConfigProprietaList
  43.  *
  44.  * @author Andrea Poli (apoli@link.it)
  45.  * @author Giuliano Pintori (pintori@link.it)
  46.  * @author $Author$
  47.  * @version $Rev$, $Date$
  48.  *
  49.  */
  50. public final class PorteApplicativeConnettoriMultipliProprietaList 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.             PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(request, pd, session);
  62.             String idPorta = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  63.             String nomePorta = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME);
  64.             String nomeSAConnettore = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_NOME_SA);
  65.             // Preparo il menu
  66.             porteApplicativeHelper.makeMenu();
  67.    
  68.             // Preparo la lista
  69.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);
  70.    
  71.             int idLista = Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_PROPRIETA;
  72.    
  73.             ricerca = porteApplicativeHelper.checkSearchParameters(idLista, ricerca);
  74.    
  75.             PorteApplicativeCore porteApplicativeCore = new PorteApplicativeCore();
  76.            
  77.             int idInt = Integer.parseInt(idPorta);
  78.             PortaApplicativa pa = porteApplicativeCore.getPortaApplicativa(idInt);
  79.             PortaApplicativaServizioApplicativo oldPaSA = null;
  80.             for (PortaApplicativaServizioApplicativo paSATmp : pa.getServizioApplicativoList()) {
  81.                 if(paSATmp.getNome().equals(nomeSAConnettore)) {
  82.                     oldPaSA = paSATmp;      
  83.                     break;
  84.                 }
  85.             }
  86.             if(oldPaSA==null) {
  87.                 throw new ControlStationCoreException("PortaApplicativaServizioApplicativo con nome '"+nomeSAConnettore+"' non trovato");
  88.             }
  89.            
  90.             long idPaSa = oldPaSA.getId();
  91.            
  92.             List<Proprieta> lista = porteApplicativeCore.porteApplicativeConnettoriMultipliPropList(idPaSa, ricerca);

  93.             porteApplicativeHelper.preparePorteApplicativeConnettoriMultipliPropList(nomePorta, ricerca, lista);
  94.    
  95.             ServletUtils.setSearchObjectIntoSession(request, session, ricerca);
  96.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  97.            
  98.             // Forward control to the specified success URI
  99.             return ServletUtils.getStrutsForward (mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_PROPERTIES,
  100.                     ForwardParams.LIST());
  101.         } catch (Exception e) {
  102.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_PROPERTIES,
  103.                     ForwardParams.LIST());
  104.         }  
  105.     }
  106. }