Enumeration filtermapperEnum = descriptor.getServletFilterMappingDescriptors().elements();
if (filtermapperEnum.hasMoreElements()) {
ServletFilterMappingDescriptor filterMapper = null;
boolean mappingFound = false;
do {
filterMapper = (ServletFilterMappingDescriptor)filtermapperEnum.nextElement();
String filterMapping = filterMapper.getName();
mappingFound = filterName.equals(filterMapping);
} while (!mappingFound && filtermapperEnum.hasMoreElements());
if (mappingFound) {
List<String> urlPatterns = filterMapper.getURLPatterns();
for(String url : urlPatterns) {
if (!((url.startsWith("/")) ||
((url.startsWith("/")) && (url.endsWith("/*"))) ||
(url.startsWith("*.")))) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".failed",
"Filter Mapping for [ {0} ] has invalid " +
"url-mapping [ {1} ] ",
new Object[] {filterName, url} ));
}
}
List<String> servletsInFilter = filterMapper.getServletNames();
List<String> servletsInWAR = new ArrayList<String>();
if(servletsInFilter.size() > 0) {
Set servletDescriptor = descriptor.getServletDescriptors();
Iterator itr = servletDescriptor.iterator();
// test the servlets in this .war
while (itr.hasNext()) {
WebComponentDescriptor servlet = (WebComponentDescriptor) itr.next();
servletsInWAR.add(servlet.getCanonicalName());
}
if (!(servletsInWAR != null && servletsInWAR.containsAll(servletsInFilter))) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".failed1",
"Filter Mapping for [ {0} ] has invalid servlet-name",
new Object[] {filterName}));
}
}
}
}