KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > sandesha > ws > rm > AcksTo


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.axis.message.addressing.Address;
22 import org.apache.sandesha.Constants;
23
24 import javax.xml.soap.SOAPException JavaDoc;
25 import java.util.Iterator JavaDoc;
26
27 public class AcksTo implements IRmElement {
28     private Address address;
29     private MessageElement acksToElement;
30
31     /**
32      * Constructor Nack
33      */

34     public AcksTo() {
35     }
36
37     public AcksTo(Address address) {
38         acksToElement = new MessageElement();
39         acksToElement.setName(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.ACKS_TO);
40         this.address = address;
41     }
42
43     /**
44      * Method fromSOAPEnvelope
45      *
46      * @param element
47      * @return Nack
48      */

49     public AcksTo fromSOAPEnvelope(MessageElement element) throws SOAPException JavaDoc {
50
51         Iterator JavaDoc iterator = element.getChildElements();
52         MessageElement childElement;
53         try {
54             while (iterator.hasNext()) {
55                 childElement = (MessageElement) iterator.next();
56                 if (childElement.getName().equals(org.apache.axis.message.addressing.Constants.NS_PREFIX_ADDRESSING +
57                         Constants.COLON +
58                         org.apache.axis.message.addressing.Constants.ADDRESS)) {
59                     String JavaDoc uri = childElement.getFirstChild().getFirstChild().toString();
60                     address = new Address(uri);
61                 }
62                 if (childElement.getName().equals(org.apache.axis.message.addressing.Constants.ADDRESS)) {
63                     String JavaDoc uri = childElement.getFirstChild().getNodeValue();
64                     address = new Address(uri);
65                 }
66             }
67         } catch (Exception JavaDoc e) {
68             throw new SOAPException JavaDoc(e);
69         }
70         return this;
71     }
72
73     /**
74      * Method toSOAPEnvelope
75      *
76      * @param msgElement
77      * @return MessageElement
78      * @throws SOAPException
79      */

80     public MessageElement toSOAPEnvelope(MessageElement msgElement) throws SOAPException JavaDoc {
81         MessageElement messageElement = new MessageElement("", Constants.WSRM.NS_PREFIX_RM,
82                 Constants.WSRM.NS_URI_RM);
83         messageElement.setName(Constants.WSRM.ACKS_TO);
84         address.append(messageElement);
85         msgElement.addChildElement(messageElement);
86         return msgElement;
87     }
88
89     public MessageElement getSoapElement() throws SOAPException JavaDoc {
90         address.append(acksToElement);
91         return acksToElement;
92     }
93
94     /**
95      * Method addChildElement
96      *
97      * @param element
98      */

99     public void addChildElement(MessageElement element) {
100         // TODO no child elements ?
101
}
102
103     /**
104      * get the address
105      *
106      * @return
107      */

108     public Address getAddress() {
109         return address;
110     }
111
112     /**
113      * set the address
114      *
115      * @param address
116      */

117     public void setAddress(Address address) {
118         this.address = address;
119     }
120
121
122 }
123
Popular Tags