OpenSPCoop2MessageMimeHeaderProperties.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.soap;

  21. import java.util.Iterator;
  22. import java.util.List;
  23. import java.util.Map;

  24. import javax.xml.soap.SOAPMessage;

  25. import org.openspcoop2.message.OpenSPCoop2MessageProperties;

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

  34.     private SOAPMessage soapMessage;
  35.     protected OpenSPCoop2MessageMimeHeaderProperties(SOAPMessage soapMessage, OpenSPCoop2MessageProperties original) {
  36.         super();
  37.         this.soapMessage = soapMessage;
  38.        
  39.         // inizializzo eventuali header gia' inseriti
  40.         if(original!=null && original.size()>0) {
  41.             Map<String, List<String>> p = original.map();
  42.             Iterator<String> keys = p.keySet().iterator();
  43.             while (keys.hasNext()) {
  44.                 String key = (String) keys.next();
  45.                 List<String> values = p.get(key);
  46.                 if(values!=null && !values.isEmpty()) {
  47.                     for (String value : values) {
  48.                         super.addProperty(key, value);
  49.                         this.soapMessage.getMimeHeaders().addHeader(key, value);        
  50.                     }
  51.                 }
  52.             }
  53.         }
  54.     }
  55.    
  56.     @Override
  57.     public void addProperty(String key,String value){
  58.         super.addProperty(key, value);
  59.         this.soapMessage.getMimeHeaders().addHeader(key, value);
  60.     }

  61. }