AbstractConfigurationServiceBinding.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.message.config;

  21. import java.io.Serializable;
  22. import java.util.List;

  23. import org.openspcoop2.message.constants.MessageType;
  24. import org.openspcoop2.message.constants.ServiceBinding;
  25. import org.openspcoop2.message.exception.MessageException;

  26. /**
  27.  * AbstractConfigurationServiceBinding
  28.  *
  29.  * @author Poli Andrea (apoli@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  */
  33. public abstract class AbstractConfigurationServiceBinding implements Serializable {

  34.     /**
  35.      *
  36.      */
  37.     private static final long serialVersionUID = 1L;
  38.    
  39.     protected ServiceBinding serviceBinding;
  40.     protected boolean enabled;
  41.     protected AbstractMediaTypeCollection request;
  42.     protected AbstractMediaTypeCollection response;
  43.     protected IntegrationErrorCollection internalIntegrationErrorConfiguration;
  44.     protected IntegrationErrorCollection externalIntegrationErrorConfiguration;

  45.     public AbstractConfigurationServiceBinding(ServiceBinding serviceBinding,boolean enabled,
  46.             IntegrationErrorCollection internalIntegrationErrorConfiguration,
  47.             IntegrationErrorCollection externalIntegrationErrorConfiguration) throws MessageException{
  48.         if(serviceBinding==null){
  49.             throw new MessageException("ServiceBinding not defined");
  50.         }
  51.         this.serviceBinding = serviceBinding;
  52.         this.enabled = enabled;
  53.         if(enabled){
  54.            
  55.             if(internalIntegrationErrorConfiguration==null){
  56.                 throw new MessageException("InternalIntegrationErrorConfiguration for binding "+serviceBinding.name()+" not defined");
  57.             }
  58.             if(externalIntegrationErrorConfiguration==null){
  59.                 throw new MessageException("ExternalIntegrationErrorConfiguration for binding "+serviceBinding.name()+" not defined");
  60.             }
  61.             this.internalIntegrationErrorConfiguration = internalIntegrationErrorConfiguration;
  62.             this.externalIntegrationErrorConfiguration = externalIntegrationErrorConfiguration;
  63.         }
  64.     }
  65.    
  66.     public abstract void init();
  67.    
  68.     public abstract List<MessageType> getMessageTypeSupported();
  69.    
  70.     public ServiceBinding getServiceBinding() {
  71.         return this.serviceBinding;
  72.     }
  73.     public boolean isEnabled() {
  74.         return this.enabled;
  75.     }
  76.     public AbstractMediaTypeCollection getRequest() {
  77.         return this.request;
  78.     }
  79.     public AbstractMediaTypeCollection getResponse() {
  80.         return this.response;
  81.     }
  82.     public IntegrationErrorCollection getInternalIntegrationErrorConfiguration() {
  83.         return this.internalIntegrationErrorConfiguration;
  84.     }
  85.     public IntegrationErrorCollection getExternalIntegrationErrorConfiguration() {
  86.         return this.externalIntegrationErrorConfiguration;
  87.     }
  88. }