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 AppAltDDAppClient extends ApplicationTest implements AppCheck { 40 41 42 50 public Result check(Application descriptor) { 51 52 Result result = getInitializedResult(); 53 54 55 if (descriptor.getApplicationClientDescriptors().size() > 0) { 56 boolean oneFailed = false; 57 int na = 0; 58 for (Iterator itr = descriptor.getApplicationClientDescriptors().iterator(); itr.hasNext();) { 59 ApplicationClientDescriptor acd = (ApplicationClientDescriptor) itr.next(); 60 61 if (acd.getModuleDescriptor().getAlternateDescriptor()!=null) { 62 if (!(acd.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(acd.getModuleDescriptor().getAlternateDescriptor()); 75 84 if (deploymentEntry != null) { 85 result.addGoodDetails(smh.getLocalString 86 (getClass().getName() + ".passed", 87 "Found alternate application client deployment descriptor URI file [ {0} ] within [ {1} ]", 88 new Object [] {acd.getModuleDescriptor().getAlternateDescriptor(), acd.getName()})); 89 } else { 90 if (!oneFailed) { 91 oneFailed = true; 92 } 93 result.addErrorDetails(smh.getLocalString 94 (getClass().getName() + ".failed", 95 "Error: No alternate application client deployment descriptor URI file found, looking for [ {0} ] within [ {1} ]", 96 new Object [] {acd.getModuleDescriptor().getAlternateDescriptor(), acd.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 [] {acd.getModuleDescriptor().getAlternateDescriptor(), acd.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 [] {acd.getModuleDescriptor().getAlternateDescriptor(), acd.getName()})); 120 } finally { 121 try { 122 if (deploymentEntry !=null) 123 deploymentEntry.close(); 124 } catch (Exception x) {} 125 } 126 } 127 } else { 128 na++; 129 result.notApplicable(smh.getLocalString 130 (getClass().getName() + ".notApplicable1", 131 "There is no java application client alternative deployment descriptor in [ {0} ]", 132 new Object [] {acd.getName()})); 133 } 134 135 } 136 if (oneFailed) { 137 result.setStatus(Result.FAILED); 138 } else if (na == descriptor.getApplicationClientDescriptors().size()) { 139 result.setStatus(Result.NOT_APPLICABLE); 140 } else { 141 result.setStatus(Result.PASSED); 142 } 143 } else { 144 result.notApplicable(smh.getLocalString 145 (getClass().getName() + ".notApplicable", 146 "There are no java application clients in application [ {0} ]", 147 new Object [] {descriptor.getName()})); 148 } 149 150 return result; 151 } 152 } 153 | Popular Tags |