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 ModulesExistAppClient extends ApplicationTest implements AppCheck { 38 39 40 49 public Result check(Application descriptor) { 50 51 Result result = getInitializedResult(); 52 53 54 55 if (descriptor.getApplicationClientDescriptors().size() > 0) { 56 boolean oneFailed = false; 57 for (Iterator itr = descriptor.getApplicationClientDescriptors().iterator(); itr.hasNext();) { 58 ApplicationClientDescriptor acd = (ApplicationClientDescriptor) itr.next(); 59 60 if (!(acd.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 acd.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 Application Client module [ {0} ] exists within [ {1} ].", 95 new Object [] {acd.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 Application Client module [ {0} ] does not exist within [ {1} ].", 103 new Object [] {acd.getModuleDescriptor().getArchiveUri(), descriptor.getName()})); 104 } 105 106 try { 109 if (jarFile != null) 110 jarFile.close(); 111 if (deploymentEntry != null) 112 deploymentEntry.close(); 113 } catch (Exception x) {} 114 116 } 117 118 } 119 if (oneFailed) { 120 result.setStatus(Result.FAILED); 121 } else { 122 result.setStatus(Result.PASSED); 123 } 124 } else { 125 result.notApplicable(smh.getLocalString 126 (getClass().getName() + ".notApplicable", 127 "There are no java application clients in application [ {0} ]", 128 new Object [] {descriptor.getName()})); 129 } 130 return result; 131 } 132 } 133 | Popular Tags |