001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Emil Ong
028: */
029:
030: package com.caucho.xml.saaj;
031:
032: import javax.xml.XMLConstants;
033: import javax.xml.namespace.*;
034: import javax.xml.soap.*;
035:
036: import com.caucho.xml.QNode;
037:
038: public class SOAP11HeaderElementImpl extends SOAPElementImpl implements
039: SOAPHeaderElement {
040: static final NameImpl SOAP_1_1_UPGRADE_NAME = new NameImpl(
041: SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Upgrade",
042: SOAPConstants.SOAP_ENV_PREFIX);
043:
044: static final NameImpl SOAP_1_1_MUST_UNDERSTAND_NAME = new NameImpl(
045: SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "mustUnderstand",
046: SOAPConstants.SOAP_ENV_PREFIX);
047:
048: static final NameImpl ACTOR_NAME = new NameImpl(
049: SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "actor",
050: SOAPConstants.SOAP_ENV_PREFIX);
051:
052: static final NameImpl NOT_UNDERSTOOD_NAME = new NameImpl(
053: SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "NotUnderstood");
054:
055: static final NameImpl UPGRADE_NAME = new NameImpl(
056: SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Upgrade");
057:
058: protected Name _mustUnderstandName = SOAP_1_1_MUST_UNDERSTAND_NAME;
059:
060: SOAP11HeaderElementImpl(SOAPFactory factory, NameImpl name)
061: throws SOAPException {
062: super (factory, name);
063:
064: if (name.getURI() == null || "".equals(name.getURI())
065: || name.getPrefix() == null
066: || "".equals(name.getPrefix()))
067: throw new SOAPException(
068: "Header elements must have qualified names");
069: }
070:
071: SOAP11HeaderElementImpl(SOAPFactory factory, SOAPElement element)
072: throws SOAPException {
073: this (factory, NameImpl.fromQName(element.getElementQName()));
074:
075: copySOAPElement(element);
076: }
077:
078: public String getActor() {
079: return getAttributeValue((Name) ACTOR_NAME);
080: }
081:
082: public void setActor(String actorURI) {
083: try {
084: addAttribute((Name) ACTOR_NAME, actorURI);
085: } catch (SOAPException e) {
086: // as specified by SAAJ
087: throw new IllegalArgumentException(e);
088: }
089: }
090:
091: public boolean getMustUnderstand() {
092: String value = getAttributeValue(_mustUnderstandName);
093:
094: return "true".equalsIgnoreCase(value);
095: }
096:
097: public void setMustUnderstand(boolean mustUnderstand) {
098: try {
099: addAttribute(_mustUnderstandName, Boolean
100: .toString(mustUnderstand));
101: } catch (SOAPException e) {
102: // as specified by SAAJ
103: throw new IllegalArgumentException(e);
104: }
105: }
106:
107: public boolean getRelay() {
108: throw new UnsupportedOperationException(
109: "Relay unsupported by SOAP 1.1");
110: }
111:
112: public void setRelay(boolean relay) throws SOAPException {
113: throw new UnsupportedOperationException(
114: "Relay unsupported by SOAP 1.1");
115: }
116:
117: public String getRole() {
118: throw new UnsupportedOperationException(
119: "Relay unsupported by SOAP 1.1");
120: }
121:
122: public void setRole(String uri) throws SOAPException {
123: throw new UnsupportedOperationException(
124: "Relay unsupported by SOAP 1.1");
125: }
126:
127: public void setParentElement(SOAPElement parent)
128: throws SOAPException {
129: if (parent == null)
130: throw new IllegalArgumentException();
131:
132: if (parent instanceof SOAP11HeaderImpl)
133: _parent = (SOAP11HeaderImpl) parent;
134: else if (parent instanceof SOAP11HeaderElementImpl)
135: _parent = (SOAP11HeaderElementImpl) parent;
136: else
137: throw new SOAPException("Parent is a " + parent.getClass()
138: + ", not a SOAPHeader or SOAPHeaderElement");
139: }
140: }
|