PorteDelegateExtendedUtilities.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.pd;

  21. import java.util.List;

  22. import org.openspcoop2.web.ctrlstat.core.UrlParameters;
  23. import org.openspcoop2.web.ctrlstat.plugins.ExtendedException;
  24. import org.openspcoop2.web.ctrlstat.servlet.ConsoleHelper;
  25. import org.openspcoop2.web.lib.mvc.DataElement;
  26. import org.openspcoop2.web.lib.mvc.Parameter;
  27. import org.openspcoop2.web.lib.mvc.ServletUtils;
  28. import org.openspcoop2.web.lib.mvc.TipoOperazione;

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

  39.     public static void addToHiddenDati(TipoOperazione tipoOperazione,List<DataElement> dati,ConsoleHelper consoleHelper) throws ExtendedException{
  40.         try {
  41.             String id = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  42.             String idsogg = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  43.             PorteDelegateHelper porteDelegateHelper = (PorteDelegateHelper)consoleHelper;
  44.             porteDelegateHelper.addHiddenFieldsToDati(tipoOperazione, id, idsogg, null, dati);
  45.         }catch(Exception e) {
  46.             throw new ExtendedException(e.getMessage(),e);
  47.         }
  48.     }
  49.    
  50.     public static Object getObject(ConsoleHelper consoleHelper) throws Exception {
  51.         PorteDelegateCore porteDelegateCore = new PorteDelegateCore(consoleHelper.getCore());
  52.         String id = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  53.         int idInt = Integer.parseInt(id);
  54.         return porteDelegateCore.getPortaDelegata(idInt);
  55.     }
  56.    
  57.     public static List<Parameter> getTitle(ConsoleHelper consoleHelper) throws Exception {
  58.        
  59.         String idSoggettoFruitore = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);

  60.         String idAsps = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_ASPS);
  61.         if(idAsps == null)
  62.             idAsps = "";
  63.        
  64.         String idFruizione = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_FRUIZIONE);
  65.         if(idFruizione == null)
  66.             idFruizione = "";
  67.        
  68.         PorteDelegateHelper pdHelper = new PorteDelegateHelper(consoleHelper.getCore(), consoleHelper.getRequest(), consoleHelper.getPd(), consoleHelper.getSession());
  69.        
  70.         // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  71.         Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, consoleHelper.getSession(), consoleHelper.getRequest());
  72.         if(parentPD == null) parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  73.        
  74.         return pdHelper.getTitoloPD(parentPD, idSoggettoFruitore, idAsps, idFruizione);
  75.        
  76.     }
  77.    
  78.     public static Parameter[] getParameterList(ConsoleHelper consoleHelper) throws Exception {
  79.        
  80.         String id = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  81.         String idsogg = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  82.        
  83.         Parameter[] par = new Parameter[2];
  84.         par[0] = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID, id);
  85.         par[1] = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO, idsogg);
  86.         return par;
  87.        
  88.     }
  89.    
  90.     public static UrlParameters getUrlExtendedChange(ConsoleHelper consoleHelper) throws Exception {
  91.         String id = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  92.         String idsogg = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  93.         UrlParameters urlExtended = new UrlParameters();
  94.         urlExtended.addParameter(new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID,id));
  95.         urlExtended.addParameter(new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO,idsogg));
  96.         urlExtended.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_EXTENDED_CHANGE);
  97.         return urlExtended;
  98.     }
  99.    
  100.     public static UrlParameters getUrlExtendedList(ConsoleHelper consoleHelper) throws Exception {
  101.         String id = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID);
  102.         String idsogg = consoleHelper.getParameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO);
  103.         UrlParameters urlExtended = new UrlParameters();
  104.         urlExtended.addParameter(new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID,id));
  105.         urlExtended.addParameter(new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_ID_SOGGETTO,idsogg));
  106.         urlExtended.setUrl(PorteDelegateCostanti.SERVLET_NAME_PORTE_DELEGATE_EXTENDED_LIST);
  107.         return urlExtended;
  108.     }
  109. }