< prev index next >

jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/message/saaj/SAAJMessageHeaders.java

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.api.message.saaj;
  27 












  28 import java.util.ArrayList;
  29 import java.util.Collections;
  30 import java.util.HashMap;
  31 import java.util.HashSet;
  32 import java.util.Iterator;
  33 import java.util.List;
  34 import java.util.Map;
  35 import java.util.Set;
  36 
  37 import javax.xml.namespace.QName;
  38 import javax.xml.soap.SOAPException;
  39 import javax.xml.soap.SOAPHeader;
  40 import javax.xml.soap.SOAPHeaderElement;
  41 import javax.xml.soap.SOAPMessage;
  42 
  43 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
  44 import com.sun.xml.internal.messaging.saaj.soap.impl.HeaderImpl;
  45 import com.sun.xml.internal.ws.api.SOAPVersion;
  46 import com.sun.xml.internal.ws.api.WSBinding;
  47 import com.sun.xml.internal.ws.api.message.Header;
  48 import com.sun.xml.internal.ws.api.message.MessageHeaders;
  49 import com.sun.xml.internal.ws.binding.SOAPBindingImpl;
  50 import com.sun.xml.internal.ws.message.saaj.SAAJHeader;
  51 
  52 public class SAAJMessageHeaders implements MessageHeaders {
  53     SOAPMessage sm;
  54     Map<SOAPHeaderElement, Header> nonSAAJHeaders;
  55     Map<QName, Integer> notUnderstoodCount;
  56     SOAPVersion soapVersion;
  57     private Set<QName> understoodHeaders;
  58 
  59     public SAAJMessageHeaders(SOAPMessage sm, SOAPVersion version) {
  60         this.sm = sm;
  61         this.soapVersion = version;
  62         initHeaderUnderstanding();
  63     }
  64 
  65     /** Set the initial understood/not understood state of the headers in this
  66      * object
  67      */
  68     private void initHeaderUnderstanding() {
  69         SOAPHeader soapHeader = ensureSOAPHeader();
  70         if (soapHeader == null) {
  71             return;


 219         if (isNonSAAJHeader(header)) {
 220             //TODO assumes only one header with that name?
 221             addNonSAAJHeader(find(header.getNamespaceURI(), header.getLocalPart()),
 222                     header);
 223         }
 224 
 225         return true;
 226     }
 227 
 228     @Override
 229     public Header remove(QName name) {
 230         return remove(name.getNamespaceURI(), name.getLocalPart());
 231     }
 232 
 233     @Override
 234     public Header remove(String nsUri, String localName) {
 235         SOAPHeader soapHeader = ensureSOAPHeader();
 236         if (soapHeader == null) {
 237             return null;
 238         }
 239         SOAPDocumentImpl soapDocument = ((HeaderImpl)soapHeader).getSoapDocument();
 240         SOAPHeaderElement headerElem = find(nsUri, localName);
 241         if (headerElem == null) {
 242             return null;
 243         }
 244         headerElem = (SOAPHeaderElement) soapDocument.find(soapHeader.removeChild(headerElem));
 245 
 246         //it might have been a nonSAAJHeader - remove from that map
 247         removeNonSAAJHeader(headerElem);
 248 
 249         //remove it from understoodHeaders and notUnderstoodHeaders if present
 250         QName hdrName = (nsUri == null) ? new QName(localName) : new QName(nsUri, localName);
 251         if (understoodHeaders != null) {
 252             understoodHeaders.remove(hdrName);
 253         }
 254         removeNotUnderstood(hdrName);
 255 
 256         return new SAAJHeader(headerElem);
 257     }
 258 
 259     private void removeNotUnderstood(QName hdrName) {
 260         if (notUnderstoodCount == null) {
 261             return;
 262         }
 263         Integer notUnderstood = notUnderstoodCount.get(hdrName);
 264         if (notUnderstood != null) {




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.api.message.saaj;
  27 
  28 import com.sun.xml.internal.ws.api.SOAPVersion;
  29 import com.sun.xml.internal.ws.api.WSBinding;
  30 import com.sun.xml.internal.ws.api.message.Header;
  31 import com.sun.xml.internal.ws.api.message.MessageHeaders;
  32 import com.sun.xml.internal.ws.binding.SOAPBindingImpl;
  33 import com.sun.xml.internal.ws.message.saaj.SAAJHeader;
  34 
  35 import javax.xml.namespace.QName;
  36 import javax.xml.soap.SOAPException;
  37 import javax.xml.soap.SOAPHeader;
  38 import javax.xml.soap.SOAPHeaderElement;
  39 import javax.xml.soap.SOAPMessage;
  40 import java.util.ArrayList;
  41 import java.util.Collections;
  42 import java.util.HashMap;
  43 import java.util.HashSet;
  44 import java.util.Iterator;
  45 import java.util.List;
  46 import java.util.Map;
  47 import java.util.Set;
  48 















  49 public class SAAJMessageHeaders implements MessageHeaders {
  50     SOAPMessage sm;
  51     Map<SOAPHeaderElement, Header> nonSAAJHeaders;
  52     Map<QName, Integer> notUnderstoodCount;
  53     SOAPVersion soapVersion;
  54     private Set<QName> understoodHeaders;
  55 
  56     public SAAJMessageHeaders(SOAPMessage sm, SOAPVersion version) {
  57         this.sm = sm;
  58         this.soapVersion = version;
  59         initHeaderUnderstanding();
  60     }
  61 
  62     /** Set the initial understood/not understood state of the headers in this
  63      * object
  64      */
  65     private void initHeaderUnderstanding() {
  66         SOAPHeader soapHeader = ensureSOAPHeader();
  67         if (soapHeader == null) {
  68             return;


 216         if (isNonSAAJHeader(header)) {
 217             //TODO assumes only one header with that name?
 218             addNonSAAJHeader(find(header.getNamespaceURI(), header.getLocalPart()),
 219                     header);
 220         }
 221 
 222         return true;
 223     }
 224 
 225     @Override
 226     public Header remove(QName name) {
 227         return remove(name.getNamespaceURI(), name.getLocalPart());
 228     }
 229 
 230     @Override
 231     public Header remove(String nsUri, String localName) {
 232         SOAPHeader soapHeader = ensureSOAPHeader();
 233         if (soapHeader == null) {
 234             return null;
 235         }

 236         SOAPHeaderElement headerElem = find(nsUri, localName);
 237         if (headerElem == null) {
 238             return null;
 239         }
 240         headerElem = (SOAPHeaderElement) soapHeader.removeChild(headerElem);
 241 
 242         //it might have been a nonSAAJHeader - remove from that map
 243         removeNonSAAJHeader(headerElem);
 244 
 245         //remove it from understoodHeaders and notUnderstoodHeaders if present
 246         QName hdrName = (nsUri == null) ? new QName(localName) : new QName(nsUri, localName);
 247         if (understoodHeaders != null) {
 248             understoodHeaders.remove(hdrName);
 249         }
 250         removeNotUnderstood(hdrName);
 251 
 252         return new SAAJHeader(headerElem);
 253     }
 254 
 255     private void removeNotUnderstood(QName hdrName) {
 256         if (notUnderstoodCount == null) {
 257             return;
 258         }
 259         Integer notUnderstood = notUnderstoodCount.get(hdrName);
 260         if (notUnderstood != null) {


< prev index next >