ErogazioniConfEnv.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.erogazioni.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.IDPortaApplicativa;
  27. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  28. import org.openspcoop2.utils.service.beans.ProfiloEnum;
  29. import org.openspcoop2.utils.service.beans.utils.BaseHelper;
  30. import org.openspcoop2.utils.service.context.IContext;
  31. import org.openspcoop2.utils.service.fault.jaxrs.FaultCode;
  32. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  33. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneHelper;

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

  48.     public ErogazioniConfEnv(HttpServletRequest req, ProfiloEnum profilo, String soggetto, IContext context, String nome, Integer versione, String gruppo, String tipoServizio)
  49.             throws Exception {
  50.         super(req, profilo, soggetto, context);
  51.         this.confCore = new ConfigurazioneCore(this.stationCore);
  52.         this.confHelper = new ConfigurazioneHelper(this.stationCore, this.requestWrapper, this.pd, req.getSession());
  53.            
  54.         this.asps = BaseHelper.supplyOrNotFound( () -> ErogazioniApiHelper.getServizioIfErogazione(tipoServizio, nome, versione, this.idSoggetto.toIDSoggetto(), this), "Erogazione");
  55.         this.idAsps = new IdServizio(this.idServizioFactory.getIDServizioFromAccordo(this.asps), this.asps.getId());
  56.        
  57.         if ( tipoServizio != null && ! this.protocolFactoryMgr._getServiceTypes().get(this.tipo_protocollo).contains(tipoServizio))
  58.             throw FaultCode.RICHIESTA_NON_VALIDA.toException("Tipo Servizio: " + tipoServizio + " sconosciuto ");
  59.    
  60.        
  61.         this.idPa = StringUtils.isEmpty(gruppo)
  62.                 ? BaseHelper.supplyOrNotFound( () -> ErogazioniApiHelper.getIDGruppoPADefault(this.idAsps, this.apsCore),  "Gruppo default per l'erogazione scelta")
  63.                 : BaseHelper.supplyOrNotFound( () -> ErogazioniApiHelper.getIDGruppoPA(gruppo, this.idAsps, this.apsCore), "Gruppo per l'erogazione scelta");

  64.     }

  65. }