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
1 /*
2 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25 /*
26 *
27 */
31 /**
32 *
33 * @author SAAJ RI Development Team
34 */
35 package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
37 import java.util.List;
38 import java.util.Iterator;
39 import java.util.logging.Logger;
40 import java.util.logging.Level;
42 import javax.xml.namespace.QName;
43 import javax.xml.soap.*;
45 import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
46 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
47 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
48 import com.sun.xml.internal.messaging.saaj.soap.impl.HeaderElementImpl;
49 import com.sun.xml.internal.messaging.saaj.soap.impl.HeaderImpl;
50 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
51 import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
54 public class Header1_2Impl extends HeaderImpl {
56 protected static final Logger log =
57 Logger.getLogger(
58 LogDomainConstants.SOAP_VER1_2_DOMAIN,
59 "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
61 public Header1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) {
62 super(ownerDocument, NameImpl.createHeader1_2Name(prefix));
63 }
65 protected NameImpl getNotUnderstoodName() {
66 return NameImpl.createNotUnderstood1_2Name(null);
67 }
69 protected NameImpl getUpgradeName() {
70 return NameImpl.createUpgrade1_2Name(null);
71 }
73 protected NameImpl getSupportedEnvelopeName() {
74 return NameImpl.createSupportedEnvelope1_2Name(null);
75 }
77 public SOAPHeaderElement addNotUnderstoodHeaderElement(final QName sourceName)
78 throws SOAPException {
80 if (sourceName == null) {
81 log.severe("SAAJ0410.ver1_2.no.null.to.addNotUnderstoodHeader");
82 throw new SOAPException("Cannot pass NULL to addNotUnderstoodHeaderElement");
83 }
84 if ("".equals(sourceName.getNamespaceURI())) {
85 log.severe("SAAJ0417.ver1_2.qname.not.ns.qualified");
86 throw new SOAPException("The qname passed to addNotUnderstoodHeaderElement must be namespace-qualified");
87 }
88 String prefix = sourceName.getPrefix();
89 if ("".equals(prefix)) {
90 prefix = "ns1";
91 }
92 Name notunderstoodName = getNotUnderstoodName();
93 SOAPHeaderElement notunderstoodHeaderElement =
94 (SOAPHeaderElement) addChildElement(notunderstoodName);
95 notunderstoodHeaderElement.addAttribute(
96 NameImpl.createFromUnqualifiedName("qname"),
97 getQualifiedName(
98 new QName(
99 sourceName.getNamespaceURI(),
100 sourceName.getLocalPart(),
101 prefix)));
102 notunderstoodHeaderElement.addNamespaceDeclaration(
103 prefix,
104 sourceName.getNamespaceURI());
105 return notunderstoodHeaderElement;
106 }
108 public SOAPElement addTextNode(String text) throws SOAPException {
109 log.log(
110 Level.SEVERE,
111 "SAAJ0416.ver1_2.adding.text.not.legal",
112 getElementQName());
113 throw new SOAPExceptionImpl("Adding text to SOAP 1.2 Header is not legal");
114 }
116 protected SOAPHeaderElement createHeaderElement(Name name)
117 throws SOAPException {
118 String uri = name.getURI();
119 if (uri == null || uri.equals("")) {
120 log.severe("SAAJ0413.ver1_2.header.elems.must.be.ns.qualified");
121 throw new SOAPExceptionImpl("SOAP 1.2 header elements must be namespace qualified");
122 }
123 return new HeaderElement1_2Impl(
124 ((SOAPDocument) getOwnerDocument()).getDocument(),
125 name);
126 }
128 protected SOAPHeaderElement createHeaderElement(QName name)
129 throws SOAPException {
130 String uri = name.getNamespaceURI();
131 if (uri == null || uri.equals("")) {
132 log.severe("SAAJ0413.ver1_2.header.elems.must.be.ns.qualified");
133 throw new SOAPExceptionImpl("SOAP 1.2 header elements must be namespace qualified");
134 }
135 return new HeaderElement1_2Impl(
136 ((SOAPDocument) getOwnerDocument()).getDocument(),
137 name);
138 }
140 public void setEncodingStyle(String encodingStyle) throws SOAPException {
141 log.severe("SAAJ0409.ver1_2.no.encodingstyle.in.header");
142 throw new SOAPExceptionImpl("encodingStyle attribute cannot appear on Header");
143 }
145 public SOAPElement addAttribute(Name name, String value)
146 throws SOAPException {
147 if (name.getLocalName().equals("encodingStyle")
148 && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {
150 setEncodingStyle(value);
151 }
152 return super.addAttribute(name, value);
153 }
155 public SOAPElement addAttribute(QName name, String value)
156 throws SOAPException {
157 if (name.getLocalPart().equals("encodingStyle")
158 && name.getNamespaceURI().equals(NameImpl.SOAP12_NAMESPACE)) {
160 setEncodingStyle(value);
161 }
162 return super.addAttribute(name, value);
163 }
164 }