1 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 36 public class TerminateSequence implements IRmElement { 37 38 41 private MessageElement terminateSequence; 42 43 46 private Identifier identifier; 47 48 51 public TerminateSequence() { 52 terminateSequence = new MessageElement(); 53 terminateSequence.setName(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.TERMINATE_DEQUENCE); 54 } 55 56 61 62 68 public MessageElement getSoapElement() throws SOAPException { 69 70 terminateSequence.addChildElement(identifier.getSoapElement()); 71 72 return terminateSequence; 73 } 74 75 82 public SOAPEnvelope toSoapEnvelop(SOAPEnvelope envelope) throws SOAPException { 83 84 SOAPEnvelope env = envelope; 85 86 if (env.getBody() == null) { 87 env.addBody(); 88 } 89 90 Name name = env.createName("", Constants.WSRM.NS_PREFIX_RM, Constants.WSRM.NS_URI_RM); 91 SOAPBodyElement bodyElement = (SOAPBodyElement) env.getBody().addBodyElement(name); 92 93 bodyElement.setName(Constants.WSRM.TERMINATE_DEQUENCE); 94 95 if (identifier != null) { 96 identifier.toSOAPEnvelope(bodyElement); 97 } 98 99 return env; 100 } 101 102 108 public TerminateSequence fromSOAPEnveploe(SOAPBodyElement bodyElement) { 109 110 Iterator iterator = bodyElement.getChildElements(); 111 MessageElement childElement; 112 113 while (iterator.hasNext()) { 114 115 childElement = (MessageElement) iterator.next(); 116 117 if (childElement.getName().equals(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.IDENTIFIER)) { 118 identifier = new Identifier(); 119 120 identifier.fromSOAPEnvelope(childElement); 121 } 122 123 if (childElement.getName().equals(Constants.WSRM.IDENTIFIER)) { 124 identifier = new Identifier(); 125 126 identifier.fromSOAPEnvelope(childElement); 127 } 128 } 129 130 return this; 131 } 132 133 139 public void addChildElement(MessageElement element) throws SOAPException { 140 141 terminateSequence.addChildElement(element); 142 143 } 144 145 150 public Identifier getIdentifier() { 151 return identifier; 152 } 153 154 159 public void setIdentifier(Identifier identifier) { 160 this.identifier = identifier; 161 } 162 } | Popular Tags |