1 19 20 package org.netbeans.modules.websvc.wsitconf.wsdlmodelext; 21 22 import org.netbeans.modules.websvc.wsitmodelext.policy.All; 23 import org.netbeans.modules.websvc.wsitmodelext.policy.Policy; 24 import org.netbeans.modules.websvc.wsitmodelext.rm.AckRequestInterval; 25 import org.netbeans.modules.websvc.wsitmodelext.rm.CloseTimeout; 26 import org.netbeans.modules.websvc.wsitmodelext.rm.Ordered; 27 import org.netbeans.modules.websvc.wsitmodelext.rm.RMSunClientQName; 28 import org.netbeans.modules.websvc.wsitmodelext.rm.RMSunQName; 29 import org.netbeans.modules.websvc.wsitmodelext.rm.ResendInterval; 30 import org.netbeans.modules.xml.wsdl.model.Binding; 31 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 32 33 37 public class RMSunModelHelper { 38 39 42 public RMSunModelHelper() { 43 } 44 45 public static void enableOrdered(Binding b) { 47 All a = PolicyModelHelper.createPolicy(b); 48 PolicyModelHelper.createElement(a, RMSunQName.ORDERED.getQName(), Ordered.class, false); 49 } 50 51 public static void disableOrdered(Binding b) { 53 WSDLModel model = b.getModel(); 54 Policy p = PolicyModelHelper.getPolicyForElement(b); 55 Ordered ord = getOrdered(p); 56 if (ord != null) { 57 PolicyModelHelper.removeElement(ord.getParent(), Ordered.class, false); 58 } 59 PolicyModelHelper.cleanPolicies(b); 60 } 61 62 public static boolean isOrderedEnabled(Binding b) { 64 WSDLModel model = b.getModel(); 65 Policy p = PolicyModelHelper.getPolicyForElement(b); 66 if (p != null) { 67 Ordered ord = getOrdered(p); 68 return (ord != null); 69 } 70 return false; 71 } 72 73 public static Ordered getOrdered(Policy p) { 74 return (Ordered) PolicyModelHelper.getTopLevelElement(p, Ordered.class); 75 } 76 77 public static String getResendInterval(Binding b) { 78 WSDLModel model = b.getModel(); 79 Policy p = PolicyModelHelper.getPolicyForElement(b); 80 ResendInterval ri = (ResendInterval) PolicyModelHelper.getTopLevelElement(p, ResendInterval.class); 81 if (ri != null) { 82 return ri.getResendInterval(); 83 } 84 return null; 85 } 86 87 public static void setResendInterval(Binding b, String value) { 88 WSDLModel model = b.getModel(); 89 All all = PolicyModelHelper.createPolicy(b); 90 ResendInterval ri = PolicyModelHelper.createElement(all, 91 RMSunClientQName.RESENDINTERVAL.getQName(), ResendInterval.class, false); 92 boolean isTransaction = model.isIntransaction(); 93 if (!isTransaction) { 94 model.startTransaction(); 95 } 96 try { 97 if ((value == null) && (ri != null)) { 98 PolicyModelHelper.removeElement(ri); 99 } else { 100 ri.setResendInterval(value); 101 } 102 } finally { 103 if (!isTransaction) { 104 model.endTransaction(); 105 } 106 } 107 } 108 109 public static String getCloseTimeout(Binding b) { 110 WSDLModel model = b.getModel(); 111 Policy p = PolicyModelHelper.getPolicyForElement(b); 112 CloseTimeout ct = (CloseTimeout) PolicyModelHelper.getTopLevelElement(p, CloseTimeout.class); 113 if (ct != null) { 114 return ct.getCloseTimeout(); 115 } 116 return null; 117 } 118 119 public static void setCloseTimeout(Binding b, String value) { 120 WSDLModel model = b.getModel(); 121 All all = PolicyModelHelper.createPolicy(b); 122 CloseTimeout ct = PolicyModelHelper.createElement(all, 123 RMSunClientQName.CLOSETIMEOUT.getQName(), CloseTimeout.class, false); 124 boolean isTransaction = model.isIntransaction(); 125 if (!isTransaction) { 126 model.startTransaction(); 127 } 128 try { 129 if ((value == null) && (ct != null)) { 130 PolicyModelHelper.removeElement(ct); 131 } else { 132 ct.setCloseTimeout(value); 133 } 134 } finally { 135 if (!isTransaction) { 136 model.endTransaction(); 137 } 138 } 139 } 140 141 public static String getAckRequestInterval(Binding b) { 142 WSDLModel model = b.getModel(); 143 Policy p = PolicyModelHelper.getPolicyForElement(b); 144 AckRequestInterval ri = PolicyModelHelper.getTopLevelElement(p, AckRequestInterval.class); 145 if (ri != null) { 146 return ri.getAckRequestInterval(); 147 } 148 return null; 149 } 150 151 public static void setAckRequestInterval(Binding b, String value) { 152 WSDLModel model = b.getModel(); 153 All all = PolicyModelHelper.createPolicy(b); 154 AckRequestInterval ri = PolicyModelHelper.createElement(all, 155 RMSunClientQName.ACKREQUESTINTERVAL.getQName(), AckRequestInterval.class, false); 156 boolean isTransaction = model.isIntransaction(); 157 if (!isTransaction) { 158 model.startTransaction(); 159 } 160 try { 161 if ((value == null) && (ri != null)) { 162 PolicyModelHelper.removeElement(ri); 163 } else { 164 ri.setAckRequestInterval(value); 165 } 166 } finally { 167 if (!isTransaction) { 168 model.endTransaction(); 169 } 170 } 171 } 172 173 } 174 | Popular Tags |