1 19 20 package org.netbeans.modules.web.project; 21 22 import org.netbeans.api.java.classpath.ClassPath; 23 import org.netbeans.modules.j2ee.metadata.ClassPathSupport; 24 import org.netbeans.modules.j2ee.dd.api.common.NameAlreadyUsedException; 25 import org.netbeans.modules.websvc.api.client.WebServicesClientConstants; 26 import org.netbeans.modules.websvc.spi.webservices.WebServicesSupportImpl; 27 import java.io.IOException ; 28 import java.util.Arrays ; 29 import java.util.ArrayList ; 30 import java.util.HashSet ; 31 import java.util.List ; 32 import java.util.Iterator ; 33 import org.netbeans.api.java.project.JavaProjectConstants; 34 import org.netbeans.api.project.Project; 35 import org.netbeans.api.project.ProjectManager; 36 import org.netbeans.api.project.ProjectUtils; 37 import org.netbeans.api.project.SourceGroup; 38 import org.netbeans.api.project.Sources; 39 import org.netbeans.api.project.ui.OpenProjects; 40 import org.netbeans.modules.j2ee.dd.api.webservices.ServiceImplBean; 41 import org.netbeans.spi.project.support.ant.AntProjectHelper; 42 import org.netbeans.spi.project.support.ant.EditableProperties; 43 import org.netbeans.spi.project.support.ant.PropertyUtils; 44 import org.openide.ErrorManager; 45 import org.openide.DialogDisplayer; 46 import org.openide.NotifyDescriptor; 47 import org.openide.filesystems.FileObject; 48 import org.openide.filesystems.FileUtil; 49 import org.openide.util.NbBundle; 50 import org.w3c.dom.Document ; 51 import org.w3c.dom.Element ; 52 import org.w3c.dom.Node ; 53 import org.w3c.dom.NodeList ; 54 import org.netbeans.modules.j2ee.dd.api.web.Servlet; 55 import org.netbeans.modules.j2ee.dd.api.web.ServletMapping; 56 import org.netbeans.modules.j2ee.dd.api.web.WebApp; 57 import org.netbeans.modules.j2ee.dd.api.web.DDProvider; 58 import org.netbeans.modules.web.project.classpath.ClassPathProviderImpl; 59 import static org.netbeans.modules.websvc.spi.webservices.WebServicesConstants.*; 60 import org.netbeans.modules.websvc.api.webservices.WsCompileEditorSupport; 61 import org.netbeans.modules.websvc.api.webservices.StubDescriptor; 62 import org.netbeans.spi.project.support.ant.ReferenceHelper; 63 64 69 public class WebProjectWebServicesSupport implements WebServicesSupportImpl { 70 private WebProject project; 71 private AntProjectHelper helper; 72 private ReferenceHelper referenceHelper; 73 private ClassPath projectSourcesClassPath; 74 75 76 public WebProjectWebServicesSupport(WebProject project, AntProjectHelper helper, ReferenceHelper referenceHelper) { 77 this.project = project; 78 this.helper = helper; 79 this.referenceHelper = referenceHelper; 80 } 81 82 public void addServiceImpl(String serviceName, FileObject configFile, boolean fromWSDL) { 83 this.addServiceImpl(serviceName, configFile, fromWSDL,null); 84 } 85 public void addServiceImpl(String serviceName, FileObject configFile, boolean fromWSDL, String [] wscompileFeatures) { 87 EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 89 String packageName = getPackageName(configFile); 90 ep.put(serviceName + CONFIG_PROP_SUFFIX, packageName + 91 (packageName.equals("") ? "" : "/") + configFile.getNameExt()); ep.put(serviceName + MAPPING_PROP_SUFFIX, serviceName + MAPPING_FILE_SUFFIX); String featurePropertyName = "wscompile.service." + serviceName + ".features"; getWebservicesDD(); 96 JAXRPCStubDescriptor stubDesc = null; 97 if (fromWSDL) { 98 if (wscompileFeatures!=null) 99 stubDesc = new JAXRPCStubDescriptor(StubDescriptor.WSDL_SERVICE_STUB, 100 NbBundle.getMessage(WebProjectWebServicesSupport.class,"LBL_WSDLServiceStub"), 101 wscompileFeatures); 102 else stubDesc = wsdlServiceStub; 103 } else { 104 stubDesc = seiServiceStub; 105 } 106 String defaultFeatures = stubDesc.getDefaultFeaturesAsArgument(); 107 ep.put(featurePropertyName, defaultFeatures); 108 helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); 109 Element data = helper.getPrimaryConfigurationData(true); 111 Document doc = data.getOwnerDocument(); 112 NodeList nodes = data.getElementsByTagName(WEB_SERVICES); Element webservices = null; 114 if (nodes.getLength() == 0){ 115 webservices = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, WEB_SERVICES); NodeList insertBefore = data.getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_CLIENTS); 117 if (insertBefore.getLength() <= 0) { 118 insertBefore = data.getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, "source-roots"); assert insertBefore.getLength() == 1 : "Invalid project.xml file."; } 121 data.insertBefore(webservices, insertBefore.item(0)); 122 } else { 123 webservices = (Element )nodes.item(0); 124 } 125 Element webservice = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, WEB_SERVICE); webservices.appendChild(webservice); 127 Element webserviceName = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, WEB_SERVICE_NAME); webservice.appendChild(webserviceName); 129 webserviceName.appendChild(doc.createTextNode(serviceName)); 130 if(fromWSDL) { 131 Element fromWSDLElem = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, "from-wsdl"); 132 webservice.appendChild(fromWSDLElem); 133 } 134 helper.putPrimaryConfigurationData(data, true); 135 updateWsCompileProperties(serviceName); 138 try { 139 ProjectManager.getDefault().saveProject(project); 140 }catch(java.io.IOException ioe){ 141 throw new RuntimeException (ioe.getMessage()); 142 } 143 } 144 145 private WebApp getWebApp() { 146 try { 147 FileObject deploymentDescriptor = getDeploymentDescriptor(); 148 if(deploymentDescriptor != null) { 149 return DDProvider.getDefault().getDDRoot(deploymentDescriptor); 150 } 151 } catch (java.io.IOException e) { 152 org.openide.ErrorManager.getDefault().log(e.getLocalizedMessage()); 153 } 154 return null; 155 } 156 157 public void addServiceEntriesToDD(String serviceName, String serviceEndpointInterface, String servantClassName) { 158 String servletName = WebServiceServlet_PREFIX + serviceName; 160 WebApp webApp = getWebApp(); 161 if(webApp != null){ 162 Servlet servlet = null; 163 try{ 164 servlet = (Servlet)webApp.addBean("Servlet", new String []{"ServletName","ServletClass"}, 165 new Object []{servletName,servantClassName}, "ServletName"); 166 servlet.setLoadOnStartup(new java.math.BigInteger ("1")); 167 ServletMapping servletMapping = (ServletMapping) 168 webApp.addBean("ServletMapping", new String []{"ServletName","UrlPattern"}, 169 new Object []{servletName, "/" + serviceName}, "ServletName"); 170 171 webApp.write(getDeploymentDescriptor()); 173 } catch (ClassNotFoundException exc) { 174 exc.printStackTrace(); 175 throw new RuntimeException (exc.getMessage()); 176 } catch (NameAlreadyUsedException exc) { 177 exc.printStackTrace(); 178 throw new RuntimeException (exc.getMessage()); 179 } catch (IOException exc) { 180 exc.printStackTrace(); 181 throw new RuntimeException (exc.getMessage()); 182 } 183 } 184 } 185 186 187 191 public FileObject getWebservicesDD() { 192 FileObject webInfFo = getWebInf(); 193 if (webInfFo==null) { 194 if (isProjectOpened()) { 195 DialogDisplayer.getDefault().notify( 196 new NotifyDescriptor.Message(NbBundle.getMessage(WebProjectWebServicesSupport.class,"MSG_WebInfCorrupted"), 197 NotifyDescriptor.ERROR_MESSAGE)); 198 } 199 return null; 200 } 201 return getWebInf().getFileObject(WEBSERVICES_DD, "xml"); 202 } 203 204 207 public FileObject getWsDDFolder() { 208 return getWebInf(); 209 } 210 211 215 public String getArchiveDDFolderName() { 216 return "WEB-INF"; } 218 219 223 public String getImplementationBean(String linkName) { 224 WebApp webApp = getWebApp(); 225 org.netbeans.modules.j2ee.dd.api.web.Servlet[] servlets = webApp.getServlet(); 226 for(int i = 0; i < servlets.length; i++) { 227 if(servlets[i].getServletName().equals(linkName)) { 228 return servlets[i].getServletClass(); 229 } 230 } 231 return null; 232 } 233 234 public boolean isFromWSDL(String serviceName) { 235 Element data = helper.getPrimaryConfigurationData(true); 236 NodeList nodes = data.getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, 237 WEB_SERVICES); Element webservices = null; 239 Element wsNameNode = null; 240 if(nodes.getLength() == 1){ 241 webservices = (Element )nodes.item(0); 242 NodeList wsNodes = webservices.getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, 243 WEB_SERVICE); for(int j = 0; j < wsNodes.getLength(); j++) { 245 Element wsNode = (Element )wsNodes.item(j); 246 NodeList wsNameNodes = wsNode.getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, 247 WEB_SERVICE_NAME); if(wsNameNodes.getLength() == 1) { 249 wsNameNode = (Element )wsNameNodes.item(0); 250 NodeList nl = wsNameNode.getChildNodes(); 251 if(nl.getLength() == 1) { 252 Node n = nl.item(0); 253 if(n.getNodeType() == Node.TEXT_NODE) { 254 if(serviceName.equals(n.getNodeValue())) { 255 NodeList fromWSDLNodes = wsNode.getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, 256 WEB_SERVICE_FROM_WSDL); if(fromWSDLNodes.getLength() == 1) { 258 return true; 259 } 260 } 261 } 262 } 263 } 264 } 265 } 266 return false; 267 } 268 269 public void removeProjectEntries(String serviceName) { 270 boolean needsSave = false; 271 272 EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 275 String configProperty = serviceName + CONFIG_PROP_SUFFIX; 276 String mappingProperty = serviceName + MAPPING_PROP_SUFFIX; 277 if(ep.getProperty(configProperty) != null) { 278 ep.remove(configProperty); 279 needsSave = true; 280 } 281 if(ep.getProperty(mappingProperty) != null) { 282 ep.remove(mappingProperty); 283 needsSave = true; 284 } 285 String featureProperty = "wscompile.service." + serviceName + ".features"; if(ep.getProperty(featureProperty) != null) { 287 ep.remove(featureProperty); 288 needsSave = true; 289 } 290 if(needsSave){ 291 helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); 292 } 293 Element data = helper.getPrimaryConfigurationData(true); 295 NodeList nodes = data.getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, 296 WEB_SERVICES); Element webservices = null; 298 Element wsNameNode = null; 299 if(nodes.getLength() == 1){ 300 webservices = (Element )nodes.item(0); 301 NodeList wsNodes = webservices.getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, 302 WEB_SERVICE); for(int j = 0; j < wsNodes.getLength(); j++) { 304 Element wsNode = (Element )wsNodes.item(j); 305 NodeList wsNameNodes = wsNode.getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, 306 WEB_SERVICE_NAME); if(wsNameNodes.getLength() == 1) { 308 wsNameNode = (Element )wsNameNodes.item(0); 309 NodeList nl = wsNameNode.getChildNodes(); 310 if(nl.getLength() == 1) { 311 Node n = nl.item(0); 312 if(n.getNodeType() == Node.TEXT_NODE) { 313 if(serviceName.equals(n.getNodeValue())) { 314 webservices.removeChild(wsNode); 315 NodeList children = webservices.getChildNodes(); 317 if(children.getLength() == 0) { 318 data.removeChild(webservices); 319 } 320 needsSave = true; 321 break; 322 } 323 } 324 } 325 } 326 } 327 } 328 if(needsSave) { 329 helper.putPrimaryConfigurationData(data, true); 330 try { 331 ProjectManager.getDefault().saveProject(project); 332 } catch(IOException ex) { 333 String mes = NbBundle.getMessage(this.getClass(), "MSG_ErrorSavingOnWSRemove") + serviceName + "'\r\n" + ex.getMessage(); 335 NotifyDescriptor desc = new NotifyDescriptor. 336 Message(mes, NotifyDescriptor.Message.ERROR_MESSAGE); 337 DialogDisplayer.getDefault().notify(desc); } 338 } 339 } 340 341 public void removeServiceEntry(String linkName) { 342 WebApp webApp = getWebApp(); 344 Servlet[] servlets = webApp.getServlet(); 345 for(int i = 0; i < servlets.length; i++) { 346 Servlet servlet = servlets[i]; 347 if(servlet.getServletName().equals(linkName)) { 348 webApp.removeServlet(servlet); 349 break; 350 } 351 } 352 ServletMapping[] mappings = webApp.getServletMapping(); 353 for(int j = 0; j < mappings.length; j++ ) { 354 ServletMapping mapping = mappings[j]; 355 if(mapping.getServletName().equals(linkName)) { 356 webApp.removeServletMapping(mapping); 357 } 358 } 359 try { 360 webApp.write(getDeploymentDescriptor()); 362 } 363 catch(java.io.IOException e) { 364 NotifyDescriptor ndd = 365 new NotifyDescriptor.Message(NbBundle.getMessage(this.getClass(), "MSG_Unable_WRITE_WS_DD"), NotifyDescriptor.ERROR_MESSAGE); 367 DialogDisplayer.getDefault().notify(ndd); 368 } 369 } 370 371 public AntProjectHelper getAntProjectHelper() { 372 return helper; 373 } 374 375 public String generateImplementationBean(String wsName, FileObject pkg, Project project, String delegateData) 376 throws java.io.IOException { 377 return null; 378 } 380 381 public void addServiceImplLinkEntry(ServiceImplBean serviceImplBean, String wsName) { 382 serviceImplBean.setServletLink(WebServiceServlet_PREFIX + wsName); 383 } 384 385 public ReferenceHelper getReferenceHelper(){ 386 return referenceHelper; 387 } 388 389 397 private static final String [] WSCOMPILE_SEI_SERVICE_FEATURES = { 398 "documentliteral", "rpcliteral", "noencodedtypes", 406 "nomultirefs", 407 "serializeinterfaces", 412 "strict", "useonewayoperations", "donotoverride", }; 419 420 private static final List allSeiServiceFeatures = Arrays.asList(WSCOMPILE_SEI_SERVICE_FEATURES); 421 422 private static final String [] WSCOMPILE_KEY_SEI_SERVICE_FEATURES = { 423 "documentliteral", 424 "rpcliteral", 425 "strict", 426 "useonewayoperations", 427 "donotoverride" 428 }; 429 430 private static final List importantSeiServiceFeatures = Arrays.asList(WSCOMPILE_KEY_SEI_SERVICE_FEATURES); 431 432 private static final String [] WSCOMPILE_WSDL_SERVICE_FEATURES = { 433 "datahandleronly", "explicitcontext", "jaxbenumtype", "nodatabinding", "noencodedtypes", 441 "nomultirefs", 442 "norpcstructures", "novalidation", "resolveidref", "searchschema", "serializeinterfaces", 447 "strict", "wsi", "unwrap", "donotoverride", "donotunwrap", }; 454 455 private static final List allWsdlServiceFeatures = Arrays.asList(WSCOMPILE_WSDL_SERVICE_FEATURES); 456 457 private static final String [] WSCOMPILE_KEY_WSDL_SERVICE_FEATURES = { 458 "wsi", 459 "strict", 460 "unwrap", 461 "donotunwrap", 462 "donotoverride", 463 "datahandleronly", 464 "nodatabinding", 465 "novalidation", 466 "searchschema", 467 "explicitcontext", 468 }; 469 470 private static final List importantWsdlServiceFeatures = Arrays.asList(WSCOMPILE_KEY_WSDL_SERVICE_FEATURES); 471 472 public List getServices() { 473 List serviceList = new ArrayList (); 474 475 Element data = helper.getPrimaryConfigurationData(true); 476 NodeList nodes = data.getElementsByTagName(WEB_SERVICES); 477 EditableProperties projectProperties = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 478 479 if(nodes.getLength() != 0) { 480 Element serviceElements = (Element ) nodes.item(0); 481 NodeList serviceNameList = serviceElements.getElementsByTagNameNS( 482 WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, WEB_SERVICE_NAME); 483 for(int i = 0; i < serviceNameList.getLength(); i++ ) { 484 Element serviceNameElement = (Element ) serviceNameList.item(i); 485 NodeList nl = serviceNameElement.getChildNodes(); 486 if(nl.getLength() == 1) { 487 org.w3c.dom.Node n = nl.item(0); 488 if(n.getNodeType() == org.w3c.dom.Node.TEXT_NODE) { 489 String serviceName = n.getNodeValue(); 490 String currentFeatures = projectProperties.getProperty("wscompile.service." + serviceName + ".features"); StubDescriptor stubType = getServiceStubDescriptor(serviceNameElement.getParentNode()); 492 WsCompileEditorSupport.ServiceSettings settings; 493 494 if(seiServiceStub == stubType) { 496 if(currentFeatures == null) { 497 currentFeatures = seiServiceStub.getDefaultFeaturesAsArgument(); 499 } 500 settings = new WsCompileEditorSupport.ServiceSettings( 501 serviceName, stubType, currentFeatures, allSeiServiceFeatures, importantSeiServiceFeatures); 502 } else { if(currentFeatures == null) { 504 currentFeatures = wsdlServiceStub.getDefaultFeaturesAsArgument(); 506 } 507 settings = new WsCompileEditorSupport.ServiceSettings( 508 serviceName, stubType, currentFeatures, allWsdlServiceFeatures, importantWsdlServiceFeatures); 509 } 510 serviceList.add(settings); 511 } else { 512 } 514 } else { 515 } 517 } 518 } 519 520 return serviceList; 521 } 522 523 private StubDescriptor getServiceStubDescriptor(org.w3c.dom.Node parentNode) { 524 StubDescriptor result = null; 525 526 if(parentNode instanceof Element ) { 527 Element parentElement = (Element ) parentNode; 528 NodeList fromWsdlList = parentElement.getElementsByTagNameNS( 529 WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, WEB_SERVICE_FROM_WSDL); 530 if(fromWsdlList.getLength() == 1) { 531 result = wsdlServiceStub; 532 } else { 533 result = seiServiceStub; 534 } 535 } 536 537 return result; 538 } 539 540 private String getPackageName(FileObject file){ 541 FileObject parent = file.getParent(); 542 Sources sources = ProjectUtils.getSources(project); 543 SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); 544 String packageName = null; 545 for (int i = 0; i < groups.length && packageName == null; i++) { 546 packageName = FileUtil.getRelativePath(groups[i].getRootFolder(), parent); 547 if (packageName != null) { 548 packageName = groups[i].getName() + "/" + packageName; 549 } 550 } 551 return packageName + ""; 552 } 553 554 public void addInfrastructure(String implBeanClass, FileObject pkg) { 555 } 557 558 public FileObject getDeploymentDescriptor() { 559 FileObject webInfFo = getWebInf(); 560 if (webInfFo==null) { 561 if (isProjectOpened()) { 562 DialogDisplayer.getDefault().notify( 563 new NotifyDescriptor.Message(NbBundle.getMessage(WebProjectWebServicesSupport.class,"MSG_WebInfCorrupted"), NotifyDescriptor.ERROR_MESSAGE)); 565 } 566 return null; 567 } 568 return getWebInf().getFileObject(ProjectWebModule.FILE_DD); 569 } 570 571 public FileObject getWebInf() { 572 FileObject documentBase = getDocumentBase(); 573 if (documentBase != null) 574 return documentBase.getFileObject(ProjectWebModule.FOLDER_WEB_INF); 575 else 576 return null; 577 } 578 579 public FileObject getDocumentBase() { 580 return getFileObject("web.docbase.dir"); } 582 583 private FileObject getFileObject(String propname) { 584 String prop = helper.getStandardPropertyEvaluator().getProperty(propname); 585 if (prop != null) { 586 return helper.resolveFileObject(prop); 587 } else { 588 return null; 589 } 590 } 591 592 private boolean updateWsCompileProperties(String serviceName) { 593 605 boolean globalPropertiesChanged = false; 606 607 EditableProperties globalProperties = PropertyUtils.getGlobalProperties(); 608 if(globalProperties.getProperty(WSCOMPILE_TOOLS_CLASSPATH) == null) { 609 globalProperties.setProperty(WSCOMPILE_TOOLS_CLASSPATH, "${java.home}\\..\\lib\\tools.jar"); 611 try { 612 PropertyUtils.putGlobalProperties(globalProperties); 613 } catch(IOException ex) { 614 NotifyDescriptor desc = new NotifyDescriptor.Message( 615 NbBundle.getMessage(WebProjectWebServicesSupport.class,"MSG_ErrorSavingGlobalProperties", serviceName, ex.getMessage()), NotifyDescriptor.ERROR_MESSAGE); 617 DialogDisplayer.getDefault().notify(desc); 618 } 619 620 globalPropertiesChanged = true; 621 } 622 623 624 boolean projectPropertiesChanged = false; 625 EditableProperties projectProperties = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 626 627 { HashSet wscJars = new HashSet (); 629 boolean newWscJars = false; 630 String wscClientClasspath = projectProperties.getProperty(WSCOMPILE_CLASSPATH); 631 if(wscClientClasspath != null) { 632 String [] libs = PropertyUtils.tokenizePath(wscClientClasspath); 633 for(int i = 0; i < libs.length; i++) { 634 wscJars.add(libs[i]); 635 } 636 } 637 638 for(int i = 0; i < WSCOMPILE_JARS.length; i++) { 639 if(!wscJars.contains(WSCOMPILE_JARS[i])) { 640 wscJars.add(WSCOMPILE_JARS[i]); 641 newWscJars = true; 642 } 643 } 644 645 if(newWscJars) { 646 StringBuffer newClasspathBuf = new StringBuffer (256); 647 for(Iterator iter = wscJars.iterator(); iter.hasNext(); ) { 648 newClasspathBuf.append(iter.next().toString()); 649 if(iter.hasNext()) { 650 newClasspathBuf.append(':'); 651 } 652 } 653 projectProperties.put(WSCOMPILE_CLASSPATH, newClasspathBuf.toString()); 654 projectPropertiesChanged = true; 655 } 656 } 657 658 if(projectProperties.getProperty(WSCOMPILE_TOOLS_CLASSPATH) == null) { 660 projectProperties.setProperty(WSCOMPILE_TOOLS_CLASSPATH, "${java.home}\\..\\lib\\tools.jar"); projectPropertiesChanged = true; 662 } 663 664 if(projectPropertiesChanged) { 665 helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, projectProperties); 666 } 667 668 return globalPropertiesChanged || projectPropertiesChanged; 669 } 670 671 public FileObject getWsdlFolder(boolean create) throws IOException { 672 FileObject wsdlFolder = null; 673 FileObject webInf = getWebInf(); 674 675 if(webInf != null) { 676 wsdlFolder = webInf.getFileObject(WSDL_FOLDER); 677 if(wsdlFolder == null && create) { 678 wsdlFolder = webInf.createFolder(WSDL_FOLDER); 679 } 680 } else if(create) { 681 ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, 684 NbBundle.getMessage(WebProjectWebServicesSupport.class,"MSG_WebInfNotFoundForWsdlFolder")); 685 } 686 687 return wsdlFolder; 688 } 689 690 private boolean isProjectOpened() { 691 if (OpenProjects.getDefault() == null) 694 return true; 695 696 Project[] projects = OpenProjects.getDefault().getOpenProjects(); 697 for (int i = 0; i < projects.length; i++) { 698 if (projects[i].equals(project)) 699 return true; 700 } 701 return false; 702 } 703 704 public ClassPath getClassPath() { 705 synchronized (this) { 706 if (projectSourcesClassPath == null) { 707 ClassPathProviderImpl cpProvider = (ClassPathProviderImpl)project.getLookup().lookup(ClassPathProviderImpl.class); 708 projectSourcesClassPath = ClassPathSupport.createWeakProxyClassPath(new ClassPath[] { 709 cpProvider.getProjectSourcesClassPath(ClassPath.SOURCE), 710 cpProvider.getJ2eePlatformClassPath(), 711 }); 712 } 713 return projectSourcesClassPath; 714 } 715 } 716 717 private static final JAXRPCStubDescriptor seiServiceStub = new JAXRPCStubDescriptor( 719 StubDescriptor.SEI_SERVICE_STUB, 720 NbBundle.getMessage(WebProjectWebServicesSupport.class,"LBL_SEIServiceStub"), 721 new String [] { "documentliteral", "strict", "useonewayoperations" }); 722 723 private static final JAXRPCStubDescriptor wsdlServiceStub = new JAXRPCStubDescriptor( 724 StubDescriptor.WSDL_SERVICE_STUB, 725 NbBundle.getMessage(WebProjectWebServicesSupport.class,"LBL_WSDLServiceStub"), 726 new String [] { "wsi", "strict" }); 727 728 730 private static class JAXRPCStubDescriptor extends StubDescriptor { 731 732 private String [] defaultFeatures; 733 734 public JAXRPCStubDescriptor(String name, String displayName, String [] defaultFeatures) { 735 super(name, displayName); 736 737 this.defaultFeatures = defaultFeatures; 738 } 739 740 public String [] getDefaultFeatures() { 741 return defaultFeatures; 742 } 743 744 public String getDefaultFeaturesAsArgument() { 745 StringBuffer buf = new StringBuffer (defaultFeatures.length*32); 746 for(int i = 0; i < defaultFeatures.length; i++) { 747 if(i > 0) { 748 buf.append(','); 749 } 750 751 buf.append(defaultFeatures[i]); 752 } 753 return buf.toString(); 754 } 755 } 756 } 757 | Popular Tags |