ConfigurationServiceBindingRest.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.ArrayList;
  23. import java.util.List;

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

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

  35.     /**
  36.      *
  37.      */
  38.     private static final long serialVersionUID = 1L;
  39.    
  40.     private RestBinding binding;
  41.    
  42.     public ConfigurationServiceBindingRest(boolean enabled,RestBinding binding,
  43.             IntegrationErrorCollection internalIntegrationErrorConfiguration,
  44.             IntegrationErrorCollection externalIntegrationErrorConfiguration) throws MessageException{
  45.         super(ServiceBinding.REST, enabled,internalIntegrationErrorConfiguration,externalIntegrationErrorConfiguration);
  46.         if(this.enabled){
  47.             if(binding==null){
  48.                 throw new MessageException("RestBinding not defined");
  49.             }
  50.             this.binding = binding;
  51.         }
  52.     }
  53.    
  54.     @Override
  55.     public void init(){
  56.         if(this.enabled){
  57.             this.request = new RestMediaTypeCollection(this.binding);
  58.             this.response = new RestMediaTypeCollection(this.binding);
  59.         }
  60.     }
  61.    
  62.     public RestBinding getBinding() {
  63.         return this.binding;
  64.     }
  65.    
  66.     @Override
  67.     public List<MessageType> getMessageTypeSupported(){
  68.          List<MessageType> list = new ArrayList<MessageType>();
  69.          if(this.binding!=null) {
  70.              if(this.binding.isBinding_xml()) {
  71.                  list.add(MessageType.XML);
  72.              }
  73.              if(this.binding.isBinding_json()) {
  74.                  list.add(MessageType.JSON);
  75.              }
  76.              if(this.binding.isBinding_binary()) {
  77.                  list.add(MessageType.BINARY);
  78.              }
  79.              if(this.binding.isBinding_mimeMultipart()) {
  80.                  list.add(MessageType.MIME_MULTIPART);
  81.              }
  82.          }
  83.          return list;
  84.     }
  85.    
  86. }