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_1; |
duke@1 | 36 | |
duke@1 | 37 | import java.util.Iterator; |
duke@1 | 38 | import java.util.Locale; |
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.SOAPElement; |
duke@1 | 44 | import javax.xml.soap.SOAPFaultElement; |
duke@1 | 45 | import javax.xml.soap.SOAPException; |
duke@1 | 46 | import javax.xml.soap.SOAPConstants; |
duke@1 | 47 | import javax.xml.soap.Name; |
duke@1 | 48 | import javax.xml.soap.Name; |
duke@1 | 49 | |
duke@1 | 50 | import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument; |
duke@1 | 51 | import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl; |
duke@1 | 52 | import com.sun.xml.internal.messaging.saaj.soap.impl.*; |
duke@1 | 53 | import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl; |
duke@1 | 54 | import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants; |
duke@1 | 55 | import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; |
duke@1 | 56 | |
duke@1 | 57 | |
duke@1 | 58 | public class Fault1_1Impl extends FaultImpl { |
duke@1 | 59 | |
tbell@50 | 60 | protected static final Logger log = |
duke@1 | 61 | Logger.getLogger( |
duke@1 | 62 | LogDomainConstants.SOAP_VER1_1_DOMAIN, |
duke@1 | 63 | "com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings"); |
duke@1 | 64 | |
duke@1 | 65 | public Fault1_1Impl(SOAPDocumentImpl ownerDocument, String prefix) { |
duke@1 | 66 | super(ownerDocument, NameImpl.createFault1_1Name(prefix)); |
duke@1 | 67 | } |
duke@1 | 68 | |
duke@1 | 69 | protected NameImpl getDetailName() { |
duke@1 | 70 | return NameImpl.createDetail1_1Name(); |
duke@1 | 71 | } |
duke@1 | 72 | |
duke@1 | 73 | protected NameImpl getFaultCodeName() { |
duke@1 | 74 | return NameImpl.createFromUnqualifiedName("faultcode"); |
duke@1 | 75 | } |
duke@1 | 76 | |
duke@1 | 77 | protected NameImpl getFaultStringName() { |
duke@1 | 78 | return NameImpl.createFromUnqualifiedName("faultstring"); |
duke@1 | 79 | } |
duke@1 | 80 | |
duke@1 | 81 | protected NameImpl getFaultActorName() { |
duke@1 | 82 | return NameImpl.createFromUnqualifiedName("faultactor"); |
duke@1 | 83 | } |
duke@1 | 84 | |
duke@1 | 85 | protected DetailImpl createDetail() { |
duke@1 | 86 | return new Detail1_1Impl( |
duke@1 | 87 | ((SOAPDocument) getOwnerDocument()).getDocument()); |
duke@1 | 88 | } |
duke@1 | 89 | |
duke@1 | 90 | protected FaultElementImpl createSOAPFaultElement(String localName) { |
duke@1 | 91 | return new FaultElement1_1Impl( |
duke@1 | 92 | ((SOAPDocument) getOwnerDocument()).getDocument(), |
duke@1 | 93 | localName); |
duke@1 | 94 | } |
duke@1 | 95 | |
duke@1 | 96 | protected void checkIfStandardFaultCode(String faultCode, String uri) |
duke@1 | 97 | throws SOAPException { |
duke@1 | 98 | // SOAP 1.1 doesn't seem to mandate using faultcode from a particular |
duke@1 | 99 | // set of values. |
duke@1 | 100 | // Also need to be backward compatible. |
duke@1 | 101 | } |
duke@1 | 102 | |
duke@1 | 103 | protected void finallySetFaultCode(String faultcode) throws SOAPException { |
duke@1 | 104 | this.faultCodeElement.addTextNode(faultcode); |
duke@1 | 105 | } |
duke@1 | 106 | |
duke@1 | 107 | public String getFaultCode() { |
duke@1 | 108 | if (this.faultCodeElement == null) |
duke@1 | 109 | findFaultCodeElement(); |
duke@1 | 110 | return this.faultCodeElement.getValue(); |
duke@1 | 111 | } |
duke@1 | 112 | |
duke@1 | 113 | public Name getFaultCodeAsName() { |
duke@1 | 114 | |
duke@1 | 115 | String faultcodeString = getFaultCode(); |
duke@1 | 116 | if (faultcodeString == null) { |
duke@1 | 117 | return null; |
duke@1 | 118 | } |
duke@1 | 119 | int prefixIndex = faultcodeString.indexOf(':'); |
duke@1 | 120 | if (prefixIndex == -1) { |
duke@1 | 121 | // Not a valid SOAP message, but we return the unqualified name |
duke@1 | 122 | // anyway since some apps do not strictly conform to SOAP |
duke@1 | 123 | // specs. A message that does not contain a <faultcode> |
duke@1 | 124 | // element itself is also not valid in which case we return |
duke@1 | 125 | // null instead of throwing an exception so this is consistent. |
duke@1 | 126 | return NameImpl.createFromUnqualifiedName(faultcodeString); |
duke@1 | 127 | } |
duke@1 | 128 | |
duke@1 | 129 | // Get the prefix and map it to a namespace name (AKA namespace URI) |
duke@1 | 130 | String prefix = faultcodeString.substring(0, prefixIndex); |
duke@1 | 131 | if (this.faultCodeElement == null) |
duke@1 | 132 | findFaultCodeElement(); |
duke@1 | 133 | String nsName = this.faultCodeElement.getNamespaceURI(prefix); |
duke@1 | 134 | return NameImpl.createFromQualifiedName(faultcodeString, nsName); |
duke@1 | 135 | } |
duke@1 | 136 | |
duke@1 | 137 | public QName getFaultCodeAsQName() { |
duke@1 | 138 | String faultcodeString = getFaultCode(); |
duke@1 | 139 | if (faultcodeString == null) { |
duke@1 | 140 | return null; |
duke@1 | 141 | } |
duke@1 | 142 | if (this.faultCodeElement == null) |
duke@1 | 143 | findFaultCodeElement(); |
duke@1 | 144 | return convertCodeToQName(faultcodeString, this.faultCodeElement); |
duke@1 | 145 | } |
duke@1 | 146 | |
duke@1 | 147 | public void setFaultString(String faultString) throws SOAPException { |
duke@1 | 148 | |
duke@1 | 149 | if (this.faultStringElement == null) |
duke@1 | 150 | findFaultStringElement(); |
duke@1 | 151 | |
duke@1 | 152 | if (this.faultStringElement == null) |
duke@1 | 153 | this.faultStringElement = addSOAPFaultElement("faultstring"); |
duke@1 | 154 | else { |
duke@1 | 155 | this.faultStringElement.removeContents(); |
duke@1 | 156 | //this.faultStringElement.removeAttributeNS("http://www.w3.org/XML/1998/namespace", "lang"); |
duke@1 | 157 | this.faultStringElement.removeAttribute("xml:lang"); |
duke@1 | 158 | } |
duke@1 | 159 | |
duke@1 | 160 | this.faultStringElement.addTextNode(faultString); |
duke@1 | 161 | } |
duke@1 | 162 | |
duke@1 | 163 | public String getFaultString() { |
duke@1 | 164 | if (this.faultStringElement == null) |
duke@1 | 165 | findFaultStringElement(); |
duke@1 | 166 | return this.faultStringElement.getValue(); |
duke@1 | 167 | |
duke@1 | 168 | } |
duke@1 | 169 | |
duke@1 | 170 | public Locale getFaultStringLocale() { |
duke@1 | 171 | if (this.faultStringElement == null) |
duke@1 | 172 | findFaultStringElement(); |
duke@1 | 173 | if (this.faultStringElement != null) { |
duke@1 | 174 | String xmlLangAttr = |
duke@1 | 175 | this.faultStringElement.getAttributeValue( |
duke@1 | 176 | NameImpl.createFromUnqualifiedName("xml:lang")); |
duke@1 | 177 | if (xmlLangAttr != null) |
duke@1 | 178 | return xmlLangToLocale(xmlLangAttr); |
duke@1 | 179 | } |
duke@1 | 180 | return null; |
duke@1 | 181 | } |
duke@1 | 182 | |
duke@1 | 183 | public void setFaultString(String faultString, Locale locale) |
duke@1 | 184 | throws SOAPException { |
duke@1 | 185 | setFaultString(faultString); |
duke@1 | 186 | this.faultStringElement.addAttribute( |
duke@1 | 187 | NameImpl.createFromTagName("xml:lang"), |
duke@1 | 188 | localeToXmlLang(locale)); |
duke@1 | 189 | } |
duke@1 | 190 | |
duke@1 | 191 | protected boolean isStandardFaultElement(String localName) { |
duke@1 | 192 | if (localName.equalsIgnoreCase("detail") || |
duke@1 | 193 | localName.equalsIgnoreCase("faultcode") || |
duke@1 | 194 | localName.equalsIgnoreCase("faultstring") || |
duke@1 | 195 | localName.equalsIgnoreCase("faultactor")) { |
duke@1 | 196 | return true; |
duke@1 | 197 | } |
duke@1 | 198 | return false; |
duke@1 | 199 | } |
duke@1 | 200 | |
duke@1 | 201 | public void appendFaultSubcode(QName subcode) { |
duke@1 | 202 | log.log( |
duke@1 | 203 | Level.SEVERE, |
duke@1 | 204 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 205 | "appendFaultSubcode"); |
duke@1 | 206 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 207 | } |
duke@1 | 208 | |
duke@1 | 209 | public void removeAllFaultSubcodes() { |
duke@1 | 210 | log.log( |
duke@1 | 211 | Level.SEVERE, |
duke@1 | 212 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 213 | "removeAllFaultSubcodes"); |
duke@1 | 214 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 215 | } |
duke@1 | 216 | |
duke@1 | 217 | public Iterator getFaultSubcodes() { |
duke@1 | 218 | log.log( |
duke@1 | 219 | Level.SEVERE, |
duke@1 | 220 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 221 | "getFaultSubcodes"); |
duke@1 | 222 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 223 | } |
duke@1 | 224 | |
duke@1 | 225 | public String getFaultReasonText(Locale locale) { |
duke@1 | 226 | log.log( |
duke@1 | 227 | Level.SEVERE, |
duke@1 | 228 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 229 | "getFaultReasonText"); |
duke@1 | 230 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 231 | } |
duke@1 | 232 | |
duke@1 | 233 | public Iterator getFaultReasonTexts() { |
duke@1 | 234 | log.log( |
duke@1 | 235 | Level.SEVERE, |
duke@1 | 236 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 237 | "getFaultReasonTexts"); |
duke@1 | 238 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 239 | } |
duke@1 | 240 | |
duke@1 | 241 | public Iterator getFaultReasonLocales() { |
duke@1 | 242 | log.log( |
duke@1 | 243 | Level.SEVERE, |
duke@1 | 244 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 245 | "getFaultReasonLocales"); |
duke@1 | 246 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 247 | } |
duke@1 | 248 | |
duke@1 | 249 | public void addFaultReasonText(String text, java.util.Locale locale) |
duke@1 | 250 | throws SOAPException { |
duke@1 | 251 | log.log( |
duke@1 | 252 | Level.SEVERE, |
duke@1 | 253 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 254 | "addFaultReasonText"); |
duke@1 | 255 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 256 | } |
duke@1 | 257 | |
duke@1 | 258 | public String getFaultRole() { |
duke@1 | 259 | log.log( |
duke@1 | 260 | Level.SEVERE, |
duke@1 | 261 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 262 | "getFaultRole"); |
duke@1 | 263 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 264 | } |
duke@1 | 265 | |
duke@1 | 266 | public void setFaultRole(String uri) { |
duke@1 | 267 | log.log( |
duke@1 | 268 | Level.SEVERE, |
duke@1 | 269 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 270 | "setFaultRole"); |
duke@1 | 271 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 272 | } |
duke@1 | 273 | |
duke@1 | 274 | public String getFaultNode() { |
duke@1 | 275 | log.log( |
duke@1 | 276 | Level.SEVERE, |
duke@1 | 277 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 278 | "getFaultNode"); |
duke@1 | 279 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 280 | } |
duke@1 | 281 | |
duke@1 | 282 | public void setFaultNode(String uri) { |
duke@1 | 283 | log.log( |
duke@1 | 284 | Level.SEVERE, |
duke@1 | 285 | "SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1", |
duke@1 | 286 | "setFaultNode"); |
duke@1 | 287 | throw new UnsupportedOperationException("Not supported in SOAP 1.1"); |
duke@1 | 288 | } |
duke@1 | 289 | |
duke@1 | 290 | protected QName getDefaultFaultCode() { |
duke@1 | 291 | return new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Server"); |
duke@1 | 292 | } |
duke@1 | 293 | |
duke@1 | 294 | public SOAPElement addChildElement(SOAPElement element) |
duke@1 | 295 | throws SOAPException { |
duke@1 | 296 | String localName = element.getLocalName(); |
duke@1 | 297 | if ("Detail".equalsIgnoreCase(localName)) { |
duke@1 | 298 | if (hasDetail()) { |
duke@1 | 299 | log.severe("SAAJ0305.ver1_2.detail.exists.error"); |
duke@1 | 300 | throw new SOAPExceptionImpl("Cannot add Detail, Detail already exists"); |
duke@1 | 301 | } |
duke@1 | 302 | } |
duke@1 | 303 | return super.addChildElement(element); |
duke@1 | 304 | } |
tbell@45 | 305 | |
tbell@45 | 306 | protected FaultElementImpl createSOAPFaultElement(QName qname) { |
tbell@45 | 307 | return new FaultElement1_1Impl( |
tbell@45 | 308 | ((SOAPDocument) getOwnerDocument()).getDocument(), |
tbell@45 | 309 | qname); |
tbell@45 | 310 | } |
tbell@45 | 311 | |
tbell@45 | 312 | protected FaultElementImpl createSOAPFaultElement(Name qname) { |
tbell@45 | 313 | return new FaultElement1_1Impl( |
tbell@45 | 314 | ((SOAPDocument) getOwnerDocument()).getDocument(), |
tbell@45 | 315 | (NameImpl)qname); |
tbell@45 | 316 | } |
tbell@45 | 317 | |
duke@1 | 318 | } |