1 23 package com.sun.enterprise.tools.verifier.tests.app; 24 25 import com.sun.enterprise.tools.verifier.tests.app.ApplicationTest; 26 import java.io.*; 27 import java.util.jar.*; 28 import java.util.*; 29 import com.sun.enterprise.deployment.*; 30 import com.sun.enterprise.tools.verifier.*; 31 32 import com.sun.enterprise.deployment.deploy.shared.FileArchive; 33 34 38 39 public class AppAltDDEjb extends ApplicationTest implements AppCheck { 40 41 42 50 public Result check(Application descriptor) { 51 52 Result result = getInitializedResult(); 53 if (descriptor.getEjbBundleDescriptors().size() > 0) { 54 boolean oneFailed = false; 55 int na = 0; 56 for (Iterator itr = descriptor.getEjbBundleDescriptors().iterator(); itr.hasNext();) { 57 EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next(); 58 59 if (ejbd.getModuleDescriptor().getAlternateDescriptor()!=null) { 60 if (!(ejbd.getModuleDescriptor().getAlternateDescriptor().equals(""))) { 61 JarFile jarFile = null; 62 InputStream deploymentEntry=null; 63 67 try { 68 String uri = getAbstractArchiveUri(descriptor); 70 FileArchive arch = new FileArchive(); 72 arch.open(uri); 73 deploymentEntry = arch.getEntry(ejbd.getModuleDescriptor().getAlternateDescriptor()); 74 84 if (deploymentEntry != null) { 85 result.addGoodDetails(smh.getLocalString 86 (getClass().getName() + ".passed", 87 "Found alternate EJB deployment descriptor URI file [ {0} ] within [ {1} ]", 88 new Object [] {ejbd.getModuleDescriptor().getAlternateDescriptor(),ejbd.getName()})); 89 } else { 90 if (!oneFailed) { 91 oneFailed = true; 92 } 93 result.addErrorDetails(smh.getLocalString 94 (getClass().getName() + ".failed", 95 "Error: No alternate EJB deployment descriptor URI file found, looking for [ {0} ] within [ {1} ]", 96 new Object [] {ejbd.getModuleDescriptor().getAlternateDescriptor(),ejbd.getName()})); 97 } 98 100 } catch (FileNotFoundException ex) { 101 Verifier.debug(ex); 102 if (!oneFailed) { 103 oneFailed = true; 104 } 105 106 result.failed(smh.getLocalString 107 (getClass().getName() + ".failedException", 108 "Error: File not found trying to read deployment descriptor file [ {0} ] within [ {1} ]", 109 new Object [] {ejbd.getModuleDescriptor().getAlternateDescriptor(), ejbd.getName()})); 110 } catch (IOException ex) { 111 Verifier.debug(ex); 112 if (!oneFailed) { 113 oneFailed = true; 114 } 115 116 result.failed(smh.getLocalString 117 (getClass().getName() + ".failedException1", 118 "Error: IO Error trying to read deployment descriptor file [ {0} ] within [ {1} ]", 119 new Object [] {ejbd.getModuleDescriptor().getAlternateDescriptor(), ejbd.getName()})); 120 } finally { 121 try { 122 if (deploymentEntry != null) 123 deploymentEntry.close(); 124 } catch (Exception x) {} 125 } 126 127 } 128 } else { 129 na++; 130 result.notApplicable(smh.getLocalString 131 (getClass().getName() + ".notApplicable1", 132 "There is no java EJB alternative deployment descriptor in [ {0} ]", 133 new Object [] {ejbd.getName()})); 134 } 135 136 } 137 if (oneFailed) { 138 result.setStatus(Result.FAILED); 139 } else if (na == descriptor.getEjbBundleDescriptors().size()) { 140 result.setStatus(Result.NOT_APPLICABLE); 141 } else { 142 result.setStatus(Result.PASSED); 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 151 return result; 152 } 153 } 154 | Popular Tags |