1 23 24 package com.sun.enterprise.tools.verifier.tests.web.ias; 25 26 import java.util.*; 27 import com.sun.enterprise.deployment.*; 28 import com.sun.enterprise.tools.verifier.*; 29 import com.sun.enterprise.tools.verifier.tests.*; 30 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 31 import com.sun.enterprise.deployment.WebBundleDescriptor; 32 import com.sun.enterprise.tools.verifier.tests.web.*; 33 import com.sun.enterprise.tools.common.dd.webapp.*; 34 35 38 40 public class ASWebProperty extends WebTest implements WebCheck{ 41 42 43 public Result check(WebBundleDescriptor descriptor) { 44 45 46 Result result = getInitializedResult(); 47 48 WebComponentNameConstructor compName = new WebComponentNameConstructor(descriptor); 49 50 boolean oneFailed = false; 51 boolean notApp = false; 52 WebProperty[] webProps = descriptor.getIasWebApp().getWebProperty(); 53 if (webProps.length > 0) { 55 oneFailed=checkWebProperties(webProps,result ,descriptor, this ) ; 56 57 } else { 58 notApp = true; 60 result.notApplicable(smh.getLocalString 61 (getClass().getName() + ".notApplicable", 62 "NOT APPLICABLE [AS-WEB sun-web-app] web property element not defined within the web archive [ {0} ].", 63 new Object [] {descriptor.getName()})); 64 } 65 if (oneFailed) { 66 result.setStatus(Result.FAILED); 67 } else if(notApp) { 68 result.setStatus(Result.NOT_APPLICABLE); 69 }else { 70 result.setStatus(Result.PASSED); 71 } 72 73 74 75 return result; 76 } 77 public static boolean checkWebProperties(WebProperty[] webProps, Result result ,WebBundleDescriptor descriptor, Object obj ) { 78 WebComponentNameConstructor compName = new WebComponentNameConstructor(descriptor); 79 String name; 80 String value; 81 boolean oneFailed = false; 82 String [] names=null; 83 84 85 if (webProps.length > 0) { 86 names=new String [webProps.length]; 87 88 89 for (int rep=0; rep<webProps.length; rep++ ) { 90 92 name = webProps[rep].getAttributeValue(MetaData.NAME); 93 value = webProps[rep].getAttributeValue(MetaData.VALUE); 94 names[rep]=name; 95 96 if (name !=null && value !=null && name.length() != 0 && value.length() != 0) { 98 99 boolean isDuplicate=false; 101 for(int rep1=0;rep1<rep;rep1++) 102 { 103 if(name.equals(names[rep1])){ 104 isDuplicate=true; 105 break; 106 } 107 108 } 109 110 if(!isDuplicate){ 111 result.passed(smh.getLocalString 112 (obj.getClass().getName() + ".passed", 113 "PASSED [AS-WEB property] Proper web property with name [ {0} ] and value [ {1} ] defined.", 114 new Object [] {name, value})); 115 } else { 116 if (!oneFailed) 117 oneFailed = true; 118 119 result.failed(smh.getLocalString 120 (obj.getClass().getName() + ".failed", 121 "FAILED [AS-WEB property] name [ {0} ] and value [ {1} ], the name must be unique in the entire list of web property.", 122 new Object [] {name, value})); 123 } 124 125 } else { 126 if (!oneFailed) 127 oneFailed = true; 128 result.failed(smh.getLocalString 129 (obj.getClass().getName() + ".failed1", 130 "FAILED [AS-WEB property] name [ {0} ] and value [ {1} ], attributes must be of finite length.", 131 new Object [] {name, value})); 132 } 133 } 134 135 } 136 137 return oneFailed; 138 139 } 140 141 } 142 143 | Popular Tags |