1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.sandesha.ws.rm;
19
20 import org.apache.axis.message.MessageElement;
21 import org.apache.axis.message.SOAPBodyElement;
22 import org.apache.axis.message.SOAPEnvelope;
23 import org.apache.sandesha.Constants;
24
25 import javax.xml.soap.Name;
26 import javax.xml.soap.SOAPException;
27 import java.util.Iterator;
28
29 /***
30 * class CreateSequenceResponse
31 *
32 * @author Amila Navarathna
33 * @author Jaliya Ekanayaka
34 * @author Sudar Nimalan
35 */
36 public class CreateSequenceResponse implements IRmElement {
37
38 /***
39 * Field createSequenceResponse
40 */
41 private MessageElement createSequenceResponse;
42
43 /***
44 * Field identifier
45 */
46 private Identifier identifier;
47
48 private Accept accept;
49
50 /***
51 * Constructor CreateSequenceResponse
52 */
53 public CreateSequenceResponse() {
54 createSequenceResponse = new MessageElement();
55 createSequenceResponse.setName(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.CREATE_SEQUENCE_RESPONSE);
56 }
57
58 /***
59 * Method getSoapElement
60 *
61 * @return MessageElement
62 */
63 public MessageElement getSoapElement() {
64 return createSequenceResponse;
65 }
66
67 /***
68 * Method toSoapEnvelop
69 *
70 * @param envelope
71 * @return SOAPEnvelope
72 * @throws SOAPException
73 */
74 public SOAPEnvelope toSoapEnvelop(SOAPEnvelope envelope)
75 throws SOAPException {
76
77 SOAPEnvelope env = envelope;
78
79 if (env.getBody() == null) {
80 env.addBody();
81 }
82 Name name = env.createName("", Constants.WSRM.NS_PREFIX_RM, Constants.WSRM.NS_URI_RM);
83 SOAPBodyElement bodyElement = (SOAPBodyElement) env.getBody().addBodyElement(name);
84 bodyElement.setName(Constants.WSRM.CREATE_SEQUENCE_RESPONSE);
85 if (identifier != null) {
86 identifier.toSOAPEnvelope(bodyElement);
87 }
88 if (accept != null)
89 accept.toSOAPEnvelope(bodyElement);
90 return env;
91 }
92
93 /***
94 * Method fromSOAPEnveploe
95 *
96 * @param bodyElement
97 * @return CreateSequenceResponse
98 */
99 public CreateSequenceResponse fromSOAPEnveploe(SOAPBodyElement bodyElement) throws SOAPException {
100
101 Iterator iterator = bodyElement.getChildElements();
102 MessageElement childElement;
103
104 while (iterator.hasNext()) {
105 childElement = (MessageElement) iterator.next();
106
107 if (childElement.getName().equals(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.IDENTIFIER)) {
108 identifier = new Identifier();
109 identifier.fromSOAPEnvelope(childElement);
110 }
111
112 if (childElement.getName().equals(Constants.WSRM.IDENTIFIER)) {
113 identifier = new Identifier();
114 identifier.fromSOAPEnvelope(childElement);
115 }
116
117 if (childElement.getName().equals(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.ACCEPT)) {
118 accept = new Accept();
119 accept.fromSOAPEnvelope(childElement);
120 }
121
122 if (childElement.getName().equals(Constants.WSRM.ACCEPT)) {
123 accept = new Accept();
124 accept.fromSOAPEnvelope(childElement);
125 }
126 }
127
128 return this;
129 }
130
131 /***
132 * Method addChildElement
133 *
134 * @param element
135 * @throws SOAPException
136 */
137 public void addChildElement(MessageElement element) throws SOAPException {
138 createSequenceResponse.addChildElement(element);
139 }
140
141 /***
142 * Method getIdentifier
143 */
144 public Identifier getIdentifier() {
145 return identifier;
146 }
147
148 public Accept getAccept() {
149 return accept;
150 }
151
152 public void setAccept(Accept accept) {
153 this.accept = accept;
154 }
155
156 /***
157 * Method setIdentifier
158 *
159 * @param identifier
160 */
161 public void setIdentifier(Identifier identifier) {
162 this.identifier = identifier;
163 }
164 }