1 16 package org.apache.axis2.soap.impl.llom; 17 18 import org.apache.axis2.om.*; 19 import org.apache.axis2.soap.SOAPEnvelope; 20 import org.apache.axis2.soap.SOAPHeader; 21 import org.apache.axis2.soap.SOAPHeaderBlock; 22 23 import java.util.ArrayList ; 24 import java.util.Iterator ; 25 26 29 public abstract class SOAPHeaderImpl extends SOAPElement implements SOAPHeader { 30 33 public SOAPHeaderImpl(SOAPEnvelope envelope) throws SOAPProcessingException { 34 super(envelope, SOAPConstants.HEADER_LOCAL_NAME, true); 35 36 } 37 38 44 public SOAPHeaderImpl(SOAPEnvelope envelope, OMXMLParserWrapper builder) { 45 super(envelope, SOAPConstants.HEADER_LOCAL_NAME, builder); 46 } 47 48 59 public abstract SOAPHeaderBlock addHeaderBlock(String localName, OMNamespace ns) 60 throws OMException; 61 62 78 public Iterator examineHeaderBlocks(String paramRole) { 79 Iterator headerBlocksIter = this.getChildren(); 80 ArrayList headersWithGivenActor = new ArrayList (); 81 while (headerBlocksIter.hasNext()) { 82 Object o = headerBlocksIter.next(); 83 if (o instanceof SOAPHeaderBlock) { 84 SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) o; 85 String role = soapHeaderBlock.getRole(); 86 if ((role != null) && role.equalsIgnoreCase(paramRole)) { 87 headersWithGivenActor.add(soapHeaderBlock); 88 } 89 } 90 } 91 return headersWithGivenActor.iterator(); 92 } 93 94 108 public abstract Iterator extractHeaderBlocks(String role); 109 110 122 public Iterator examineMustUnderstandHeaderBlocks(String actor){ 123 Iterator headerBlocksIter = this.getChildren(); 124 ArrayList mustUnderstandHeadersWithGivenActor = new ArrayList (); 125 while (headerBlocksIter.hasNext()) { 126 Object o = headerBlocksIter.next(); 127 if (o instanceof SOAPHeaderBlock) { 128 SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) o; 129 String role = soapHeaderBlock.getRole(); 130 boolean mustUnderstand = soapHeaderBlock.getMustUnderstand(); 131 if ((role != null) && role.equalsIgnoreCase(actor) && mustUnderstand) { 132 mustUnderstandHeadersWithGivenActor.add(soapHeaderBlock); 133 } 134 } 135 } 136 return mustUnderstandHeadersWithGivenActor.iterator(); 137 } 138 139 149 public Iterator examineAllHeaderBlocks() { 150 return this.getChildrenWithName(null); 151 } 152 153 162 public Iterator extractAllHeaderBlocks() { 163 throw new UnsupportedOperationException (); } 165 166 public ArrayList getHeaderBolcksWithNSURI(String nsURI) { 167 ArrayList headers = null; 168 OMNode node = null; 169 OMElement header = this.getFirstElement(); 170 171 if (header != null) { 172 headers = new ArrayList (); 173 } 174 175 node = header; 176 177 while (node != null) { 178 if (node.getType() == OMNode.ELEMENT_NODE) { 179 header = (OMElement) node; 180 if (nsURI.equals(header.getNamespace().getName())) { 181 headers.add(header); 182 } 183 } 184 node = node.getNextSibling(); 185 186 } 187 return headers; 188 189 } 190 191 protected void checkParent(OMElement parent) throws SOAPProcessingException { 192 if (!(parent instanceof SOAPEnvelopeImpl)) { 193 throw new SOAPProcessingException("Expecting an implementation of SOAP Envelope as the parent. But received some other implementation"); 194 } 195 } 196 197 } 198 | Popular Tags |