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