use of org.apache.catalina.deploy.FilterMap in project Payara by payara.
the class StandardContext method addFilterMaps.
/**
* Add multiple filter mappings to this Context.
*
* @param filterMaps The filter mappings to be added
*
* @exception IllegalArgumentException if the specified filter name
* does not match an existing filter definition, or the filter mapping
* is malformed
*/
public void addFilterMaps(FilterMaps filterMaps) {
String[] servletNames = filterMaps.getServletNames();
String[] urlPatterns = filterMaps.getURLPatterns();
for (String servletName : servletNames) {
FilterMap fmap = new FilterMap();
fmap.setFilterName(filterMaps.getFilterName());
fmap.setServletName(servletName);
fmap.setDispatcherTypes(filterMaps.getDispatcherTypes());
addFilterMap(fmap);
}
for (String urlPattern : urlPatterns) {
FilterMap fmap = new FilterMap();
fmap.setFilterName(filterMaps.getFilterName());
fmap.setURLPattern(urlPattern);
fmap.setDispatcherTypes(filterMaps.getDispatcherTypes());
addFilterMap(fmap);
}
}
use of org.apache.catalina.deploy.FilterMap in project Payara by payara.
the class StandardHostValve method status.
/**
* Handle the HTTP status code (and corresponding message) generated
* while processing the specified Request to produce the specified
* Response. Any exceptions that occur during generation of the error
* report are logged and swallowed.
*
* @param request The request being processed
* @param response The response being generated
*/
protected void status(Request request, Response response) {
// Handle a custom error page for this status code
Context context = request.getContext();
if (context == null)
return;
/*
* Only look for error pages when isError() is set.
* isError() is set when response.sendError() is invoked.
*/
if (!response.isError()) {
return;
}
int statusCode = ((HttpResponse) response).getStatus();
ErrorPage errorPage = context.findErrorPage(statusCode);
if (errorPage != null) {
if (errorPage.getLocation() != null) {
File file = new File(context.getDocBase(), errorPage.getLocation());
if (!file.exists()) {
File file2 = new File(errorPage.getLocation());
if (!file2.exists()) {
boolean fileExists = false;
for (String servletMapping : ((StandardHost) getContainer()).findDeployedApp(context.getPath()).findServletMappings()) {
if (URLPattern.match(servletMapping, errorPage.getLocation())) {
fileExists = true;
break;
}
}
if (!fileExists) {
for (FilterMap mapping : ((StandardHost) getContainer()).findDeployedApp(context.getPath()).findFilterMaps()) {
if (mapping.getDispatcherTypes().contains(DispatcherType.ERROR) && URLPattern.match(mapping.getURLPattern(), errorPage.getLocation())) {
fileExists = true;
break;
}
}
if (!fileExists) {
log.log(Level.WARNING, LogFacade.ERROR_PAGE_NOT_EXIST, new Object[] { file.getAbsolutePath(), file2.getAbsolutePath() });
}
}
}
}
}
setErrorPageContentType(response, errorPage.getLocation(), context);
dispatchToErrorPage(request, response, errorPage, null, null, statusCode);
} else if (statusCode >= 400 && statusCode < 600 && context.getDefaultErrorPage() != null) {
dispatchToErrorPage(request, response, context.getDefaultErrorPage(), null, null, statusCode);
} else // START SJSAS 6324911
{
errorPage = ((StandardHost) getContainer()).findErrorPage(statusCode);
if (errorPage != null) {
if (errorPage.getLocation() != null) {
File file = new File(context.getDocBase(), errorPage.getLocation());
if (!file.exists()) {
File file2 = new File(errorPage.getLocation());
if (!file2.exists()) {
log.log(Level.WARNING, LogFacade.ERROR_PAGE_NOT_EXIST, new Object[] { file.getAbsolutePath(), file2.getAbsolutePath() });
}
}
}
try {
setErrorPageContentType(response, errorPage.getLocation(), context);
handleHostErrorPage(response, errorPage, statusCode);
} catch (Exception e) {
log("Exception processing " + errorPage, e);
}
}
}
// END SJSAS 6324911
}
Aggregations