View Javadoc

1   /*
2    * Copyright  1999-2004 The Apache Software Foundation.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  
18  package org.apache.sandesha.ws.rm;
19  
20  import org.apache.axis.message.MessageElement;
21  import org.apache.sandesha.Constants;
22  
23  import javax.xml.soap.SOAPException;
24  import java.util.Iterator;
25  
26  /***
27   * class SequenceOffer
28   *
29   * @author Jaliya Ekanayaka
30   * @author Chamikara Jayalath
31   */
32  
33  public class SequenceOffer extends MessageElement implements IRmElement {
34  
35      private MessageElement offerElement;
36  
37      private Identifier identifier;
38  
39      public SequenceOffer() {
40          offerElement = new MessageElement(Constants.WSRM.SEQUENCE_OFFER, Constants.WSRM.NS_PREFIX_RM, Constants.WSRM.NS_URI_RM);
41      }
42  
43      public void addChildElement(MessageElement element) throws SOAPException {
44          offerElement.addChildElement(element);
45      }
46  
47      public MessageElement getSoapElement() throws SOAPException {
48          offerElement.addChildElement(identifier.getSoapElement());
49          return offerElement;
50      }
51  
52      public SequenceOffer fromSOAPEnvelope(MessageElement element) {
53  
54          Iterator iterator = element.getChildElements();
55          MessageElement childElement;
56  
57          while (iterator.hasNext()) {
58  
59              childElement = (MessageElement) iterator.next();
60  
61              if (childElement.getName().equals(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.IDENTIFIER)) {
62                  identifier = new Identifier();
63                  identifier.fromSOAPEnvelope(childElement);
64              }
65  
66              if (childElement.getName().equals(Constants.WSRM.IDENTIFIER)) {
67                  identifier = new Identifier();
68                  identifier.fromSOAPEnvelope(childElement);
69              }
70          }
71          return this;
72      }
73  
74      public MessageElement toSOAPEnvelope(MessageElement element) throws SOAPException {
75  
76          if (identifier != null)
77              identifier.toSOAPEnvelope(offerElement);
78  
79          element.addChildElement(offerElement);
80          return element;
81      }
82  
83  
84      public Identifier getIdentifier() {
85          return identifier;
86      }
87  
88  
89      public void setIdentifier(Identifier identifier) {
90          this.identifier = identifier;
91      }
92  }