1 19 20 package org.netbeans.modules.websvc.registry.model; 21 22 26 import com.sun.xml.rpc.processor.model.Port; 27 import com.sun.xml.rpc.processor.model.Operation; 28 30 import java.net.MalformedURLException ; 31 import java.net.URL ; 32 33 import java.io.File ; 34 35 import java.util.ArrayList ; 36 import java.util.Iterator ; 37 import java.util.Arrays ; 38 import java.util.List ; 39 import java.util.Set ; 40 import java.util.HashSet ; 41 import java.util.HashMap ; 42 43 44 50 public class WebServiceData { 51 52 53 private String websvcId; 54 55 private String name; 56 57 private int webServicePort; 58 59 private String wsdlUrl; 60 61 private String proxy; 62 63 private String groupId; 64 65 private String displayName; 66 67 private String proxyJarFileName; 68 69 private String packageName; 70 71 private String webServiceAddress; 72 73 76 private ArrayList ports = new ArrayList (); 77 78 public final static String PORT_PROPERTY_NAME="WSPORTNAME"; 79 80 public WebServiceData() { 81 this(WebServiceListModel.getInstance().getUniqueWebServiceId()); 82 } 83 84 public WebServiceData(String id) { 85 setId(id); 86 } 87 88 public void setId(String id){ 89 websvcId = id; 90 } 91 92 public String getId(){ 93 return websvcId; 94 } 95 96 97 public String getName() { 98 return name; 99 } 100 101 public String getDisplayName() { 102 if(displayName == null) displayName = name; 103 return displayName; 104 } 105 106 public void setDisplayName(String dispName) { 107 displayName = dispName; 108 } 109 110 111 public String getGroupId(){ 112 return groupId; 113 } 114 115 public void setGroupId(String id){ 116 groupId = id; 117 } 118 public void setPackageName(String inPackageName){ 119 packageName = inPackageName; 120 } 121 122 public void setWebServiceAddress(String inAddress){ 123 webServiceAddress = inAddress; 124 } 125 126 130 public void setName(String name) { 131 this.name = name; 132 } 133 134 137 public ArrayList getMethods() { 138 139 143 ArrayList returnMethods = new ArrayList (); 144 Iterator portIterator = ports.iterator(); 145 Port currentPort = null; 146 while(portIterator.hasNext()) { 147 currentPort = (Port)portIterator.next(); 148 if(null == currentPort || null == currentPort.getOperations()) { 149 continue; 150 } 151 Iterator operationIterator = currentPort.getOperations(); 152 Operation currentOperation = null; 153 while(operationIterator.hasNext()) { 154 currentOperation = (Operation)operationIterator.next(); 155 if(null == currentOperation) { 156 continue; 157 } 158 returnMethods.add(currentOperation); 159 } 160 } 161 return returnMethods; 162 } 163 164 165 166 public int getWebServicePort() { 167 return webServicePort; 168 } 169 170 public void setWebServicePort(int portNumber) { 171 webServicePort = portNumber; 172 } 173 174 public String getURL() { 175 return wsdlUrl; 176 } 177 178 public void setURL(String url) { 179 wsdlUrl = url; 180 } 181 182 public String getProxy() { 183 return proxy; 184 } 185 186 public void setProxy(String proxy) { 187 this.proxy = proxy; 188 } 189 190 public void setProxyJarFileName(String jarName){ 191 192 proxyJarFileName = jarName; 193 } 194 195 public String getProxyJarFileName(){ 196 204 if(null == proxyJarFileName) return null; 205 206 File proxyFile = new File (proxyJarFileName); 207 if(!proxyFile.exists()) { 208 211 String fileOnlyName = proxyJarFileName; 212 if(proxyJarFileName.indexOf("/") != -1) { 213 fileOnlyName = proxyJarFileName.substring(proxyJarFileName.lastIndexOf("/")+1); 214 } 215 216 if(proxyJarFileName.indexOf("\\") != -1) { 217 fileOnlyName = proxyJarFileName.substring(proxyJarFileName.lastIndexOf("\\")+1); 218 } 219 220 String newName = System.getProperty("netbeans.user") + File.separator + "websvc" + File.separator + fileOnlyName; 221 proxyFile = new File (newName); 222 if(!proxyFile.exists()) { 223 return null; 224 } else { 225 proxyJarFileName = newName; 226 229 this.setProxyJarFileName(proxyJarFileName); 230 } 231 } 232 233 return proxyJarFileName; 234 } 235 236 public String getWSDescription() { 237 return "Web Service Information-\n" + 238 "Name: " + name + "\n" + 239 "Port number: " + webServicePort + "\n" + 240 "URL: " + wsdlUrl + "\n" + 241 "Address: " + webServiceAddress + "\n" 242 ; 243 } 244 public String getPackageName(){ 245 if(null == packageName) { 246 packageName = "webservice"; } 248 return packageName; 249 } 250 public String getWebServiceAddress(){ 251 return webServiceAddress; 252 } 253 254 public Port [] getPorts() { 255 return (Port []) ports.toArray(new Port [0]); 256 } 257 258 public void addPort(Port inPort) { 259 ports.add(inPort); 260 } 261 262 public void setPorts(Port [] inPorts) { 263 ports = new ArrayList (Arrays.asList(inPorts)); 264 } 265 266 267 271 public boolean equals(Object inWSData) { 272 275 if(!(inWSData instanceof WebServiceData)) { 276 return false; 277 } 278 279 WebServiceData comparingWSdata = (WebServiceData)inWSData; 280 String thisDisplayName = this.getDisplayName(); 281 String comparingDisplayName = comparingWSdata.getDisplayName(); 282 283 286 if(null == comparingDisplayName && null != thisDisplayName) { 287 return false; 288 } 289 if(null == thisDisplayName && null != comparingDisplayName) { 290 return false; 291 } 292 293 297 if(null == thisDisplayName && null == comparingDisplayName) { 298 return true; 299 } 300 301 302 if(thisDisplayName.equalsIgnoreCase(comparingDisplayName)) { 303 return true; 304 } else { 305 return false; 306 } 307 308 } 309 310 315 public String toString() { 316 return "<html><b>Web Service Information</b>" + "" + 318 "<br><b>Name:</b> " + name + 319 "<br><b>Port number:</b> " + webServicePort + 320 "<br><b>URL:</b> " + wsdlUrl + 321 "<br><b>Address:</b> " + webServiceAddress + 322 "</html>" 323 ; 324 } 325 326 327 328 } | Popular Tags |