URLProtocolContext.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.protocol.sdk.state;

  21. import javax.servlet.http.HttpServletRequest;

  22. import org.openspcoop2.protocol.sdk.ProtocolException;
  23. import org.openspcoop2.protocol.sdk.constants.IDService;
  24. import org.openspcoop2.utils.UtilsException;
  25. import org.openspcoop2.utils.transport.http.HttpServletTransportRequestContext;
  26. import org.slf4j.Logger;

  27. /**
  28.  * URL Protocol Context
  29.  *
  30.  * @author Poli Andrea (apoli@link.it)
  31.  * @author $Author$
  32.  * @version $Rev$, $Date$
  33.  */


  34. public abstract class URLProtocolContext extends HttpServletTransportRequestContext implements java.io.Serializable {


  35.     /**
  36.      *
  37.      */
  38.     private static final long serialVersionUID = 1L;
  39.    
  40.     public static final String PA_FUNCTION = "PA";
  41.     public static final String PA_FUNCTION_GOVWAY = "in";
  42.     public static final String PD_FUNCTION = "PD";
  43.     public static final String PD_FUNCTION_GOVWAY = "out";
  44.     public static final String PDtoSOAP_FUNCTION = "PDtoSOAP";
  45.     public static final String PDtoSOAP_FUNCTION_GOVWAY = "out/xml2soap";
  46.     public static final String IntegrationManager_FUNCTION = "IntegrationManager";
  47.     public static final String IntegrationManager_ENGINE = "IntegrationManagerEngine";
  48.     public static final String IntegrationManager_SERVICE_PD = "PD";
  49.     public static final String IntegrationManager_SERVICE_PD_GOVWAY = "out";
  50.     public static final String IntegrationManager_SERVICE_MessageBox = "MessageBox";
  51.     public static final String IntegrationManager_FUNCTION_PD = IntegrationManager_FUNCTION+"/"+IntegrationManager_SERVICE_PD;
  52.     public static final String IntegrationManager_FUNCTION_MessageBox = IntegrationManager_FUNCTION+"/"+IntegrationManager_SERVICE_MessageBox;
  53.     public static final String IntegrationManager_ENGINE_FUNCTION_PD = IntegrationManager_ENGINE+"/"+IntegrationManager_SERVICE_PD;
  54.     public static final String IntegrationManager_ENGINE_FUNCTION_MessageBox = IntegrationManager_ENGINE+"/"+IntegrationManager_SERVICE_MessageBox;
  55.     public static final String Check_FUNCTION = "check";
  56.     public static final String Proxy_FUNCTION = "proxy";
  57.    
  58.     protected IDService idServiceCustom;
  59.    
  60.     public IDService getIdServiceCustom() {
  61.         return this.idServiceCustom;
  62.     }
  63.    
  64.     public boolean isPortaApplicativaService() {
  65.         if(this.idServiceCustom!=null) {
  66.             return IDService.PORTA_APPLICATIVA.equals(this.idServiceCustom);
  67.         }
  68.         else {
  69.             return URLProtocolContext.PA_FUNCTION.equals(this.function);
  70.         }
  71.     }
  72.     public boolean isPortaDelegataService() {
  73.         if(this.idServiceCustom!=null) {
  74.             return IDService.PORTA_DELEGATA.equals(this.idServiceCustom) ||
  75.                     IDService.PORTA_DELEGATA_INTEGRATION_MANAGER.equals(this.idServiceCustom) ||
  76.                     IDService.PORTA_DELEGATA_XML_TO_SOAP.equals(this.idServiceCustom);
  77.         }
  78.         else {
  79.             return URLProtocolContext.PD_FUNCTION.equals(this.function);
  80.         }
  81.     }
  82.    
  83.     protected URLProtocolContext(Logger logCore) throws UtilsException{
  84.         super(logCore);
  85.     }
  86.     protected URLProtocolContext(HttpServletRequest req,Logger logCore, boolean debug, FunctionContextsCustom customContexts) throws ProtocolException, UtilsException{
  87.         this(req, logCore, debug, false, customContexts);
  88.     }
  89.     protected URLProtocolContext(HttpServletRequest req,Logger logCore, boolean debug, boolean integrationManagerEngine, FunctionContextsCustom customContexts) throws ProtocolException, UtilsException{
  90.         super(req, logCore, debug);
  91.         init(req, logCore, debug, integrationManagerEngine, customContexts);
  92.     }
  93.    
  94.     protected abstract void init(HttpServletRequest req,Logger logCore, boolean debug, boolean integrationManagerEngine, FunctionContextsCustom customContexts) throws ProtocolException, UtilsException;
  95. }