1 23 24 package com.sun.enterprise.deployment.util; 25 26 import java.util.logging.Level ; 27 28 import java.io.File ; 29 import java.io.FileOutputStream ; 30 import java.io.InputStream ; 31 import java.io.IOException ; 32 33 import java.net.URL ; 34 import java.net.URLConnection ; 35 import java.net.MalformedURLException ; 36 37 import com.sun.enterprise.deployment.Application; 38 import com.sun.enterprise.deployment.archivist.Archivist; 39 import com.sun.enterprise.deployment.deploy.shared.FileArchive; 40 import com.sun.enterprise.deployment.ServiceReferenceDescriptor; 41 import com.sun.enterprise.deployment.util.DOLUtils; 42 import com.sun.enterprise.deployment.util.ModuleDescriptor; 43 import com.sun.enterprise.deployment.WebService; 44 import com.sun.enterprise.util.FileUtil; 45 46 50 public class ModuleContentLinker extends DefaultDOLVisitor { 51 52 protected FileArchive rootLocation_; 55 56 public ModuleContentLinker(FileArchive rootLocation) { 57 rootLocation_ = rootLocation; 58 } 59 60 protected ModuleContentLinker() { 61 } 62 63 private File getModuleLocation(ModuleDescriptor module) throws IOException { 64 File moduleLocation = new File (rootLocation_.getArchiveUri()); 65 if( !module.isStandalone() ) { 66 String archiveUri = module.getArchiveUri(); 69 moduleLocation = new File (rootLocation_.getEmbeddedArchive(archiveUri).getArchiveUri()); 70 } 71 return moduleLocation; 72 } 73 74 private URL internalGetUrl(ModuleDescriptor module, String uri) 75 throws Exception { 76 File moduleLocation = getModuleLocation(module); 77 URL url = FileUtil.getEntryAsUrl(moduleLocation, uri); 78 return url; 79 } 80 81 public void accept(ServiceReferenceDescriptor serviceRef) { 82 try { 83 ModuleDescriptor moduleDesc = 84 serviceRef.getBundleDescriptor().getModuleDescriptor(); 85 86 if( serviceRef.hasWsdlFile() ) { 87 88 String wsdlFileUri = serviceRef.getWsdlFileUri(); 89 File tmpFile = new File (wsdlFileUri); 90 if(tmpFile.isAbsolute()) { 91 serviceRef.setWsdlFileUrl(tmpFile.toURI().toURL()); 94 } else { 95 if(wsdlFileUri.startsWith("http")) { 97 serviceRef.setWsdlFileUrl(new URL (wsdlFileUri)); 98 } else { 99 File wsdlFile = new File (getModuleLocation(moduleDesc), wsdlFileUri); 101 URL wsdlFileUrl = internalGetUrl(moduleDesc, wsdlFileUri); 102 serviceRef.setWsdlFileUrl(wsdlFile.toURI().toURL()); 103 } 104 } 105 } 106 if( serviceRef.hasMappingFile() ) { 107 String mappingFileUri = serviceRef.getMappingFileUri(); 108 File mappingFile = new File (getModuleLocation(moduleDesc), mappingFileUri); 109 serviceRef.setMappingFile(mappingFile); 110 111 } 112 } catch (java.net.MalformedURLException mex) { 113 DOLUtils.getDefaultLogger().log 114 (Level.SEVERE, "enterprise.deployment.backend.invalidWsdlURL", 115 new Object [] {serviceRef.getWsdlFileUri()}); 116 } catch(Exception e) { 117 DOLUtils.getDefaultLogger().log 118 (Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure", 119 new Object [] {serviceRef.getName() , rootLocation_}); 120 } 121 } 122 123 public void accept(WebService webService) { 124 try { 125 ModuleDescriptor moduleDesc = 126 webService.getBundleDescriptor().getModuleDescriptor(); 127 128 if( webService.hasWsdlFile() && webService.getWsdlFileUrl()==null) { 129 String wsdlFileUri = webService.getWsdlFileUri(); 130 URL wsdlFileURL=null; 131 try { 132 URL url = new URL (wsdlFileUri); 133 if (url.getProtocol()!=null && !url.getProtocol().equalsIgnoreCase("file")) { 134 wsdlFileURL=url; 135 } 136 } catch(java.net.MalformedURLException e) { 137 } 139 if (wsdlFileURL==null) { 140 File wsdlFile = new File (getModuleLocation(moduleDesc), wsdlFileUri); 141 wsdlFileURL = wsdlFile.toURI().toURL(); 142 } 143 webService.setWsdlFileUrl(wsdlFileURL); 144 } 145 if( webService.hasMappingFile() ) { 146 String mappingFileUri = webService.getMappingFileUri(); 147 File mappingFile = new File (getModuleLocation(moduleDesc), mappingFileUri); 148 webService.setMappingFile(mappingFile); 149 } 150 } catch(Exception e) { 151 DOLUtils.getDefaultLogger().log 152 (Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure", 153 new Object [] {webService.getName() , rootLocation_}); 154 } 155 } 156 157 } 158 | Popular Tags |