ASCacheMappingFieldConstraintpublic class ASCacheMappingFieldConstraint extends ASCache implements WebCheck
Methods Summary |
---|
public Result | check(com.sun.enterprise.deployment.WebBundleDescriptor descriptor)
Result result = getInitializedResult();
WebComponentNameConstructor compName = new WebComponentNameConstructor(descriptor);
boolean oneFailed = false;
boolean notApp = false;
boolean doneAtleastOnce=false;
Cache cache = getCache(descriptor);
CacheMapping[] cacheMapp=null;
String servletName;
String urlPattern;
ConstraintField[] fieldConstraints=null;
String mappingFor=null;
if (cache != null ){
cacheMapp=cache.getCacheMapping();
}
if (cache != null && cacheMapp !=null && cacheMapp.length !=0 ) {
for(int rep=0;rep < cacheMapp.length;rep++){
servletName = cacheMapp[rep].getServletName();
urlPattern = cacheMapp[rep].getUrlPattern();
if(servletName !=null)
mappingFor=servletName;
else
mappingFor=urlPattern;
fieldConstraints = cacheMapp[rep].getConstraintField();
if(fieldConstraints !=null && fieldConstraints.length != 0)
{
for(int rep1=0;rep1 < fieldConstraints.length;rep1++){
if(fieldConstraints[rep1] !=null){
doneAtleastOnce=true;
if(checkFieldConstraint(fieldConstraints[rep1],result,mappingFor,descriptor,compName)){
//nothing more required
}
else{
oneFailed = true;
result.failed(smh.getLocalString
(getClass().getName() + ".failed",
"FAILED [AS-WEB cache-mapping] List of field-constraint in cache-mapping for [ {0} ] is not proper, within the web archive/sun-web.xml of [ {1} ].",
new Object[] {mappingFor,descriptor.getName()}));
}
}
}//end of for(int rep1=0;rep1 < fieldConstraints.length;rep1++)
}
}//end of for(int rep=0;rep < cacheMapp.length;rep++)
}else {
notApp=true;
}
if (oneFailed) {
result.setStatus(Result.FAILED);
} else if(notApp || !doneAtleastOnce) {
result.setStatus(Result.NOT_APPLICABLE);
result.notApplicable(smh.getLocalString
(getClass().getName() + ".notApplicable",
"NOT APPLICABLE [AS-WEB cache-mapping ] constraint-field not defined in [ {0} ].",
new Object[] {descriptor.getName()}));
}else {
result.setStatus(Result.PASSED);
}
return result;
| boolean | checkFieldConstraint(ConstraintField fieldCons, Result result, java.lang.String mappingFor, com.sun.enterprise.deployment.WebBundleDescriptor descriptor, WebComponentNameConstructor compName)
boolean valid=true;
String fieldName;
String[] values;
if (fieldCons != null) {
fieldName= fieldCons.getAttributeValue("name");
values=fieldCons.getValue();
if(fieldName!=null && ! fieldName.equals("")){
result.passed(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.passed(smh.getLocalString
(getClass().getName() + ".passed1",
"PASSED [AS-WEB cache-mapping] Proper field-constraint/fieldName [ {0} ] defined for [ {1} ].",
new Object[] {fieldName,mappingFor}));
}else{
valid=false;
result.failed(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.failed(smh.getLocalString
(getClass().getName() + ".failed1",
"FAILED [AS-WEB cache-mapping] field-constraint/fieldName [ {0} ] defined for [ {1} ], attribute can not be empty.",
new Object[] {fieldName,mappingFor}));
}
for(int rep=0;values !=null && rep < values.length;rep++){
if(values[rep]!=null && ! values[rep].equals("")) {
result.passed(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.passed(smh.getLocalString
(getClass().getName() + ".passed2",
"PASSED [AS-WEB cache-mapping]Proper field-constraint/value [ {0} ] defined for [ {1} ], within the web archive/sun-web.xml of [ {2} ].",
new Object[] {values[rep],mappingFor,descriptor.getName()}));
}else {
valid=false;
result.failed(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.failed(smh.getLocalString
(getClass().getName() + ".failed2",
"FAILED [AS-WEB cache-mapping] field-constraint/value [ {0} ] defined for [ {1} ], can not be empty, within the web archive/sun-web.xml of [ {2} ].",
new Object[] {values[rep],mappingFor,descriptor.getName()}));
}
}
}
return valid;
|
|