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 AppAltDDWeb extends ApplicationTest implements AppCheck { 40 41 42 50 public Result check(Application descriptor) { 51 52 Result result = getInitializedResult(); 53 54 55 if (descriptor.getWebBundleDescriptors().size() > 0) { 56 boolean oneFailed = false; 57 int na = 0; 58 for (Iterator itr = descriptor.getWebBundleDescriptors().iterator(); itr.hasNext();) { 59 WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next(); 60 61 if (wbd.getModuleDescriptor().getAlternateDescriptor()!=null) { 62 if (!(wbd.getModuleDescriptor().getAlternateDescriptor().equals(""))) { 63 InputStream deploymentEntry=null; 64 68 try { 69 String uri = getAbstractArchiveUri(descriptor); 71 FileArchive arch = new FileArchive(); 73 arch.open(uri); 74 deploymentEntry = arch.getEntry(wbd.getModuleDescriptor().getAlternateDescriptor()); 75 84 if (deploymentEntry != null) { 85 result.addGoodDetails(smh.getLocalString 86 (getClass().getName() + ".passed", 87 "Found alternate web deployment descriptor URI file [ {0} ] within [ {1} ]", 88 new Object [] {wbd.getModuleDescriptor().getAlternateDescriptor(),wbd.getName()})); 89 } else { 90 if (!oneFailed) { 91 oneFailed = true; 92 } 93 result.addErrorDetails(smh.getLocalString 94 (getClass().getName() + ".failed", 95 "Error: No alternate web deployment descriptor URI file found, looking for [{0} ] within [ {1} ]", 96 new Object [] {wbd.getModuleDescriptor().getAlternateDescriptor(), wbd.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 [] {wbd.getModuleDescriptor().getAlternateDescriptor(), wbd.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 [] {wbd.getModuleDescriptor().getAlternateDescriptor(), wbd.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 web alternative deployment descriptor in [ {0} ]", 133 new Object [] {wbd.getName()})); 134 } 135 } 136 if (oneFailed) { 137 result.setStatus(Result.FAILED); 138 } else if (na == descriptor.getWebBundleDescriptors().size()) { 139 result.setStatus(Result.NOT_APPLICABLE); 140 } else { 141 result.setStatus(Result.PASSED); 142 } 143 144 } else { 145 result.notApplicable(smh.getLocalString 146 (getClass().getName() + ".notApplicable", 147 "There are no web components in application [ {0} ]", 148 new Object [] {descriptor.getName()})); 149 } 150 151 152 return result; 153 } 154 } 155 | Popular Tags |