1 16 package sample.amazon.amazonSimpleQueueService.util; 17 18 import org.apache.axis2.clientapi.AsyncResult; 19 import org.apache.axis2.clientapi.Callback; 20 import org.apache.axis2.om.OMElement; 21 import org.apache.axis2.om.OMNode; 22 import org.apache.axis2.soap.SOAPBody; 23 24 import javax.swing.*; 25 import java.util.Iterator ; 26 31 public class SimpleQueueDeleteQueueCallbackHandler extends Callback { 32 private String returnString = ""; 33 JTextArea results; 34 JButton button; 35 public SimpleQueueDeleteQueueCallbackHandler(){} public SimpleQueueDeleteQueueCallbackHandler(JTextArea results,JButton button){ 37 super(); 38 this.results = results; 39 this.button = button; 40 } 41 public void onComplete(AsyncResult result) { 42 SOAPBody body = result.getResponseEnvelope().getBody(); 43 this.getQueueDeleteStatus(body); 44 this.button.setText("Delete Queue"); 45 } 46 public void reportError(Exception e) { 47 48 } 49 private void getQueueDeleteStatus(OMElement element) { 50 Iterator iterator = element.getChildren(); 51 while (iterator.hasNext()) { 52 OMNode omNode = (OMNode) iterator.next(); 53 if (omNode.getType() == OMNode.ELEMENT_NODE) { 54 OMElement omElement = (OMElement) omNode; 55 if (omElement.getLocalName().equals("Status")) { 56 this.readTheQueue(omElement); 57 }else{ 58 getQueueDeleteStatus(omElement); 59 } 60 } 61 } 62 } 63 private void readTheQueue(OMElement element) { 64 if (element.getText().equals("Errors")) { 65 returnString += "Queue can't be deleted, it has to be dequeued first" + "\n"; 66 } 67 else{ 68 returnString += "Queue is deleted" + "\n"; 69 } 70 this.results.setText(returnString + "\n"); 71 } 72 } 73 | Popular Tags |