WSAddressingHeader.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.wsaddressing;

  21. import java.util.Iterator;

  22. import javax.xml.soap.SOAPElement;
  23. import javax.xml.soap.SOAPHeaderElement;

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

  32.     private SOAPHeaderElement to = null;
  33.     private SOAPHeaderElement from = null;
  34.     private SOAPHeaderElement action = null;
  35.     private SOAPHeaderElement id = null;
  36.     private SOAPHeaderElement relatesTo = null;
  37.     private SOAPHeaderElement replyTo = null;
  38.     private SOAPHeaderElement faultTo = null;

  39.     public SOAPHeaderElement getTo() {
  40.         return this.to;
  41.     }
  42.     public String getToValue() {
  43.         if(this.to!=null) {
  44.             return this.to.getValue();
  45.         }
  46.         return null;
  47.     }
  48.     public void setTo(SOAPHeaderElement to) {
  49.         this.to = to;
  50.     }
  51.    
  52.     public SOAPHeaderElement getFrom() {
  53.         return this.from;
  54.     }
  55.     public String getFromValue() {
  56.         if(this.from!=null) {
  57.             return this.getEPRValue(this.from);
  58.         }
  59.         return null;
  60.     }
  61.     public void setFrom(SOAPHeaderElement from) {
  62.         this.from = from;
  63.     }
  64.    
  65.     public SOAPHeaderElement getAction() {
  66.         return this.action;
  67.     }
  68.     public String getActionValue() {
  69.         if(this.action!=null) {
  70.             return this.action.getValue();
  71.         }
  72.         return null;
  73.     }
  74.     public void setAction(SOAPHeaderElement action) {
  75.         this.action = action;
  76.     }
  77.    
  78.     public SOAPHeaderElement getId() {
  79.         return this.id;
  80.     }
  81.     public String getIdValue() {
  82.         if(this.id!=null) {
  83.             return this.id.getValue();
  84.         }
  85.         return null;
  86.     }
  87.     public void setId(SOAPHeaderElement id) {
  88.         this.id = id;
  89.     }
  90.    
  91.     public SOAPHeaderElement getRelatesTo() {
  92.         return this.relatesTo;
  93.     }
  94.     public String getRelatesToValue() {
  95.         if(this.relatesTo!=null) {
  96.             return this.relatesTo.getValue();
  97.         }
  98.         return null;
  99.     }
  100.     public void setRelatesTo(SOAPHeaderElement relatesTo) {
  101.         this.relatesTo = relatesTo;
  102.     }
  103.    
  104.     public SOAPHeaderElement getReplyTo() {
  105.         return this.replyTo;
  106.     }
  107.     public String getReplyToValue() {
  108.         if(this.replyTo!=null) {
  109.             return this.getEPRValue(this.replyTo);
  110.         }
  111.         return null;
  112.     }
  113.     public void setReplyTo(SOAPHeaderElement replyTo) {
  114.         this.replyTo = replyTo;
  115.     }
  116.    
  117.     public SOAPHeaderElement getFaultTo() {
  118.         return this.faultTo;
  119.     }
  120.     public String getFaultToValue() {
  121.         if(this.faultTo!=null) {
  122.             return this.getEPRValue(this.faultTo);
  123.         }
  124.         return null;
  125.     }
  126.     public void setFaultTo(SOAPHeaderElement faultTo) {
  127.         this.faultTo = faultTo;
  128.     }
  129.    
  130.    
  131.     private String getEPRValue(SOAPHeaderElement hdr) {
  132.         if(hdr!=null) {
  133.             Iterator<?> itFROM = hdr.getChildElements();
  134.             while (itFROM.hasNext()) {
  135.                 Object o = itFROM.next();
  136.                 if(o!=null && (o instanceof SOAPElement) ){
  137.                     SOAPElement s = (SOAPElement) o;
  138.                     if(Costanti.WSA_SOAP_HEADER_EPR_ADDRESS.equals(s.getLocalName())){
  139.                         return s.getValue();
  140.                     }
  141.                 }
  142.             }
  143.         }
  144.         return null;
  145.     }

  146. }