PorteApplicativeExtendedUtilities.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.ArrayList;
  22. import java.util.List;

  23. import org.apache.commons.lang.StringUtils;
  24. import org.openspcoop2.web.ctrlstat.core.UrlParameters;
  25. import org.openspcoop2.web.ctrlstat.plugins.ExtendedException;
  26. import org.openspcoop2.web.ctrlstat.servlet.ConsoleHelper;
  27. import org.openspcoop2.web.lib.mvc.DataElement;
  28. import org.openspcoop2.web.lib.mvc.Parameter;
  29. import org.openspcoop2.web.lib.mvc.ServletUtils;
  30. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  31. /**
  32.  * PorteApplicativeExtendedUtilities
  33.  *
  34.  * @author Poli Andrea (apoli@link.it)
  35.  * @author $Author$
  36.  * @version $Rev$, $Date$
  37.  */
  38. public class PorteApplicativeExtendedUtilities {
  39.    
  40.     private PorteApplicativeExtendedUtilities() {}

  41.     public static void addToHiddenDati(TipoOperazione tipoOperazione,List<DataElement> dati,ConsoleHelper consoleHelper) throws ExtendedException{
  42.         try {
  43.             String idPorta = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  44.             String idsogg = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO);
  45.             String idasps = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS);
  46.             PorteApplicativeHelper porteApplicativeHelper = (PorteApplicativeHelper)consoleHelper;
  47.             porteApplicativeHelper.addHiddenFieldsToDati(tipoOperazione, idPorta, idsogg, idPorta, idasps, dati);
  48.         }catch(Exception e) {
  49.             throw new ExtendedException(e.getMessage(),e);
  50.         }
  51.     }
  52.    
  53.     public static Object getObject(ConsoleHelper consoleHelper) throws Exception {
  54.         PorteApplicativeCore porteApplicativeCore = new PorteApplicativeCore(consoleHelper.getCore());
  55.         String idPorta = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  56.         int idInt = Integer.parseInt(idPorta);
  57.         return porteApplicativeCore.getPortaApplicativa(idInt);
  58.     }
  59.    
  60.     public static List<Parameter> getTitle(ConsoleHelper consoleHelper) throws Exception {
  61.                
  62.         String idsogg = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO);
  63.         String idAsps = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS);
  64.         if(idAsps == null)
  65.             idAsps = "";
  66.        
  67.         PorteApplicativeHelper paHelper = new PorteApplicativeHelper(consoleHelper.getCore(), consoleHelper.getRequest(), consoleHelper.getPd(), consoleHelper.getSession());
  68.        
  69.         Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, consoleHelper.getSession(), consoleHelper.getRequest());
  70.         if(parentPA == null) parentPA = PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_NONE;
  71.        
  72.         return paHelper.getTitoloPA(parentPA, idsogg, idAsps);
  73.        
  74.     }
  75.    
  76.     public static Parameter[] getParameterList(ConsoleHelper consoleHelper) throws Exception {
  77.        
  78.         String idPorta = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  79.         String idsogg = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO);
  80.         String idasps = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS);
  81.         String nomePorta = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_PORTA);
  82.        
  83.         List<Parameter> list = new ArrayList<>();
  84.         list.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, idPorta));
  85.         list.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idsogg));
  86.         if(StringUtils.isNotEmpty(idasps)) {
  87.             list.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idasps));
  88.         }
  89.         if(StringUtils.isNotEmpty(nomePorta)) {
  90.             list.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_PORTA,nomePorta));
  91.         }
  92.         return list.toArray(new Parameter[1]);
  93.        
  94.     }
  95.    
  96.     public static UrlParameters getUrlExtendedChange(ConsoleHelper consoleHelper) throws Exception {
  97.         String idPorta = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  98.         String idsogg = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO);
  99.         String idasps = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS);
  100.         String nomePorta = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_PORTA);
  101.         UrlParameters urlExtended = new UrlParameters();
  102.         urlExtended.addParameter(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,idPorta));
  103.         urlExtended.addParameter(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg));
  104.         if(StringUtils.isNotEmpty(idasps)) {
  105.             urlExtended.addParameter(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idasps));
  106.         }
  107.         if(StringUtils.isNotEmpty(nomePorta)) {
  108.             urlExtended.addParameter(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_PORTA,nomePorta));
  109.         }
  110.         urlExtended.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_EXTENDED_CHANGE);
  111.         return urlExtended;
  112.     }
  113.    
  114.     public static UrlParameters getUrlExtendedList(ConsoleHelper consoleHelper) throws Exception {
  115.         String idPorta = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  116.         String idsogg = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO);
  117.         String idasps = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS);
  118.         String nomePorta = consoleHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_PORTA);
  119.         UrlParameters urlExtended = new UrlParameters();
  120.         urlExtended.addParameter(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,idPorta));
  121.         urlExtended.addParameter(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg));
  122.         if(StringUtils.isNotEmpty(idasps)) {
  123.             urlExtended.addParameter(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idasps));
  124.         }
  125.         if(StringUtils.isNotEmpty(nomePorta)) {
  126.             urlExtended.addParameter(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_PORTA,nomePorta));
  127.         }
  128.         urlExtended.setUrl(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_EXTENDED_LIST);
  129.         return urlExtended;
  130.     }
  131. }