String resName;
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
boolean oneFailed = false;
boolean notApp = false;
try{
ResourceEnvRef[] envRefs= (descriptor.getSunDescriptor()).getResourceEnvRef();
if (envRefs != null && envRefs.length > 0) {
for (int rep=0; rep<envRefs.length; rep++ ) {
resName = envRefs[rep].getResourceEnvRefName();
if (validResEnvRefName(resName,descriptor)) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString
(getClass().getName() + ".passed",
"PASSED [AS-WEB sun-web-app] resource-env-ref [ {0} ] properly defined in the war file.",
new Object[] {resName}));
} else {
oneFailed = true;
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".failed",
"FAILED [AS-WEB sun-web-app] resource-env-ref name [ {0} ] is not valid, either empty or not defined in web.xml.",
new Object[] {resName}));
}
}
} else {
notApp = true;
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString
(getClass().getName() + ".notApplicable",
"NOT APPLICABLE [AS-WEB sun-web-app] resource-env-ref element not defined in the web archive [ {0} ].",
new Object[] {descriptor.getName()}));
}
if (oneFailed) {
result.setStatus(Result.FAILED);
} else if(notApp) {
result.setStatus(Result.NOT_APPLICABLE);
}else {
result.setStatus(Result.PASSED);
addGoodDetails(result, compName);
result.passed
(smh.getLocalString
(getClass().getName() + ".passed2",
"PASSED [AS-WEB sun-web-app] resource-env-ref element(s) are valid within the web archive [ {0} ].",
new Object[] {descriptor.getName()} ));
}
}catch(Exception ex){
oneFailed=true;
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".failed2", "FAILED [AS-WEB resource-env-ref] Could not create the resource-env-ref"));
}
return result;