SoapMediaTypeCollection.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 org.openspcoop2.message.constants.MessageType;
  23. import org.openspcoop2.message.exception.MessageException;

  24. /**
  25.  * SoapMediaTypeCollection
  26.  *
  27.  * @author Poli Andrea (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class SoapMediaTypeCollection extends AbstractMediaTypeCollection implements Serializable {

  32.     /**
  33.      *
  34.      */
  35.     private static final long serialVersionUID = 1L;
  36.    
  37.    
  38.     private SoapBinding binding;
  39.    
  40.     public SoapMediaTypeCollection(SoapBinding binding){
  41.         this.binding = binding;
  42.     }
  43.    
  44.     private void checkVersion(MessageType version) throws MessageException{
  45.         if(MessageType.SOAP_11.equals(version)){
  46.             if(!this.binding.isBinding_soap11()){
  47.                 throw new MessageException("MessageType ["+version+"] not supported in SoapBinding; Soap11 disabled");
  48.             }
  49.         }
  50.         else if(MessageType.SOAP_12.equals(version)){
  51.             if(!this.binding.isBinding_soap12()){
  52.                 throw new MessageException("MessageType ["+version+"] not supported in SoapBinding; Soap12 disabled");
  53.             }
  54.         }
  55.         else{
  56.             throw new MessageException("MessageType ["+version+"] not supported in SoapBinding");
  57.         }
  58.     }
  59.    
  60.     @Override
  61.     public void addDefaultMediaType(MessageType version) throws MessageException{
  62.         this.checkVersion(version);
  63.         super.addDefaultMediaType(version);
  64.     }
  65.     @Override
  66.     public void addUndefinedMediaType(MessageType version) throws MessageException{
  67.         this.checkVersion(version);
  68.         super.addUndefinedMediaType(version);
  69.     }
  70.     @Override
  71.     public void addMediaType(String mediaType,MessageType version,boolean regExpr) throws MessageException{
  72.         this.checkVersion(version);
  73.         super.addMediaType(mediaType, version, regExpr);
  74.     }
  75.    
  76. }