Mon, 04 May 2009 21:10:41 -0700
6658158: Mutable statics in SAAJ (findbugs)
6658163: txw2.DatatypeWriter.BUILDIN is a mutable static (findbugs)
Reviewed-by: darcy
duke@1 | 1 | /* |
tbell@45 | 2 | * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. Sun designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
duke@1 | 9 | * by Sun in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
duke@1 | 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | * have any questions. |
duke@1 | 24 | */ |
tbell@45 | 25 | /* |
tbell@50 | 26 | * |
tbell@45 | 27 | */ |
tbell@45 | 28 | |
tbell@45 | 29 | |
duke@1 | 30 | |
duke@1 | 31 | /** |
duke@1 | 32 | * |
duke@1 | 33 | * @author SAAJ RI Development Team |
duke@1 | 34 | */ |
duke@1 | 35 | package com.sun.xml.internal.messaging.saaj.soap.ver1_2; |
duke@1 | 36 | |
duke@1 | 37 | import java.util.List; |
duke@1 | 38 | import java.util.Iterator; |
duke@1 | 39 | import java.util.logging.Logger; |
duke@1 | 40 | import java.util.logging.Level; |
duke@1 | 41 | |
duke@1 | 42 | import javax.xml.namespace.QName; |
duke@1 | 43 | import javax.xml.soap.*; |
duke@1 | 44 | |
duke@1 | 45 | import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; |
duke@1 | 46 | import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument; |
duke@1 | 47 | import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl; |
duke@1 | 48 | import com.sun.xml.internal.messaging.saaj.soap.impl.HeaderElementImpl; |
duke@1 | 49 | import com.sun.xml.internal.messaging.saaj.soap.impl.HeaderImpl; |
duke@1 | 50 | import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl; |
duke@1 | 51 | import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants; |
duke@1 | 52 | |
duke@1 | 53 | |
duke@1 | 54 | public class Header1_2Impl extends HeaderImpl { |
duke@1 | 55 | |
tbell@50 | 56 | protected static final Logger log = |
duke@1 | 57 | Logger.getLogger( |
duke@1 | 58 | LogDomainConstants.SOAP_VER1_2_DOMAIN, |
duke@1 | 59 | "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings"); |
duke@1 | 60 | |
duke@1 | 61 | public Header1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) { |
duke@1 | 62 | super(ownerDocument, NameImpl.createHeader1_2Name(prefix)); |
duke@1 | 63 | } |
duke@1 | 64 | |
duke@1 | 65 | protected NameImpl getNotUnderstoodName() { |
duke@1 | 66 | return NameImpl.createNotUnderstood1_2Name(null); |
duke@1 | 67 | } |
duke@1 | 68 | |
duke@1 | 69 | protected NameImpl getUpgradeName() { |
duke@1 | 70 | return NameImpl.createUpgrade1_2Name(null); |
duke@1 | 71 | } |
duke@1 | 72 | |
duke@1 | 73 | protected NameImpl getSupportedEnvelopeName() { |
duke@1 | 74 | return NameImpl.createSupportedEnvelope1_2Name(null); |
duke@1 | 75 | } |
duke@1 | 76 | |
duke@1 | 77 | public SOAPHeaderElement addNotUnderstoodHeaderElement(final QName sourceName) |
duke@1 | 78 | throws SOAPException { |
duke@1 | 79 | |
duke@1 | 80 | if (sourceName == null) { |
duke@1 | 81 | log.severe("SAAJ0410.ver1_2.no.null.to.addNotUnderstoodHeader"); |
duke@1 | 82 | throw new SOAPException("Cannot pass NULL to addNotUnderstoodHeaderElement"); |
duke@1 | 83 | } |
duke@1 | 84 | if ("".equals(sourceName.getNamespaceURI())) { |
duke@1 | 85 | log.severe("SAAJ0417.ver1_2.qname.not.ns.qualified"); |
duke@1 | 86 | throw new SOAPException("The qname passed to addNotUnderstoodHeaderElement must be namespace-qualified"); |
duke@1 | 87 | } |
duke@1 | 88 | String prefix = sourceName.getPrefix(); |
duke@1 | 89 | if ("".equals(prefix)) { |
duke@1 | 90 | prefix = "ns1"; |
duke@1 | 91 | } |
duke@1 | 92 | Name notunderstoodName = getNotUnderstoodName(); |
duke@1 | 93 | SOAPHeaderElement notunderstoodHeaderElement = |
duke@1 | 94 | (SOAPHeaderElement) addChildElement(notunderstoodName); |
duke@1 | 95 | notunderstoodHeaderElement.addAttribute( |
duke@1 | 96 | NameImpl.createFromUnqualifiedName("qname"), |
duke@1 | 97 | getQualifiedName( |
duke@1 | 98 | new QName( |
duke@1 | 99 | sourceName.getNamespaceURI(), |
duke@1 | 100 | sourceName.getLocalPart(), |
duke@1 | 101 | prefix))); |
duke@1 | 102 | notunderstoodHeaderElement.addNamespaceDeclaration( |
duke@1 | 103 | prefix, |
duke@1 | 104 | sourceName.getNamespaceURI()); |
duke@1 | 105 | return notunderstoodHeaderElement; |
duke@1 | 106 | } |
duke@1 | 107 | |
duke@1 | 108 | public SOAPElement addTextNode(String text) throws SOAPException { |
duke@1 | 109 | log.log( |
duke@1 | 110 | Level.SEVERE, |
duke@1 | 111 | "SAAJ0416.ver1_2.adding.text.not.legal", |
duke@1 | 112 | getElementQName()); |
duke@1 | 113 | throw new SOAPExceptionImpl("Adding text to SOAP 1.2 Header is not legal"); |
duke@1 | 114 | } |
duke@1 | 115 | |
duke@1 | 116 | protected SOAPHeaderElement createHeaderElement(Name name) |
duke@1 | 117 | throws SOAPException { |
duke@1 | 118 | String uri = name.getURI(); |
duke@1 | 119 | if (uri == null || uri.equals("")) { |
duke@1 | 120 | log.severe("SAAJ0413.ver1_2.header.elems.must.be.ns.qualified"); |
duke@1 | 121 | throw new SOAPExceptionImpl("SOAP 1.2 header elements must be namespace qualified"); |
duke@1 | 122 | } |
duke@1 | 123 | return new HeaderElement1_2Impl( |
duke@1 | 124 | ((SOAPDocument) getOwnerDocument()).getDocument(), |
duke@1 | 125 | name); |
duke@1 | 126 | } |
duke@1 | 127 | |
duke@1 | 128 | protected SOAPHeaderElement createHeaderElement(QName name) |
duke@1 | 129 | throws SOAPException { |
duke@1 | 130 | String uri = name.getNamespaceURI(); |
duke@1 | 131 | if (uri == null || uri.equals("")) { |
duke@1 | 132 | log.severe("SAAJ0413.ver1_2.header.elems.must.be.ns.qualified"); |
duke@1 | 133 | throw new SOAPExceptionImpl("SOAP 1.2 header elements must be namespace qualified"); |
duke@1 | 134 | } |
duke@1 | 135 | return new HeaderElement1_2Impl( |
duke@1 | 136 | ((SOAPDocument) getOwnerDocument()).getDocument(), |
duke@1 | 137 | name); |
duke@1 | 138 | } |
duke@1 | 139 | |
duke@1 | 140 | public void setEncodingStyle(String encodingStyle) throws SOAPException { |
duke@1 | 141 | log.severe("SAAJ0409.ver1_2.no.encodingstyle.in.header"); |
duke@1 | 142 | throw new SOAPExceptionImpl("encodingStyle attribute cannot appear on Header"); |
duke@1 | 143 | } |
duke@1 | 144 | |
duke@1 | 145 | public SOAPElement addAttribute(Name name, String value) |
duke@1 | 146 | throws SOAPException { |
duke@1 | 147 | if (name.getLocalName().equals("encodingStyle") |
duke@1 | 148 | && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) { |
duke@1 | 149 | |
duke@1 | 150 | setEncodingStyle(value); |
duke@1 | 151 | } |
duke@1 | 152 | return super.addAttribute(name, value); |
duke@1 | 153 | } |
duke@1 | 154 | |
duke@1 | 155 | public SOAPElement addAttribute(QName name, String value) |
duke@1 | 156 | throws SOAPException { |
duke@1 | 157 | if (name.getLocalPart().equals("encodingStyle") |
duke@1 | 158 | && name.getNamespaceURI().equals(NameImpl.SOAP12_NAMESPACE)) { |
duke@1 | 159 | |
duke@1 | 160 | setEncodingStyle(value); |
duke@1 | 161 | } |
duke@1 | 162 | return super.addAttribute(name, value); |
duke@1 | 163 | } |
duke@1 | 164 | } |