1 23 24 package com.sun.enterprise.tools.verifier.tests.web.runtime; 25 26 import com.sun.enterprise.deployment.WebBundleDescriptor; 27 import com.sun.enterprise.deployment.runtime.web.Cache; 28 import com.sun.enterprise.deployment.runtime.web.CacheHelper; 29 import com.sun.enterprise.deployment.runtime.web.WebProperty; 30 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 31 import com.sun.enterprise.tools.verifier.tests.web.WebCheck; 32 import com.sun.enterprise.tools.verifier.Result; 33 34 37 39 40 41 42 public class ASCacheHelperClass extends ASCache implements WebCheck { 43 public Result check(WebBundleDescriptor descriptor) { 44 Result result = getInitializedResult(); 45 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 46 boolean oneFailed = false; 47 boolean notApp = false; 48 boolean oneWarning=false; 49 boolean presentHelper=false; 50 51 try{ 52 Cache cache = (descriptor.getSunDescriptor()).getCache(); 53 CacheHelper[] helperClasses=null; 54 CacheHelper helperClass=null; 55 WebProperty[] webProps; 56 String name=null; 57 String classname=null; 58 String [] names=null; 59 if (cache != null ) 61 helperClasses=cache.getCacheHelper(); 62 if (cache != null && helperClasses !=null && helperClasses.length > 0) 63 { 64 names=new String [helperClasses.length]; 65 for(int rep=0;rep < helperClasses.length;rep++) 66 { 67 helperClass=helperClasses[rep]; 68 if(helperClass==null) 69 continue; 70 int i = rep+1; 71 name = getXPathValue("sun-web-app/cache/cache-helper["+i+"]/@name"); 72 classname = getXPathValue("sun-web-app/cache/cache-helper["+i+"]/@class-name"); 73 Class hClass=null; 74 names[rep]=name; 75 76 if (name != null && name.length() != 0) { 77 boolean isDuplicate=false; 79 for(int rep1=0;rep1<rep;rep1++) 80 { 81 if(name.equals(names[rep1])) 82 { 83 isDuplicate=true; 84 break; 85 } 86 87 } 88 if(isDuplicate) 89 { 90 oneFailed = true; 91 addErrorDetails(result, compName); 92 result.failed(smh.getLocalString 93 (getClass().getName() + ".failed", 94 "FAILED [AS-WEB cache-helper] name attribute [ {0} ], must be unique in the entire list of cache-helper.", 95 new Object [] {name})); 96 } 97 else 98 { 99 if(classname!=null && classname.length()!=0) { 100 hClass = loadClass(result,classname); 101 } 102 if(hClass !=null) 103 presentHelper=true ; 104 else 105 presentHelper=false ; 106 107 if(!presentHelper) 108 { 109 addWarningDetails(result, compName); 110 result.warning(smh.getLocalString( 111 getClass().getName() + ".error", 112 "WARNING [AS-WEB cache-helper] " + 113 "name [ {0} ], class not present in the war file.", 114 new Object [] {name})); 115 oneWarning = true; 116 } 117 else 118 { 119 addGoodDetails(result, compName); 120 result.passed(smh.getLocalString 121 (getClass().getName() + ".passed", 122 "PASSED [AS-WEB cache-helper] name [ {0} ], helper class is valid.", 123 new Object [] {name})); 124 } 125 126 } 127 } else { 128 addErrorDetails(result, compName); 129 result.failed(smh.getLocalString 130 (getClass().getName() + ".failed1", 131 "FAILED [AS-WEB cache-helper] name [ {0} ], either empty or null.", 132 new Object [] {name})); 133 oneFailed = true; 134 135 } 136 webProps=helperClass.getWebProperty(); 137 if(ASWebProperty.checkWebProperties(webProps,result ,descriptor, this )){ 138 oneFailed=true; 139 addErrorDetails(result, compName); 140 result.failed(smh.getLocalString 141 (getClass().getName() + ".failed2", 142 "FAILED [AS-WEB cache-helper] Atleast one name/value pair is not valid in helper-class of [ {0} ].", 143 new Object [] {descriptor.getName()})); 144 } 145 } }else 147 { 148 notApp = true; 149 addNaDetails(result, compName); 150 result.notApplicable(smh.getLocalString 151 (getClass().getName() + ".notApplicable", 152 "NOT APPLICABLE [AS-WEB cache-helper] There is no cache-helper element for the web application", 153 new Object [] {descriptor.getName()})); 154 } 155 if (oneFailed) { 156 result.setStatus(Result.FAILED); 157 } else if(oneWarning){ 158 result.setStatus(Result.WARNING); 159 } else if(notApp) { 160 result.setStatus(Result.NOT_APPLICABLE); 161 }else { 162 result.setStatus(Result.PASSED); 163 } 164 165 }catch(Exception ex){ 166 oneFailed = true; 167 addErrorDetails(result, compName); 168 result.failed(smh.getLocalString 169 (getClass().getName() + ".failed3", 170 "FAILED [AS-WEB cache-helper] could not create the cache object")); 171 } 172 return result; 173 } 174 } 175 | Popular Tags |