FruizioniConfEnv.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.core.config.rs.server.api.impl.fruizioni.configurazione;

  21. import javax.servlet.http.HttpServletRequest;

  22. import org.apache.commons.lang3.StringUtils;
  23. import org.openspcoop2.core.config.rs.server.api.impl.IdServizio;
  24. import org.openspcoop2.core.config.rs.server.api.impl.erogazioni.ErogazioniApiHelper;
  25. import org.openspcoop2.core.config.rs.server.api.impl.erogazioni.ErogazioniEnv;
  26. import org.openspcoop2.core.id.IDPortaDelegata;
  27. import org.openspcoop2.core.id.IDSoggetto;
  28. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  29. import org.openspcoop2.utils.service.beans.ProfiloEnum;
  30. import org.openspcoop2.utils.service.beans.utils.BaseHelper;
  31. import org.openspcoop2.utils.service.context.IContext;
  32. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  33. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneHelper;

  34. /**
  35.  * FruizioniConfEnv
  36.  *
  37.  * @author $Author$
  38.  * @version $Rev$, $Date$
  39.  *
  40.  */
  41. public class FruizioniConfEnv extends ErogazioniEnv {
  42.    
  43.    
  44.     public final ConfigurazioneCore confCore;
  45.     public final ConfigurazioneHelper confHelper;
  46.     public final AccordoServizioParteSpecifica asps;
  47.     public final IdServizio idAsps;
  48.     public final IDPortaDelegata idPd;
  49.     public final IDSoggetto idErogatore;


  50.     public FruizioniConfEnv(HttpServletRequest req, ProfiloEnum profilo, String soggetto, IContext context, String erogatore, String nome, Integer versione, String gruppo, String tipoServizio)
  51.             throws Exception {
  52.         super(req, profilo, soggetto, context);
  53.        
  54.         this.confCore = new ConfigurazioneCore(this.stationCore);
  55.         this.confHelper = new ConfigurazioneHelper(this.stationCore, this.requestWrapper, this.pd, req.getSession());
  56.        
  57.         this.idErogatore = new IDSoggetto(this.tipo_soggetto, erogatore);
  58.        
  59.         this.asps = BaseHelper.supplyOrNotFound(
  60.                 () -> ErogazioniApiHelper.getServizioIfFruizione(tipoServizio, nome, versione, this.idErogatore, this.idSoggetto.toIDSoggetto(), this),
  61.                 "Fruizione"
  62.             );
  63.        
  64.         this.idAsps = new IdServizio(this.idServizioFactory.getIDServizioFromAccordo(this.asps), this.asps.getId());
  65.         this.idPd = StringUtils.isEmpty(gruppo)
  66.                 ? BaseHelper.supplyOrNotFound( () -> ErogazioniApiHelper.getIDGruppoPDDefault(this.idSoggetto.toIDSoggetto(), this.idAsps, this.apsCore), "Gruppo default per la fruizione scelta")
  67.                 : BaseHelper.supplyOrNotFound( () -> ErogazioniApiHelper.getIDGruppoPD(gruppo, this.idSoggetto.toIDSoggetto(), this.idAsps, this.apsCore), "Gruppo con nome " + gruppo + " per la fruizione scelta");

  68.     }

  69. }