001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.saaj;
020:
021: import org.apache.axiom.om.impl.dom.ElementImpl;
022: import org.apache.axiom.soap.SOAPHeaderBlock;
023: import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
024:
025: import javax.xml.soap.SOAPElement;
026: import javax.xml.soap.SOAPException;
027: import javax.xml.soap.SOAPHeader;
028: import javax.xml.soap.SOAPHeaderElement;
029:
030: public class SOAPHeaderElementImpl extends SOAPElementImpl implements
031: SOAPHeaderElement {
032:
033: private SOAPHeaderBlock headerElem;
034:
035: /** @param element */
036: public SOAPHeaderElementImpl(SOAPHeaderBlock element) {
037: super ((ElementImpl) element);
038: this .headerElem = element;
039: }
040:
041: /**
042: * Sets the actor associated with this <CODE> SOAPHeaderElement</CODE> object to the specified
043: * actor. The default value of an actor is: <CODE> SOAPConstants.URI_SOAP_ACTOR_NEXT</CODE>
044: *
045: * @param actorURI a <CODE>String</CODE> giving the URI of the actor to set
046: * @throws IllegalArgumentException
047: * if there is a problem in setting the actor.
048: * @see #getActor() getActor()
049: */
050: public void setActor(String actorURI) {
051: this .headerElem.setRole(actorURI);
052: }
053:
054: /**
055: * Returns the uri of the actor associated with this <CODE> SOAPHeaderElement</CODE> object.
056: *
057: * @return a <CODE>String</CODE> giving the URI of the actor
058: * @see #setActor(String) setActor(java.lang.String)
059: */
060: public String getActor() {
061: return this .headerElem.getRole();
062: }
063:
064: /**
065: * Sets the mustUnderstand attribute for this <CODE> SOAPHeaderElement</CODE> object to be on or
066: * off.
067: * <p/>
068: * <P>If the mustUnderstand attribute is on, the actor who receives the
069: * <CODE>SOAPHeaderElement</CODE> must process it correctly. This ensures, for example, that if
070: * the <CODE> SOAPHeaderElement</CODE> object modifies the message, that the message is being
071: * modified correctly.</P>
072: *
073: * @param mustUnderstand <CODE>true</CODE> to set the mustUnderstand attribute on;
074: * <CODE>false</CODE> to turn if off
075: * @throws IllegalArgumentException
076: * if there is a problem in setting the actor.
077: * @see #getMustUnderstand() getMustUnderstand()
078: */
079: public void setMustUnderstand(boolean mustUnderstand) {
080: this .headerElem.setMustUnderstand(mustUnderstand);
081: }
082:
083: /**
084: * Returns whether the mustUnderstand attribute for this <CODE>SOAPHeaderElement</CODE> object
085: * is turned on.
086: *
087: * @return <CODE>true</CODE> if the mustUnderstand attribute of this
088: * <CODE>SOAPHeaderElement</CODE> object is turned on; <CODE>false</CODE> otherwise
089: */
090: public boolean getMustUnderstand() {
091: return this .headerElem.getMustUnderstand();
092: }
093:
094: /**
095: * Sets the Role associated with this SOAPHeaderElement object to the specified Role.
096: *
097: * @param uri - the URI of the Role
098: * @throws SOAPException - if there is an error in setting the role java.lang.UnsupportedOperationException
099: * - if this message does not support the SOAP 1.2 concept of Fault Role.
100: */
101: public void setRole(String uri) throws SOAPException {
102: if (this .element.getOMFactory() instanceof SOAP11Factory) {
103: throw new UnsupportedOperationException();
104: } else {
105: this .headerElem.setRole(uri);
106: }
107: }
108:
109: public String getRole() {
110: if (this .element.getOMFactory() instanceof SOAP11Factory) {
111: throw new UnsupportedOperationException();
112: } else {
113: return this .headerElem.getRole();
114: }
115: }
116:
117: /**
118: * Sets the relay attribute for this SOAPHeaderElement to be either true or false. The SOAP
119: * relay attribute is set to true to indicate that the SOAP header block must be relayed by any
120: * node that is targeted by the header block but not actually process it. This attribute is
121: * ignored on header blocks whose mustUnderstand attribute is set to true or that are targeted
122: * at the ultimate reciever (which is the default). The default value of this attribute is
123: * false.
124: *
125: * @param relay - the new value of the relay attribute
126: * @throws SOAPException - if there is a problem in setting the relay attribute.
127: * java.lang.UnsupportedOperationException - if this message does not
128: * support the SOAP 1.2 concept of Relay attribute.
129: */
130: public void setRelay(boolean flag) throws SOAPException {
131: if (this .element.getOMFactory() instanceof SOAP11Factory) {
132: throw new UnsupportedOperationException();
133: } else {
134: this .headerElem.setRelay(flag);
135: }
136: }
137:
138: public boolean getRelay() {
139: if (this .element.getOMFactory() instanceof SOAP11Factory) {
140: throw new UnsupportedOperationException();
141: } else {
142: return this .headerElem.getRelay();
143: }
144: }
145:
146: public void setParentElement(SOAPElement parent)
147: throws SOAPException {
148: if (!(parent instanceof SOAPHeader)) {
149: throw new IllegalArgumentException(
150: "Parent is not a SOAPHeader");
151: }
152: super.setParentElement(parent);
153: }
154: }
|