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.FlowControl; 25 import org.netbeans.modules.websvc.wsitmodelext.rm.MaxReceiveBufferSize; 26 import org.netbeans.modules.websvc.wsitmodelext.rm.RMMSQName; 27 import org.netbeans.modules.xml.wsdl.model.Binding; 28 import org.netbeans.modules.xml.wsdl.model.WSDLComponentFactory; 29 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 30 import org.netbeans.modules.xml.xam.Model; 31 32 import java.io.IOException ; 33 import org.openide.ErrorManager; 34 35 39 public class RMMSModelHelper { 40 41 44 public RMMSModelHelper() { 45 } 46 47 public static void enableFlowControl(Binding b) { 49 All a = PolicyModelHelper.createPolicy(b); 50 PolicyModelHelper.createElement(a, RMMSQName.RMFLOWCONTROL.getQName(), FlowControl.class, false); 51 } 52 53 public static void disableFlowControl(Binding b) { 55 WSDLModel model = b.getModel(); 56 Policy p = PolicyModelHelper.getPolicyForElement(b); 57 FlowControl fc = getFlowControl(p); 58 if (fc != null) { 59 PolicyModelHelper.removeElement(fc.getParent(), FlowControl.class, false); 60 } 61 PolicyModelHelper.cleanPolicies(b); 62 } 63 64 public static boolean isFlowControlEnabled(Binding b) { 66 Policy p = PolicyModelHelper.getPolicyForElement(b); 67 if (p != null) { 68 FlowControl fc = getFlowControl(p); 69 return (fc != null); 70 } 71 return false; 72 } 73 74 public static FlowControl getFlowControl(Binding b) { 75 Policy p = PolicyModelHelper.getPolicyForElement(b); 76 return getFlowControl(p); 77 } 78 79 public static FlowControl getFlowControl(Policy p) { 80 return (FlowControl) PolicyModelHelper.getTopLevelElement(p, FlowControl.class); 81 } 82 83 public static void setMaxReceiveBufferSize(Binding b, String value) { 84 WSDLModel model = b.getModel(); 85 FlowControl fc = getFlowControl(b); 86 setMaxReceiveBufferSize(fc, value); 87 } 88 89 public static String getMaxReceiveBufferSize(Binding b) { 90 WSDLModel model = b.getModel(); 91 FlowControl fc = getFlowControl(b); 92 return getMaxReceiveBufferSize(fc); 93 } 94 95 public static String getMaxReceiveBufferSize(FlowControl fc) { 96 String max = null; 97 if (fc != null) { 98 MaxReceiveBufferSize maxBuf = fc.getMaxReceiveBufferSize(); 99 if (maxBuf!=null) { 100 max = maxBuf.getMaxReceiveBufferSize(); 101 } 102 } 103 return max; 104 } 105 106 public static void setMaxReceiveBufferSize(FlowControl fc, String value) { 107 if (fc != null) { 108 Model model = fc.getModel(); 109 boolean isTransaction = model.isIntransaction(); 110 if (!isTransaction) { 111 model.startTransaction(); 112 } 113 try { 114 MaxReceiveBufferSize maxBufSize = fc.getMaxReceiveBufferSize(); 115 if (maxBufSize == null) { 116 if (value != null) { WSDLComponentFactory wcf = fc.getModel().getFactory(); 118 MaxReceiveBufferSize maxBuf = (MaxReceiveBufferSize)wcf.create(fc, 119 RMMSQName.MAXRECEIVEBUFFERSIZE.getQName() 120 ); 121 maxBuf.setMaxReceiveBufferSize(value); 122 fc.addExtensibilityElement(maxBuf); 123 } 124 } else { 125 if (value == null) { 126 fc.removeMaxReceiveBufferSize(maxBufSize); 127 } else { 128 maxBufSize.setMaxReceiveBufferSize(value); 129 } 130 } 131 } finally { 132 if (!isTransaction) { 133 model.endTransaction(); 134 } 135 } 136 } 137 } 138 139 } 140 | Popular Tags |