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 ModulesExistEjb extends ApplicationTest implements AppCheck { 38 39 40 49 public Result check(Application descriptor) { 50 51 Result result = getInitializedResult(); 52 53 54 55 if (descriptor.getEjbBundleDescriptors().size() > 0) { 56 boolean oneFailed = false; 57 for (Iterator itr = descriptor.getEjbBundleDescriptors().iterator(); itr.hasNext();) { 58 EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next(); 59 60 if (!(ejbd.getModuleDescriptor().getArchiveUri().equals(""))) { 61 JarFile jarFile = null; 62 InputStream deploymentEntry=null; 63 boolean moduleDirExists = false; 64 65 71 String archBase = 74 getAbstractArchiveUri(descriptor); 75 String moduleName = 76 ejbd.getModuleDescriptor().getArchiveUri(); 77 String moduleDir = FileUtils.makeFriendlyFileName(moduleName); 78 File f = new File(archBase + File.separator 79 + moduleDir); 80 moduleDirExists = f.isDirectory(); 81 91 if ((deploymentEntry != null) || (moduleDirExists)) { 92 result.addGoodDetails(smh.getLocalString 93 (getClass().getName() + ".passed", 94 "J2EE EJB module [ {0} ] exists within [ {1} ]", 95 new Object [] {ejbd.getModuleDescriptor().getArchiveUri(),descriptor.getName()})); 96 } else { 97 if (!oneFailed) { 98 oneFailed = true; 99 } 100 result.addErrorDetails(smh.getLocalString 101 (getClass().getName() + ".failed", 102 "Error: J2EE EJB module [ {0} ] does not exist within [ {1} ].", 103 new Object [] {ejbd.getModuleDescriptor().getArchiveUri(),descriptor.getName()})); 104 } 105 106 try { 128 if (jarFile != null) 129 jarFile.close(); 130 if (deploymentEntry != null) 131 deploymentEntry.close(); 132 } catch (Exception x) {} 133 135 } 136 137 } 138 if (oneFailed) { 139 result.setStatus(Result.FAILED); 140 } else { 141 result.setStatus(Result.PASSED); 142 } 143 144 } else { 145 result.notApplicable(smh.getLocalString 146 (getClass().getName() + ".notApplicable", 147 "There are no EJB components in application [ {0} ]", 148 new Object [] {descriptor.getName()})); 149 } 150 return result; 151 } 152 } 153 | Popular Tags |