1 23 package com.sun.enterprise.tools.verifier.tests.app; 24 25 import com.sun.enterprise.tools.verifier.tests.app.ApplicationTest; 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.util.io.FileUtils; 29 import java.io.*; 30 import java.util.jar.*; 31 import java.util.*; 32 33 37 public class ModulesExistWeb extends ApplicationTest implements AppCheck { 38 39 40 49 public Result check(Application descriptor) { 50 51 Result result = getInitializedResult(); 52 53 54 55 if (descriptor.getWebBundleDescriptors().size() > 0) { 56 boolean oneFailed = false; 57 for (Iterator itr = descriptor.getWebBundleDescriptors().iterator(); itr.hasNext();) { 58 WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next(); 59 60 if (!(wbd.getModuleDescriptor().getArchiveUri().equals(""))) { 61 JarFile jarFile = null; 62 InputStream deploymentEntry=null; 63 boolean moduleDirExists = false; 64 65 71 String archBase = getAbstractArchiveUri(descriptor); 74 String moduleName = wbd.getModuleDescriptor().getArchiveUri(); 75 String moduleDir = FileUtils.makeFriendlyFileName(moduleName); 76 File f = new File(archBase + File.separator + moduleDir); 77 moduleDirExists = f.isDirectory(); 78 88 if ((deploymentEntry != null) || moduleDirExists) { 89 result.addGoodDetails(smh.getLocalString 90 (getClass().getName() + ".passed", 91 "J2EE Web module [ {0} ] exists within [ {1} ].", 92 new Object [] {wbd.getModuleDescriptor().getArchiveUri(),descriptor.getName()})); 93 } else { 94 if (!oneFailed) { 95 oneFailed = true; 96 } 97 result.addErrorDetails(smh.getLocalString 98 (getClass().getName() + ".failed", 99 "Error: J2EE Web module [ {0} ] does not exist within [ {1} ].", 100 new Object [] {wbd.getModuleDescriptor().getArchiveUri(), descriptor.getName()})); 101 } 102 103 try { 125 if (jarFile != null) 126 jarFile.close(); 127 if (deploymentEntry != null) 128 deploymentEntry.close(); 129 } catch (Exception x) {} 130 132 } 133 } 134 if (oneFailed) { 135 result.setStatus(Result.FAILED); 136 } else { 137 result.setStatus(Result.PASSED); 138 } 139 140 } else { 141 result.notApplicable(smh.getLocalString 142 (getClass().getName() + ".notApplicable", 143 "There are no web components in application [ {0} ]", 144 new Object [] {descriptor.getName()})); 145 } 146 return result; 147 } 148 } 149 | Popular Tags |